Skip to content

Instantly share code, notes, and snippets.

@Aatch
Last active April 15, 2016 01:00
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 Aatch/5257da7c18fb7a86595080c0851fabd5 to your computer and use it in GitHub Desktop.
Save Aatch/5257da7c18fb7a86595080c0851fabd5 to your computer and use it in GitHub Desktop.
define i32 @foo() unnamed_addr #0 {
entry-block:
%a = alloca i32
%temp0 = alloca {}
%temp3 = alloca {}
br label %start
start: ; preds = %entry-block
store i32 0, i32* %a
br label %bb2
end: ; preds = %bb3
ret i32 %4
bb2: ; preds = %bb4, %start
%0 = load i32, i32* %a
%1 = icmp slt i32 %0, 100
br i1 %1, label %bb4, label %bb3
bb3: ; preds = %bb2
%2 = load i32, i32* %a
%3 = load i32, i32* %a
%4 = mul i32 %2, %3
br label %end
bb4: ; preds = %bb2
%5 = load i32, i32* %a
%6 = add i32 %5, 1
store i32 %6, i32* %a
%7 = load i32, i32* %a
%8 = mul i32 %7, 2
store i32 %8, i32* %a
br label %bb2
}
attributes #0 = { uwtable }
fn foo() -> i32 {
let mut var0: i32; // a in Scope(3) at test.rs:5:9: 5:14
let mut tmp0: ();
let mut tmp1: bool;
let mut tmp2: i32;
let mut tmp3: ();
let mut tmp4: i32;
let mut tmp5: i32;
let mut tmp6: i32;
bb0: {
var0 = const 0i32; // Scope(5) at test.rs:5:17: 5:18
goto -> bb2; // Scope(7) at test.rs:6:5: 10:6
}
bb1: {
return; // Scope(0) at test.rs:4:1: 13:2
}
bb2: {
tmp2 = var0; // Scope(10) at test.rs:6:11: 6:12
tmp1 = Lt(tmp2, const 100i32); // Scope(9) at test.rs:6:11: 6:18
if(tmp1) -> [true: bb4, false: bb3]; // Scope(7) at test.rs:6:5: 10:6
}
bb3: {
tmp0 = (); // Scope(7) at test.rs:6:5: 10:6
tmp5 = var0; // Scope(24) at test.rs:12:5: 12:6
tmp6 = var0; // Scope(25) at test.rs:12:9: 12:10
return = Mul(tmp5, tmp6); // Scope(23) at test.rs:12:5: 12:10
goto -> bb1; // Scope(0) at test.rs:4:1: 13:2
}
bb4: {
var0 = Add(var0, const 1i32); // Scope(14) at test.rs:7:9: 7:15
tmp4 = var0; // Scope(20) at test.rs:9:13: 9:14
var0 = Mul(tmp4, const 2i32); // Scope(18) at test.rs:9:9: 9:18
tmp3 = (); // Scope(12) at test.rs:6:19: 10:6
goto -> bb2; // Scope(7) at test.rs:6:5: 10:6
}
}
define i32 @foo() unnamed_addr #0 {
entry-block:
%a = alloca i32
%temp0 = alloca {}
%temp2 = alloca i32
%temp3 = alloca {}
%temp4 = alloca {}
%temp5 = alloca {}
%temp7 = alloca i32
%temp8 = alloca i32
%temp9 = alloca i32
br label %start
start: ; preds = %entry-block
store i32 0, i32* %a
br label %bb2
end: ; preds = %bb8
ret i32 %12
bb2: ; preds = %bb7, %start
%0 = load i32, i32* %a
store i32 %0, i32* %temp2
%1 = load i32, i32* %temp2
%2 = icmp slt i32 %1, 100
br i1 %2, label %bb4, label %bb3
bb3: ; preds = %bb2
br label %bb8
bb4: ; preds = %bb2
%3 = load i32, i32* %a
%4 = add i32 %3, 1
store i32 %4, i32* %a
br label %bb5
bb5: ; preds = %bb4
%5 = load i32, i32* %a
store i32 %5, i32* %temp7
%6 = load i32, i32* %temp7
%7 = mul i32 %6, 2
br label %bb6
bb6: ; preds = %bb5
store i32 %7, i32* %a
br label %bb7
bb7: ; preds = %bb6
br label %bb2
bb8: ; preds = %bb3
%8 = load i32, i32* %a
store i32 %8, i32* %temp8
%9 = load i32, i32* %a
store i32 %9, i32* %temp9
%10 = load i32, i32* %temp8
%11 = load i32, i32* %temp9
%12 = mul i32 %10, %11
br label %end
}
attributes #0 = { uwtable }
fn foo() -> i32 {
let mut var0: i32; // a
let mut tmp0: ();
let mut tmp1: bool;
let mut tmp2: i32;
let mut tmp3: ();
let mut tmp4: ();
let mut tmp5: ();
let mut tmp6: i32;
let mut tmp7: i32;
let mut tmp8: i32;
let mut tmp9: i32;
bb0: {
var0 = const 0i32; // Scope(5) at test.rs:5:17: 5:18
goto -> bb2; // Scope(7) at test.rs:6:5: 10:6
}
bb1: {
return; // Scope(0) at test.rs:4:1: 13:2
}
bb2: {
tmp2 = var0; // Scope(10) at test.rs:6:11: 6:12
tmp1 = Lt(tmp2, const 100i32); // Scope(9) at test.rs:6:11: 6:18
if(tmp1) -> [true: bb4, false: bb3]; // Scope(7) at test.rs:6:5: 10:6
}
bb3: {
tmp0 = (); // Scope(7) at test.rs:6:5: 10:6
drop(tmp0) -> bb8; // Scope(6) at test.rs:6:5: 10:6
}
bb4: {
var0 = Add(var0, const 1i32); // Scope(14) at test.rs:7:9: 7:15
drop(tmp4) -> bb5; // Scope(13) at test.rs:7:9: 7:15
}
bb5: {
tmp7 = var0; // Scope(20) at test.rs:9:13: 9:14
tmp6 = Mul(tmp7, const 2i32); // Scope(19) at test.rs:9:13: 9:18
drop(var0) -> bb6; // Scope(18) at test.rs:9:9: 9:10
}
bb6: {
var0 = tmp6; // Scope(18) at test.rs:9:9: 9:18
drop(tmp5) -> bb7; // Scope(17) at test.rs:9:9: 9:18
}
bb7: {
tmp3 = (); // Scope(12) at test.rs:6:19: 10:6
goto -> bb2; // Scope(7) at test.rs:6:5: 10:6
}
bb8: {
tmp8 = var0; // Scope(24) at test.rs:12:5: 12:6
tmp9 = var0; // Scope(25) at test.rs:12:9: 12:10
return = Mul(tmp8, tmp9); // Scope(23) at test.rs:12:5: 12:10
goto -> bb1; // Scope(0) at test.rs:4:1: 13:2
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment