Skip to content

Instantly share code, notes, and snippets.

@jesboat
Created August 16, 2019 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesboat/a88aa28f0a80c876872425901bdd9279 to your computer and use it in GitHub Desktop.
Save jesboat/a88aa28f0a80c876872425901bdd9279 to your computer and use it in GitHub Desktop.
pub fn voidfn() -> () {}
rustc --crate-type=rlib a/a.rs
rustc \
--emit=asm,llvm-ir -Cllvm-args='-print-isel-input=true -print-machineinstrs -fast-isel' \
--crate-type=lib --extern a=liba.rlib \
-Crelocation-model=static \
main.rs \
2>details
*** Final LLVM Code input to ISel ***
; Function Attrs: nonlazybind uwtable
define void @_ZN4main8example117h149bc290ecddb5b8E() unnamed_addr #0 {
start:
call void @_ZN4main5takep17h851b97fbf6407c1bE(void ()* nonnull @_ZN1a6voidfn17h7d790e74ed3ff940E)
br label %bb1
bb1: ; preds = %start
ret void
}
# After Instruction Selection:
# Machine code for function _ZN4main8example117h149bc290ecddb5b8E: IsSSA, TracksLiveness
bb.0.start:
successors: %bb.1
%0:gr64 = MOV64rm $noreg, 1, $noreg, target-flags(x86-gotpcrel) @_ZN1a6voidfn17h7d790e74ed3ff940E, $noreg
ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
$rdi = COPY %0:gr64
CALL64pcrel32 @_ZN4main5takep17h851b97fbf6407c1bE, <regmask $bh $bl $bp $bph $bpl $bx $ebp $ebx $hbp $hbx $rbp $rbx $r12 $r13 $r14 $r15 $r12b $r13b $r14b $r15b $r12bh $r13bh $r14bh $r15bh $r12d $r13d $r14d $r15d $r12w $r13w $r14w $r15w $r12wh and 3 more...>, implicit $rsp, implicit $ssp, implicit $rdi
ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
bb.1.bb1:
; predecessors: %bb.0
RETQ
# End machine code for function _ZN4main8example117h149bc290ecddb5b8E.
; Function Attrs: nonlazybind uwtable
define void @_ZN4main8example217h4f443cbc5e17bbddE() unnamed_addr #0 personality i32 (i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*)* @rust_eh_personality {
start:
%personalityslot = alloca { i8*, i32 }, align 8
%_v = alloca %Droppable, align 1
invoke void @_ZN4main5takep17h851b97fbf6407c1bE(void ()* nonnull @_ZN1a6voidfn17h7d790e74ed3ff940E)
to label %bb2 unwind label %cleanup
bb1: ; preds = %bb3
%0 = bitcast { i8*, i32 }* %personalityslot to i8**
%1 = load i8*, i8** %0, align 8
%2 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %personalityslot, i32 0, i32 1
call void @_Unwind_Resume(i8* %1)
unreachable
bb2: ; preds = %start
call void @_ZN4core3ptr18real_drop_in_place17h6782efda6a962288E(%Droppable* nonnull align 1 %_v)
br label %bb4
bb3: ; preds = %cleanup
call void @_ZN4core3ptr18real_drop_in_place17h6782efda6a962288E(%Droppable* nonnull align 1 %_v) #3
br label %bb1
bb4: ; preds = %bb2
ret void
cleanup: ; preds = %start
%3 = landingpad { i8*, i32 }
cleanup
%4 = extractvalue { i8*, i32 } %3, 0
%5 = extractvalue { i8*, i32 } %3, 1
%6 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %personalityslot, i32 0, i32 0
store i8* %4, i8** %6, align 8
%7 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %personalityslot, i32 0, i32 1
store i32 %5, i32* %7, align 8
br label %bb3
}
# After Instruction Selection:
# Machine code for function _ZN4main8example217h4f443cbc5e17bbddE: IsSSA, TracksLiveness
Frame Objects:
fi#0: size=16, align=8, at location [SP+8]
fi#1: size=1, align=8, at location [SP+8]
bb.0.start:
successors: %bb.2, %bb.5
EH_LABEL <mcsymbol .Ltmp0>
ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
%0:gr64 = MOV64rm $rip, 1, $noreg, target-flags(x86-gotpcrel) @_ZN1a6voidfn17h7d790e74ed3ff940E, $noreg :: (load 8 from got)
$rdi = COPY %0:gr64
CALL64pcrel32 @_ZN4main5takep17h851b97fbf6407c1bE, <regmask $bh $bl $bp $bph $bpl $bx $ebp $ebx $hbp $hbx $rbp $rbx $r12 $r13 $r14 $r15 $r12b $r13b $r14b $r15b $r12bh $r13bh $r14bh $r15bh $r12d $r13d $r14d $r15d $r12w $r13w $r14w $r15w $r12wh and 3 more...>, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
EH_LABEL <mcsymbol .Ltmp1>
JMP_1 %bb.2
bb.1.bb1:
; predecessors: %bb.3
%8:gr64 = MOV64rm %stack.0.personalityslot, 1, $noreg, 0, $noreg :: (dereferenceable load 8 from %ir.0)
ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
$rdi = COPY %8:gr64
CALL64pcrel32 @_Unwind_Resume, <regmask $bh $bl $bp $bph $bpl $bx $ebp $ebx $hbp $hbx $rbp $rbx $r12 $r13 $r14 $r15 $r12b $r13b $r14b $r15b $r12bh $r13bh $r14bh $r15bh $r12d $r13d $r14d $r15d $r12w $r13w $r14w $r15w $r12wh and 3 more...>, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
TRAP
bb.2.bb2:
; predecessors: %bb.0
successors: %bb.4
ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
%9:gr64 = LEA64r %stack.1._v, 1, $noreg, 0, $noreg
$rdi = COPY %9:gr64
CALL64pcrel32 @_ZN4core3ptr18real_drop_in_place17h6782efda6a962288E, <regmask $bh $bl $bp $bph $bpl $bx $ebp $ebx $hbp $hbx $rbp $rbx $r12 $r13 $r14 $r15 $r12b $r13b $r14b $r15b $r12bh $r13bh $r14bh $r15bh $r12d $r13d $r14d $r15d $r12w $r13w $r14w $r15w $r12wh and 3 more...>, implicit $rsp, implicit $ssp, implicit $rdi
ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
JMP_1 %bb.4
bb.3.bb3:
; predecessors: %bb.5
successors: %bb.1
ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
%7:gr64 = LEA64r %stack.1._v, 1, $noreg, 0, $noreg
$rdi = COPY %7:gr64
CALL64pcrel32 @_ZN4core3ptr18real_drop_in_place17h6782efda6a962288E, <regmask $bh $bl $bp $bph $bpl $bx $ebp $ebx $hbp $hbx $rbp $rbx $r12 $r13 $r14 $r15 $r12b $r13b $r14b $r15b $r12bh $r13bh $r14bh $r15bh $r12d $r13d $r14d $r15d $r12w $r13w $r14w $r15w $r12wh and 3 more...>, implicit $rsp, implicit $ssp, implicit $rdi
ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
JMP_1 %bb.1
bb.4.bb4:
; predecessors: %bb.2
RETQ
bb.5.cleanup (landing-pad):
; predecessors: %bb.0
successors: %bb.3
liveins: $rax, $rdx
EH_LABEL <mcsymbol .Ltmp2>
%2:gr64 = COPY killed $rdx
%1:gr64 = COPY killed $rax
%6:gr32 = COPY %2.sub_32bit:gr64
%5:gr64 = COPY %1:gr64
MOV64mr %stack.0.personalityslot, 1, $noreg, 0, $noreg, killed %5:gr64 :: (store 8 into %ir.6)
MOV32mr %stack.0.personalityslot, 1, $noreg, 8, $noreg, killed %6:gr32 :: (store 4 into %ir.7, align 8)
JMP_1 %bb.3
# End machine code for function _ZN4main8example217h4f443cbc5e17bbddE.
extern crate a;
pub fn takep(arg: fn() -> ()) -> () {}
pub fn example1() {
takep(a::voidfn);
}
struct Droppable {}
impl Drop for Droppable {
fn drop(&mut self) {}
}
pub fn example2() {
let _v = Droppable{};
takep(a::voidfn);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment