[llvm-dev] minimal C code that would generate IR code using phi
Tim Northover via llvm-dev
llvm-dev at lists.llvm.org
Fri Jan 25 09:03:41 PST 2019
On Fri, 25 Jan 2019 at 16:55, Peng Yu via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> 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.
Cheers.
Tim.
More information about the llvm-dev
mailing list