Skip to content

Instantly share code, notes, and snippets.

@lqd
Created September 20, 2018 21:16
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 lqd/c2bc1eb891b59c6258fdcfd4961bed7b to your computer and use it in GitHub Desktop.
Save lqd/c2bc1eb891b59c6258fdcfd4961bed7b to your computer and use it in GitHub Desktop.
; ModuleID = 'extern_const.7rcbfp3g-cgu.0'
source_filename = "extern_const.7rcbfp3g-cgu.0"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-darwin"
%"unwind::libunwind::_Unwind_Exception" = type { [0 x i64], i64, [0 x i64], void (i32, %"unwind::libunwind::_Unwind_Exception"*)*, [0 x i64], [6 x i64], [0 x i64] }
%"unwind::libunwind::_Unwind_Context" = type { [0 x i8] }
@vtable.0 = private unnamed_addr constant { void (i8**)*, i64, i64, i32 (i8**)*, i32 (i8**)*, i32 (i8*)* } { void (i8**)* @_ZN4core3ptr13drop_in_place17hc14534eece999a74E, i64 8, i64 8, i32 (i8**)* @"_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h2ab5e0001d4cd98cE", i32 (i8**)* @"_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h2ab5e0001d4cd98cE", i32 (i8*)* @_ZN4core3ops8function6FnOnce9call_once17hbbcec13b4120ec4fE }, align 8
@C = external global i8
; std::rt::lang_start
; Function Attrs: uwtable
define hidden i64 @_ZN3std2rt10lang_start17h68b725913dfb2382E(void ()* nonnull %main, i64 %argc, i8** %argv) unnamed_addr #0 {
start:
%_7 = alloca i8*, align 8
%0 = bitcast i8** %_7 to void ()**
store void ()* %main, void ()** %0, align 8
%1 = bitcast i8** %_7 to {}*
; call std::rt::lang_start_internal
%2 = call i64 @_ZN3std2rt19lang_start_internal17h2a0359a3e80fe152E({}* nonnull %1, [3 x i64]* noalias readonly dereferenceable(24) bitcast ({ void (i8**)*, i64, i64, i32 (i8**)*, i32 (i8**)*, i32 (i8*)* }* @vtable.0 to [3 x i64]*), i64 %argc, i8** %argv)
br label %bb1
bb1: ; preds = %start
ret i64 %2
}
; std::rt::lang_start::{{closure}}
; Function Attrs: uwtable
define internal i32 @"_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h2ab5e0001d4cd98cE"(i8** noalias readonly dereferenceable(8) %arg0) unnamed_addr #0 {
start:
%0 = bitcast i8** %arg0 to void ()**
%1 = load void ()*, void ()** %0, align 8, !nonnull !1
call void %1()
br label %bb1
bb1: ; preds = %start
; call <() as std::process::Termination>::report
%2 = call i32 @"_ZN54_$LT$$LP$$RP$$u20$as$u20$std..process..Termination$GT$6report17hd975198253364f2aE"()
br label %bb2
bb2: ; preds = %bb1
ret i32 %2
}
; std::sys::unix::process::process_common::ExitCode::as_i32
; Function Attrs: inlinehint uwtable
define internal i32 @_ZN3std3sys4unix7process14process_common8ExitCode6as_i3217h67cd608f12564695E(i8* noalias readonly dereferenceable(1) %self) unnamed_addr #1 {
start:
%0 = load i8, i8* %self, align 1
%1 = zext i8 %0 to i32
ret i32 %1
}
; core::ops::function::FnOnce::call_once
; Function Attrs: uwtable
define internal i32 @_ZN4core3ops8function6FnOnce9call_once17hbbcec13b4120ec4fE(i8* nonnull) 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
%arg1 = alloca {}, align 1
%arg0 = alloca i8*, align 8
store i8* %0, i8** %arg0, align 8
; invoke std::rt::lang_start::{{closure}}
%1 = invoke i32 @"_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h2ab5e0001d4cd98cE"(i8** noalias dereferenceable(8) %arg0)
to label %bb1 unwind label %cleanup
bb1: ; preds = %start
br label %bb2
bb2: ; preds = %bb1
ret i32 %1
bb3: ; preds = %cleanup
br label %bb4
bb4: ; preds = %bb3
%2 = bitcast { i8*, i32 }* %personalityslot to i8**
%3 = load i8*, i8** %2, align 8
%4 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %personalityslot, i32 0, i32 1
%5 = load i32, i32* %4, align 4
%6 = insertvalue { i8*, i32 } undef, i8* %3, 0
%7 = insertvalue { i8*, i32 } %6, i32 %5, 1
resume { i8*, i32 } %7
cleanup: ; preds = %start
%8 = landingpad { i8*, i32 }
cleanup
%9 = extractvalue { i8*, i32 } %8, 0
%10 = extractvalue { i8*, i32 } %8, 1
%11 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %personalityslot, i32 0, i32 0
store i8* %9, i8** %11, align 8
%12 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %personalityslot, i32 0, i32 1
store i32 %10, i32* %12, align 8
br label %bb3
}
; core::ptr::drop_in_place
; Function Attrs: uwtable
define internal void @_ZN4core3ptr13drop_in_place17hc14534eece999a74E(i8** %arg0) unnamed_addr #0 {
start:
ret void
}
; <() as std::process::Termination>::report
; Function Attrs: inlinehint uwtable
define internal i32 @"_ZN54_$LT$$LP$$RP$$u20$as$u20$std..process..Termination$GT$6report17hd975198253364f2aE"() unnamed_addr #1 {
start:
; call <std::process::ExitCode as std::process::Termination>::report
%0 = call i32 @"_ZN68_$LT$std..process..ExitCode$u20$as$u20$std..process..Termination$GT$6report17h986be17942fd684dE"(i8 0)
br label %bb1
bb1: ; preds = %start
ret i32 %0
}
; <std::process::ExitCode as std::process::Termination>::report
; Function Attrs: inlinehint uwtable
define internal i32 @"_ZN68_$LT$std..process..ExitCode$u20$as$u20$std..process..Termination$GT$6report17h986be17942fd684dE"(i8) unnamed_addr #1 {
start:
%self = alloca i8, align 1
store i8 %0, i8* %self, align 1
; call std::sys::unix::process::process_common::ExitCode::as_i32
%1 = call i32 @_ZN3std3sys4unix7process14process_common8ExitCode6as_i3217h67cd608f12564695E(i8* noalias readonly dereferenceable(1) %self)
br label %bb1
bb1: ; preds = %start
ret i32 %1
}
; extern_const::main
; Function Attrs: uwtable
define internal void @_ZN12extern_const4main17hbff16dcccc4c621dE() unnamed_addr #0 {
start:
%_x = alloca i8, align 1
%0 = load i8, i8* @C, align 1
store i8 %0, i8* %_x, align 1
ret void
}
; std::rt::lang_start_internal
; Function Attrs: uwtable
declare i64 @_ZN3std2rt19lang_start_internal17h2a0359a3e80fe152E({}* nonnull, [3 x i64]* noalias readonly dereferenceable(24), i64, i8**) unnamed_addr #0
; Function Attrs: uwtable
declare i32 @rust_eh_personality(i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*) unnamed_addr #2
define i32 @main(i32, i8**) unnamed_addr #3 {
top:
%2 = sext i32 %0 to i64
; call std::rt::lang_start
%3 = call i64 @_ZN3std2rt10lang_start17h68b725913dfb2382E(void ()* @_ZN12extern_const4main17hbff16dcccc4c621dE, i64 %2, i8** %1)
%4 = trunc i64 %3 to i32
ret i32 %4
}
attributes #0 = { uwtable "no-frame-pointer-elim"="true" "probe-stack"="__rust_probestack" }
attributes #1 = { inlinehint uwtable "no-frame-pointer-elim"="true" "probe-stack"="__rust_probestack" }
attributes #2 = { uwtable "no-frame-pointer-elim"="true" "probe-stack"="__rust_probestack" "target-cpu"="core2" }
attributes #3 = { "no-frame-pointer-elim"="true" "target-cpu"="core2" }
!llvm.module.flags = !{!0}
!0 = !{i32 7, !"PIE Level", i32 2}
!1 = !{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment