Hi all, I'm reading the language reference of LLVM here: http://llvm.org/docs/LangRef.html#i_getelementptr In the first example, it shows that the generated IR is supposed to be something like: %reg = getelementptr %ST* %s, i32 1, i32 2, i32 1, i32 5, i32 13 But when I copied the code and compile it myself (using v2.7), I got five getelementptr instructions, which are just like the equivalent code given later in the document. In the case above, why the resulting IRs are different? Thanks a lot.Regards,--Wenbin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100722/e03b22aa/attachment.html>
2010/7/21 Wenbin Zhang <zhangwen at cse.ohio-state.edu>:> Hi all, > I'm reading the language reference of LLVM here: > http://llvm.org/docs/LangRef.html#i_getelementptr > > In the first example, it shows that the generated IR is supposed to be > something like: > > %reg = getelementptr %ST* %s, i32 1, i32 2, i32 1, i32 5, i32 13 > > But when I copied the code and compile it myself (using v2.7), I got five > getelementptr instructions, which are just like the equivalent code given > later in the document. > > In the case above, why the resulting IRs are different? > > Thanks a lot.Just a quirk of frontend code generation; you'll get the shown result with -O. -Eli
Christoph Erhardt
2010-Jul-22 07:13 UTC
[LLVMdev] the generation of getelementptr instruction
Hi Wenbin,> I'm reading the language reference of LLVM here: > http://llvm.org/docs/LangRef.html#i_getelementptr > > In the first example, it shows that the generated IR is supposed to be > something like: > %reg = getelementptr %ST* %s, i32 1, i32 2, i32 1, i32 5, i32 13 > But when I copied the code and compile it myself (using v2.7), I got > five getelementptr instructions, which are just like the equivalent > code given later in the document. In the case above, why the > resulting IRs are different?if you enable optimizations in the frontend (-O1), the resulting LLVM code will look just as shown in the example. Regards, Christoph
Maybe Matching Threads
- [LLVMdev] a problem when using postDominatorTree
- [LLVMdev] how to check whether from basicblock A we can go to basicblock B within the same function?
- [LLVMdev] a problem when using postDominatorTree
- [LLVMdev] Can we map a instruction in IR back to source code?
- [LLVMdev] a problem when using postDominatorTree