Slide 38
Slide 38 text
CODE BLUE 2020
≫ How could this happen?
uint32_t foo()
{
uint32_t V_0 = 0;
goto LBL3;
LBL1:
if (V_0 == 1) {
printf("2\n");
goto LBL2;
}
else
goto LBL3;
LBL2:
printf("3\n");
goto LBL3;
LBL3:
printf("1\n");
V_0 = getNum(); //getNum() {return first_time_called ? 1 : 0;}
if (V_0)
goto LBL1;
else {
printf("4\n");
return V_0;
}
}
An O-LLVM Bug
define i32 @_Z3foov() local_unnamed_addr #1 {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32 0 to i32
store i32 205249092, i32* %1
br label %4
; :4: ; preds = %0, %29
%5 = load i32, i32* %1
switch i32 %5, label %6 [
i32 205249092, label %7
i32 -1124873994, label %10
i32 -1130815655, label %11
i32 -1828373093, label %12
i32 192667987, label %15
i32 -599381087, label %19
i32 -786179519, label %23
i32 2098306815, label %27
]
; :6: ; preds = %4
br label %29
; :7: ; preds = %4
%8 = tail call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]*
@str.5, i64 0, i64 0))
%9 = tail call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]*
@str.6, i64 0, i64 0))
store i32 -1130815655, i32* %1
br label %29
…
}
first non-default bb is
always executed first
LLVM IR
(Flattened by O-LLVM)
38