Skip to content

Instantly share code, notes, and snippets.

@nickdesaulniers
Last active December 18, 2015 03:09
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 nickdesaulniers/5716101 to your computer and use it in GitHub Desktop.
Save nickdesaulniers/5716101 to your computer and use it in GitHub Desktop.
llvm-dis hello_world.bc -o hello_world.ll
; ModuleID = 'hello_world.bc'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-apple-darwin"
%tydesc = type { i64, i64, void ({}*, %tydesc**, i8*)*, void ({}*, %tydesc**, i8*)*, void ({}*, %tydesc**, i8*)*, void ({}*, %tydesc**, i8*)*, i8*, i8* }
@_rust_crate_map_toplevel = global { i32, i8*, i64, [2 x i64] } { i32 1, i8* bitcast ({} ({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)*)* @_ZN7cleanup10annihilate17_c17425bfbdabf8296_07preE to i8*), i64 ptrtoint ([1 x { i64, i64 }]* @_rust_mod_map to i64), [2 x i64] [i64 ptrtoint (i64* @_rust_crate_map_std_0.7-pre_c3ca5d77d81b46c1 to i64), i64 0] }
@_rust_crate_map_std_0.7-pre_c3ca5d77d81b46c1 = external global i64
@_rust_mod_map = internal global [1 x { i64, i64 }] zeroinitializer
@rust_abi_version = constant i64 1
declare i64 @upcall_call_shim_on_rust_stack(i8*, i8*)
define internal i64 @_ZN9add_three16_e0f64ae76a8e9923_00E({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)*, i64) {
static_allocas:
%2 = alloca i64
%3 = alloca i64
br label %5
return: ; preds = %5
%4 = load i64* %2
ret i64 %4
; <label>:5 ; preds = %static_allocas
store i64 %1, i64* %3
%6 = load i64* %3
%7 = add i64 3, %6
store i64 %7, i64* %2
br label %return
}
define internal i64 @_ZN6double16_e0f64ae76a8e9923_00E({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)*, i64) {
static_allocas:
%2 = alloca i64
%3 = alloca i64
br label %5
return: ; preds = %5
%4 = load i64* %2
ret i64 %4
; <label>:5 ; preds = %static_allocas
store i64 %1, i64* %3
%6 = load i64* %3
%7 = mul i64 2, %6
store i64 %7, i64* %2
br label %return
}
define i64 @meaning_of_life() {
static_allocas:
%0 = alloca i64
%1 = alloca { i64* }
%2 = alloca i64
br label %4
return: ; preds = %4
%3 = load i64* %0
ret i64 %3
; <label>:4 ; preds = %static_allocas
%5 = getelementptr inbounds { i64* }* %1, i32 0, i32 0
store i64* %2, i64** %5
%6 = bitcast { i64* }* %1 to i8*
%7 = call i64 @upcall_call_shim_on_rust_stack(i8* %6, i8* bitcast ({} ({ i64* }*)* @_ZN15meaning_of_life17__rust_stack_shimE to i8*))
%8 = getelementptr inbounds { i64* }* %1, i32 0, i32 0
%9 = load i64** %8
%10 = load i64* %9
store i64 %10, i64* %0
br label %return
}
define internal i64 @_ZN15meaning_of_life10__rust_abiE({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)*) {
static_allocas:
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
br label %6
return: ; preds = %15
%5 = load i64* %1
ret i64 %5
; <label>:6 ; preds = %static_allocas
br label %7
; <label>:7 ; preds = %6
br label %8
; <label>:8 ; preds = %7
store i64 18, i64* %3
%9 = load i64* %3
%10 = call i64 @_ZN9add_three16_e0f64ae76a8e9923_00E({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)* undef, i64 %9)
store i64 %10, i64* %2
br label %11
; <label>:11 ; preds = %8
%12 = load i64* %2
store i64 %12, i64* %4
%13 = load i64* %4
%14 = call i64 @_ZN6double16_e0f64ae76a8e9923_00E({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)* undef, i64 %13)
store i64 %14, i64* %1
br label %15
; <label>:15 ; preds = %11
br label %return
}
define internal {} @_ZN15meaning_of_life17__rust_stack_shimE({ i64* }*) {
static_allocas:
%1 = alloca i64
br label %2
return: ; preds = %2
ret {} zeroinitializer
; <label>:2 ; preds = %static_allocas
%3 = call i64 @_ZN15meaning_of_life10__rust_abiE({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)* null)
%4 = getelementptr inbounds { i64* }* %0, i32 0, i32 0
%5 = load i64** %4
store i64 %3, i64* %5
br label %return
}
define internal {} @_ZN4main17_3941ddf94af05e673_00E({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)*) {
static_allocas:
%1 = alloca {}
br label %3
return: ; preds = %3
%2 = load {}* %1
ret {} %2
; <label>:3 ; preds = %static_allocas
br label %return
}
define {} @_rust_main({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)*) {
static_allocas:
%1 = alloca {}
br label %3
return: ; preds = %3
%2 = load {}* %1
ret {} %2
; <label>:3 ; preds = %static_allocas
%4 = call {} @_ZN4main17_3941ddf94af05e673_00E({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)* %0)
store {} %4, {}* %1
br label %return
}
define i64 @main(i64, i8**) {
top:
%2 = call i64 @_ZN8unstable4lang5start17_80798dc0c0e380dc6_07preE({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)* null, i8* bitcast ({} ({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)*)* @_rust_main to i8*), i64 %0, i8** %1, i8* bitcast ({ i32, i8*, i64, [2 x i64] }* @_rust_crate_map_toplevel to i8*))
ret i64 %2
}
declare i64 @_ZN8unstable4lang5start17_80798dc0c0e380dc6_07preE({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)*, i8*, i64, i8**, i8*)
declare {} @_ZN7cleanup10annihilate17_c17425bfbdabf8296_07preE({ i64, %tydesc*, i8*, i8*, i8 } addrspace(1)*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment