Hi, I am interested in SSA and read llvm uses SSA in its ir. I decided to write a simple program and compile it with llvm to the human readable assembly language representation of the ir. I expected phi nodes all over the place. However, I could not find a single one! Could you tell my why that is so? I compiled with "llvm-gcc -emit-llvm test.c -S -o test.ll". Attached to this message are the source and the resulting ll output. Thanks in advance, Maarten Faddegon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100910/e9f65c23/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: test.c Type: text/x-csrc Size: 143 bytes Desc: test.c URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100910/e9f65c23/attachment.c> -------------- next part -------------- A non-text attachment was scrubbed... Name: test.ll Type: application/octet-stream Size: 2702 bytes Desc: test.ll URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100910/e9f65c23/attachment.obj>
They have been converted into stores. If you want PHI nodes to appear, try running the "mem2reg" pass with "opt -mem2reg test.ll -S". On Fri, 2010-09-10 at 13:27 +0200, Maarten Faddegon wrote:> Hi, > > I am interested in SSA and read llvm uses SSA in its ir. I decided to > write a simple program and compile it with llvm to the human readable > assembly language representation of the ir. I expected phi nodes all > over the place. However, I could not find a single one! Could you tell > my why that is so? > > I compiled with "llvm-gcc -emit-llvm test.c -S -o test.ll". Attached > to this message are the source and the resulting ll output. > > Thanks in advance, > > Maarten Faddegon > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Hi Maarten,> I compiled with "llvm-gcc -emit-llvm test.c -S -o test.ll". Attached to this > message are the source and the resulting ll output.compile with optimization. The llvm-gcc front-end "cheats" and stores/loads all values to/from memory, avoiding the need to construct phi nodes; instead it lets the optimizers do that. For what it's worth the dragonegg plugin produces phi nodes directly, even at -O0. I don't know what clang does. Ciao, Duncan.
On Sep 13, 2010, at 1:15 AM, Duncan Sands wrote:>> I compiled with "llvm-gcc -emit-llvm test.c -S -o test.ll". Attached to this >> message are the source and the resulting ll output. > > compile with optimization. The llvm-gcc front-end "cheats" and stores/loads all > values to/from memory, avoiding the need to construct phi nodes; instead it lets > the optimizers do that. For what it's worth the dragonegg plugin produces phi > nodes directly, even at -O0. I don't know what clang does.If you're talking about variables, clang emits stores and loads, of course. C/C++ variables specify their semantics in terms of objects in memory; SSA conversion is an optimization which does break (obviously invalid) programs. Any attempt by the frontend to emit variables in true SSA form is just duplicating this optimization — in the case of dragonegg, because the SSA conversion is implicit in how gcc creates the IR it lowers from. John.