Eric Lu
2015-Apr-22 03:34 UTC
[LLVMdev] Use clang to generate LLVM IR with -O3, how to visit these load operations after -reg2mem
Hi, all I want to instrument load/store operations in LLVM IR. And I find the LLVM IR generated with flag -o3 is much more efficient than -o0, so I try to instrument on these optimized LLVM IR, but, some load operations are changed to Phi loads. Then, I try the -reg2mem flag to remove these phi nodes. The problems are: 1) I use visitLoadInst to collect these load operations, and it seems I cannot reach these loads that are generated by reg2mem? What is the reason? 2) Is there any way to compile with -O3 but not generate phi nodes ? -- Best Regards! Eric Lew -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150422/b5c8e2d1/attachment.html>
David Blaikie
2015-Apr-22 04:11 UTC
[LLVMdev] Use clang to generate LLVM IR with -O3, how to visit these load operations after -reg2mem
On Tue, Apr 21, 2015 at 8:34 PM, Eric Lu <eirc.lew at gmail.com> wrote:> Hi, all > > I want to instrument load/store operations in LLVM IR. And I find the LLVM > IR generated with flag -o3 is much more efficient than -o0, so I try to > instrument on these optimized LLVM IR, but, some load operations are changed > to Phi loads. Then, I try the -reg2mem flag to remove these phi nodes. > The problems are: > 1) I use visitLoadInst to collect these load operations, and it seems I > cannot reach these loads that are generated by reg2mem? What is the reason?Clang doesn't generate optimized IR - so if your instrumentation is in Clang's IRGen (clang/lib/CodeGen) it won't see these. Clang generates the unoptimized IR (you can see it with -Xclang -disable-llvm-optzns)> 2) Is there any way to compile with -O3 but not generate phi nodes ?Not likely - without that it'd disable a lot of LLVM's optimization power. - David> > > -- > Best Regards! > Eric Lew > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Eric Lu
2015-Apr-22 04:29 UTC
[LLVMdev] Use clang to generate LLVM IR with -O3, how to visit these load operations after -reg2mem
Best Regards! Eric Lew On 周三, 4月 22, 2015 at 12:11 下午, David Blaikie < dblaikie at gmail.com [dblaikie at gmail.com] > wrote: On Tue, Apr 21, 2015 at 8:34 PM, Eric Lu <eirc.lew at gmail.com> wrote:> Hi, all > > I want to instrument load/store operations in LLVM IR. And I find the LLVM > IR generated with flag -o3 is much more efficient than -o0, so I try to > instrument on these optimized LLVM IR, but, some load operations are changed > to Phi loads. Then, I try the -reg2mem flag to remove these phi nodes. > The problems are: > 1) I use visitLoadInst to collect these load operations, and it seems I > cannot reach these loads that are generated by reg2mem? What is the reason?Clang doesn't generate optimized IR - so if your instrumentation is in Clang's IRGen (clang/lib/CodeGen) it won't see these. Clang generates the unoptimized IR (you can see it with -Xclang -disable-llvm-optzns) I do instrumentation in the opt of llvm. Does clang itself do some optimizations that speed up applications with -O3 compared to -O0?> 2) Is there any way to compile with -O3 but not generate phi nodes ?Not likely - without that it'd disable a lot of LLVM's optimization power. - David> > > -- > Best Regards! > Eric Lew > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150422/3a3c2849/attachment.html>
Reasonably Related Threads
- [LLVMdev] Use clang to generate LLVM IR with -O3, how to visit these load operations after -reg2mem
- [LLVMdev] what is the Line number of Phi Node with addr2line
- [LLVMdev] what is the Line number of Phi Node with addr2line
- [LLVMdev] what is the Line number of Phi Node with addr2line
- [LLVMdev] How to recognize the declaring code scopes of stack variables