Skip to content

Instantly share code, notes, and snippets.

@cramertj
Created August 7, 2018 01:00
Show Gist options
  • Save cramertj/25dcc75a28e183f699dbbd42fbeb500d to your computer and use it in GitHub Desktop.
Save cramertj/25dcc75a28e183f699dbbd42fbeb500d to your computer and use it in GitHub Desktop.
; ModuleID = 'main0-317d481089b8c8fe83113de504472633.rs'
source_filename = "main0-317d481089b8c8fe83113de504472633.rs"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%"core::fmt::Arguments" = type { [0 x i64], { [0 x { [0 x i8]*, i64 }]*, i64 }, [0 x i64], { i64*, i64 }, [0 x i64], { [0 x { i8*, i8* }]*, i64 }, [0 x i64] }
%"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_place17h2f1aa87fe2ee6613E, i64 8, i64 8, i32 (i8**)* @"_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h20a9a6e32dc32665E", i32 (i8**)* @"_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h20a9a6e32dc32665E", i32 (i8*)* @_ZN4core3ops8function6FnOnce9call_once17h613edd86d736fc4dE }, align 8
@byte_str.1 = private unnamed_addr constant <{ [7 x i8] }> <{ [7 x i8] c"oh no!\0A" }>, align 1
@byte_str.2 = private unnamed_addr constant <{ i8*, [8 x i8] }> <{ i8* getelementptr inbounds (<{ [7 x i8] }>, <{ [7 x i8] }>* @byte_str.1, i32 0, i32 0, i32 0), [8 x i8] c"\07\00\00\00\00\00\00\00" }>, align 8
@byte_str.3 = private unnamed_addr constant <{ [0 x i8] }> zeroinitializer, align 8
; std::rt::lang_start
; Function Attrs: uwtable
define hidden i64 @_ZN3std2rt10lang_start17he9b04dd74ce36000E(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_internal17h29f0088f4842b11fE({}* nonnull %1, [6 x i64]* noalias readonly dereferenceable(48) bitcast ({ void (i8**)*, i64, i64, i32 (i8**)*, i32 (i8**)*, i32 (i8*)* }* @vtable.0 to [6 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$17h20a9a6e32dc32665E"(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$6report17hac87111a13be2d60E"()
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_i3217h36ea415d7049ff89E(i8* noalias readonly dereferenceable(1) %self) unnamed_addr #1 {
start:
%0 = load i8, i8* %self, align 1
%1 = icmp ule i8 %0, -1
call void @llvm.assume(i1 %1)
%2 = zext i8 %0 to i32
ret i32 %2
}
; core::fmt::Arguments::new_v1
; Function Attrs: inlinehint uwtable
define internal void @_ZN4core3fmt9Arguments6new_v117h2b8032ea465abf95E(%"core::fmt::Arguments"* noalias nocapture sret dereferenceable(48), [0 x { [0 x i8]*, i64 }]* noalias nonnull readonly %pieces.0, i64 %pieces.1, [0 x { i8*, i8* }]* noalias nonnull readonly %args.0, i64 %args.1) unnamed_addr #1 {
start:
%_4 = alloca { i64*, i64 }, align 8
%1 = bitcast { i64*, i64 }* %_4 to {}**
store {}* null, {}** %1, align 8
%2 = bitcast %"core::fmt::Arguments"* %0 to { [0 x { [0 x i8]*, i64 }]*, i64 }*
%3 = getelementptr inbounds { [0 x { [0 x i8]*, i64 }]*, i64 }, { [0 x { [0 x i8]*, i64 }]*, i64 }* %2, i32 0, i32 0
store [0 x { [0 x i8]*, i64 }]* %pieces.0, [0 x { [0 x i8]*, i64 }]** %3, align 8
%4 = getelementptr inbounds { [0 x { [0 x i8]*, i64 }]*, i64 }, { [0 x { [0 x i8]*, i64 }]*, i64 }* %2, i32 0, i32 1
store i64 %pieces.1, i64* %4, align 8
%5 = getelementptr inbounds %"core::fmt::Arguments", %"core::fmt::Arguments"* %0, i32 0, i32 3
%6 = getelementptr inbounds { i64*, i64 }, { i64*, i64 }* %_4, i32 0, i32 0
%7 = load i64*, i64** %6, align 8
%8 = getelementptr inbounds { i64*, i64 }, { i64*, i64 }* %_4, i32 0, i32 1
%9 = load i64, i64* %8, align 8
%10 = getelementptr inbounds { i64*, i64 }, { i64*, i64 }* %5, i32 0, i32 0
store i64* %7, i64** %10, align 8
%11 = getelementptr inbounds { i64*, i64 }, { i64*, i64 }* %5, i32 0, i32 1
store i64 %9, i64* %11, align 8
%12 = getelementptr inbounds %"core::fmt::Arguments", %"core::fmt::Arguments"* %0, i32 0, i32 5
%13 = getelementptr inbounds { [0 x { i8*, i8* }]*, i64 }, { [0 x { i8*, i8* }]*, i64 }* %12, i32 0, i32 0
store [0 x { i8*, i8* }]* %args.0, [0 x { i8*, i8* }]** %13, align 8
%14 = getelementptr inbounds { [0 x { i8*, i8* }]*, i64 }, { [0 x { i8*, i8* }]*, i64 }* %12, i32 0, i32 1
store i64 %args.1, i64* %14, align 8
ret void
}
; core::ops::function::FnOnce::call_once
; Function Attrs: uwtable
define internal i32 @_ZN4core3ops8function6FnOnce9call_once17h613edd86d736fc4dE(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$17h20a9a6e32dc32665E"(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_place17h2f1aa87fe2ee6613E(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$6report17hac87111a13be2d60E"() 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$6report17hf40c537cbb27df63E"(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$6report17hf40c537cbb27df63E"(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_i3217h36ea415d7049ff89E(i8* noalias readonly dereferenceable(1) %self)
br label %bb1
bb1: ; preds = %start
ret i32 %1
}
; main::main
; Function Attrs: uwtable
define internal void @_ZN4main4main17hd31e54a560abace9E() unnamed_addr #0 {
start:
%_9 = alloca {}, align 1
%_2 = alloca %"core::fmt::Arguments", align 8
; call core::fmt::Arguments::new_v1
call void @_ZN4core3fmt9Arguments6new_v117h2b8032ea465abf95E(%"core::fmt::Arguments"* noalias nocapture sret dereferenceable(48) %_2, [0 x { [0 x i8]*, i64 }]* noalias nonnull readonly bitcast (<{ i8*, [8 x i8] }>* @byte_str.2 to [0 x { [0 x i8]*, i64 }]*), i64 1, [0 x { i8*, i8* }]* noalias nonnull readonly bitcast (<{ [0 x i8] }>* @byte_str.3 to [0 x { i8*, i8* }]*), i64 0)
br label %bb1
bb1: ; preds = %start
; call std::io::stdio::_print
call void @_ZN3std2io5stdio6_print17h8638fb8d66db7db0E(%"core::fmt::Arguments"* noalias nocapture dereferenceable(48) %_2)
br label %bb2
bb2: ; preds = %bb1
ret void
}
; std::rt::lang_start_internal
declare i64 @_ZN3std2rt19lang_start_internal17h29f0088f4842b11fE({}* nonnull, [6 x i64]* noalias readonly dereferenceable(48), i64, i8**) unnamed_addr #2
; Function Attrs: nounwind
declare void @llvm.assume(i1) #3
declare i32 @rust_eh_personality(i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*) unnamed_addr #2
; std::io::stdio::_print
declare void @_ZN3std2io5stdio6_print17h8638fb8d66db7db0E(%"core::fmt::Arguments"* noalias nocapture dereferenceable(48)) unnamed_addr #2
define i32 @main(i32, i8**) unnamed_addr {
top:
%2 = sext i32 %0 to i64
; call std::rt::lang_start
%3 = call i64 @_ZN3std2rt10lang_start17he9b04dd74ce36000E(void ()* @_ZN4main4main17hd31e54a560abace9E, i64 %2, i8** %1)
%4 = trunc i64 %3 to i32
ret i32 %4
}
attributes #0 = { uwtable "probe-stack"="__rust_probestack" }
attributes #1 = { inlinehint uwtable "probe-stack"="__rust_probestack" }
attributes #2 = { "probe-stack"="__rust_probestack" }
attributes #3 = { nounwind }
!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