But when I tried to create a minimal code using if-else with
unbalanced statements to change a variable in C, it still did not
generate IR code using phi.
Does anybody have a minimal C code that would generate IR code using
phi? Thanks.
Clang never really generates phis itself because it's easier to
generate code that simply uses a stack variable (you don't have to
keep track of control flow). The Mem2Reg pass in LLVM is what converts
Clang's output into a form with phis.
If you run Clang at an optimization above -O0 (e.g. "clang -O1 -Xclang
-disable-llvm-passes -emit-llvm ...") then run "opt -mem2reg" manually
you'll closest to what Clang would have emitted if it did do phis.