Skip to content

Instantly share code, notes, and snippets.

@Aatch
Last active December 25, 2015 13:28
Show Gist options
  • Save Aatch/6983394 to your computer and use it in GitHub Desktop.
Save Aatch/6983394 to your computer and use it in GitHub Desktop.
; ModuleID = 'test.rc'
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-S128"
target triple = "x86_64-unknown-linux-gnu"
%struct.Foo = type { [10 x i64] }
%tydesc = type { i64, i64, void ({}*, i8*)*, void ({}*, i8*)*, void ({}*, i8*)*, void ({}*, i8*)*, i64, { i8*, i64 } }
@_rust_crate_map_toplevel = global { i32, i64, [2 x i64] } { i32 1, i64 ptrtoint ([1 x { i64, i64 }]* @_rust_mod_map to i64), [2 x i64] [i64 ptrtoint (i64* @_rust_crate_map_std_0.9-pre_6c65cf4b443341b1 to i64), i64 0] }
@_rust_crate_map_std_0.9-pre_6c65cf4b443341b1 = external global i64
@_rust_mod_map = internal global [1 x { i64, i64 }] zeroinitializer
@rust_abi_version = constant i64 1
; Function Attrs: noinline nounwind uwtable
define internal fastcc void @_ZN5test119hd4142abcf19795f7an4v0.0E(%struct.Foo* noalias nocapture sret) #0 {
"function top level":
%1 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 0
store i64 1, i64* %1, align 8
%2 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 1
store i64 2, i64* %2, align 8
%3 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 2
store i64 3, i64* %3, align 8
%4 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 3
store i64 4, i64* %4, align 8
%5 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 4
store i64 5, i64* %5, align 8
%6 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 5
store i64 6, i64* %6, align 8
%7 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 6
store i64 7, i64* %7, align 8
%8 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 7
store i64 8, i64* %8, align 8
%9 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 8
store i64 9, i64* %9, align 8
%10 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 9
store i64 0, i64* %10, align 8
ret void
}
; Function Attrs: noinline nounwind uwtable
define internal fastcc void @_ZN5test219hd4142abcf19795f7aD4v0.0E(%struct.Foo* noalias nocapture sret) #0 {
"function top level":
%f.sroa.0.0.idx = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 0
store i64 1, i64* %f.sroa.0.0.idx, align 8
%f.sroa.2.0.idx1 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 1
store i64 2, i64* %f.sroa.2.0.idx1, align 8
%f.sroa.3.0.idx2 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 2
store i64 3, i64* %f.sroa.3.0.idx2, align 8
%f.sroa.4.0.idx3 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 3
store i64 2, i64* %f.sroa.4.0.idx3, align 8
%f.sroa.6.0.idx4 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 4
store i64 5, i64* %f.sroa.6.0.idx4, align 8
%f.sroa.7.0.idx5 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 5
store i64 6, i64* %f.sroa.7.0.idx5, align 8
%f.sroa.8.0.idx6 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 6
store i64 7, i64* %f.sroa.8.0.idx6, align 8
%f.sroa.9.0.idx7 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 7
store i64 8, i64* %f.sroa.9.0.idx7, align 8
%f.sroa.10.0.idx8 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 8
store i64 9, i64* %f.sroa.10.0.idx8, align 8
%f.sroa.11.0.idx9 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 9
store i64 0, i64* %f.sroa.11.0.idx9, align 8
ret void
}
; Function Attrs: nounwind uwtable
define internal void @_ZN4main18hd7d397690bb6180a64v0.0E({ i64, %tydesc*, i8*, i8*, i8 }* nocapture readnone) #1 {
"function top level":
%_1 = alloca %struct.Foo, align 8
%_2 = alloca %struct.Foo, align 8
call fastcc void @_ZN5test119hd4142abcf19795f7an4v0.0E(%struct.Foo* sret %_1)
call fastcc void @_ZN5test219hd4142abcf19795f7aD4v0.0E(%struct.Foo* sret %_2)
ret void
}
define i64 @main(i64, i8**) {
top:
%2 = tail call i64 @"_ZN8unstable4lang5start17hf72eb8b3c3a0a9aa11v0.9$x2dpreE"({ i64, %tydesc*, i8*, i8*, i8 }* null, i8* bitcast (void ({ i64, %tydesc*, i8*, i8*, i8 }*)* @_ZN4main18hd7d397690bb6180a64v0.0E to i8*), i64 %0, i8** %1)
ret i64 %2
}
declare i64 @"_ZN8unstable4lang5start17hf72eb8b3c3a0a9aa11v0.9$x2dpreE"({ i64, %tydesc*, i8*, i8*, i8 }*, i8*, i64, i8**)
attributes #0 = { noinline nounwind uwtable }
attributes #1 = { nounwind uwtable }
struct Foo {
v: [int,..10]
}
#[inline(never)]
fn test1() -> Foo {
Foo {
v: [1,2,3,4,5,6,7,8,9,0]
}
}
#[inline(never)]
fn test2() -> Foo {
let mut f = Foo {
v: [1,2,3,4,5,6,7,8,9,0]
};
f.v[3] = 2;
f
}
fn main() {
let _1 = test1();
let _2 = test2();
}
define void @_ZN5test218h3b288a3d1579e11aD4v0.0E(%struct.Foo* noalias nocapture sret, { i64, %tydesc*, i8*, i8*, i8 }* nocapture readnone, i64) #0 {
"function top level":
%g.sroa.0.sroa.0.0.idx = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 0
store i64 %2, i64* %g.sroa.0.sroa.0.0.idx, align 8
%g.sroa.0.sroa.2.0.idx25 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 1
store i64 2, i64* %g.sroa.0.sroa.2.0.idx25, align 8
%g.sroa.0.sroa.3.0.idx26 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 2
store i64 3, i64* %g.sroa.0.sroa.3.0.idx26, align 8
%g.sroa.2.0.idx7 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 3
store i64 %2, i64* %g.sroa.2.0.idx7, align 8
%g.sroa.3.sroa.0.0.idx = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 4
store i64 5, i64* %g.sroa.3.sroa.0.0.idx, align 8
%g.sroa.3.sroa.2.0.idx20 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 5
store i64 6, i64* %g.sroa.3.sroa.2.0.idx20, align 8
%g.sroa.3.sroa.3.0.idx21 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 6
store i64 7, i64* %g.sroa.3.sroa.3.0.idx21, align 8
%g.sroa.3.sroa.4.0.idx22 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 7
store i64 8, i64* %g.sroa.3.sroa.4.0.idx22, align 8
%g.sroa.3.sroa.5.0.idx23 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 8
store i64 9, i64* %g.sroa.3.sroa.5.0.idx23, align 8
%g.sroa.3.sroa.6.0.idx24 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 0, i64 9
store i64 0, i64* %g.sroa.3.sroa.6.0.idx24, align 8
ret void
}
#[inline(never)]
fn test2(n:uint) -> Foo {
let f = Foo {
v: [n as int ,2,3,4,5,6,7,8,9,0]
};
let mut g = f;
g.v[3] = f.v[0];
return g;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment