For the following code in C:
void test(int a, int b, int c){
if(a > 1 && (b == 2 || c == 3))
b = a + c;
else
c = a + b;
return;
}
The CFG is as following:
But when I change the if on line 2 to while:
void test(int a, int b, int c){
while(a > 1 && (b == 2 || c == 3))
b = a + c;
c = a + b;
return;
}
Then the CFG is changed to:
So the basic block lor.end and land.end are generated, but they are not corresponding to any statement in the program. Why does while.cond not connects to while.end directly just like entry -> if.else in the first CFG? In other words, why are lor.end and land.end generated? It seems that the way of handling short circuits in if statements are different from that in loop statements. What causes this difference?
compiling script(calng/llvm 7.0.1): clang -emit-llvm -c -g -fno-discard-value-names file_name.c