-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Below is the test example I use,
int a(){
return 1;
}
int b(){
return 2;
}
int main(){
int x = 1;
int y = x==2 ? a() : b();
return y;
}The llvm IL of the test example:
; ModuleID = '/Users/jackxia/Project/IBM/lljb/test/cpp/ternary.cpp'
source_filename = "/Users/jackxia/Project/IBM/lljb/test/cpp/ternary.cpp"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.14.0"
; Function Attrs: noinline nounwind optnone ssp uwtable
define i32 @_Z1av() #0 {
ret i32 1
}
; Function Attrs: noinline nounwind optnone ssp uwtable
define i32 @_Z1bv() #0 {
ret i32 2
}
; Function Attrs: noinline norecurse nounwind optnone ssp uwtable
define i32 @main() #1 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
%3 = alloca i32, align 4
store i32 0, i32* %1, align 4
store i32 1, i32* %2, align 4
%4 = load i32, i32* %2, align 4
%5 = icmp eq i32 %4, 2
br i1 %5, label %6, label %8
; <label>:6: ; preds = %0
%7 = call i32 @_Z1av()
br label %10
; <label>:8: ; preds = %0
%9 = call i32 @_Z1bv()
br label %10
; <label>:10: ; preds = %8, %6
%11 = phi i32 [ %7, %6 ], [ %9, %8 ]
store i32 %11, i32* %3, align 4
%12 = load i32, i32* %3, align 4
ret i32 %12
}
attributes #0 = { noinline nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { noinline norecurse nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.module.flags = !{!0, !1}
!llvm.ident = !{!2}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{!"Apple LLVM version 10.0.1 (clang-1001.0.46.4)"}
Metadata
Metadata
Assignees
Labels
No labels