[LLVMdev] Use clang to generate LLVM IR with -O3, how to visit these load operations after -reg2mem

David Blaikie dblaikie at gmail.com
Tue Apr 21 21:11:13 PDT 2015


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
>



More information about the llvm-dev mailing list