[llvm-dev] Integrating llvm pass with pass manager

陳韋任 via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 12 19:40:27 PST 2018


Look back to the SO link [1] you posted, I assume you register your pass by
writing something like below already,

    INITIALIZE_PASS_BEGIN

    ...

    INITIALIZE_PASS_END
    ModulePass *llvm::createYourPass() { return new YourPass(); }

The only suggestion I can give is looking at other existing pass to see
what you might miss. For example, take a look on X86OptimizeLEAs.cpp. It
works like the following ways.

    $ clang -mllvm -disable-x86-lea-opt test.c
    $ opt -disable-x86-lea-opt test.ll

On the other hand, Mem2Reg.cpp fail to be used on clang.

    $ clang -mllvm -mem2reg test.c
    $ clang (LLVM option parsing): Unknown command line argument
'-mem2reg'.  Try: 'clang (LLVM option parsing) -help'

I guess you need to implement the code below for your pass just like
X86OptimizeLEAS.cpp does.

    static cl::opt<bool>
        DisableX86LEAOpt("disable-x86-lea-opt", cl::Hidden,
                         cl::desc("X86: Disable LEA optimizations."),
                         cl::init(false));


​[1] https://stackoverflow.com/questions/29910051/integrating-llvm-passes/
48142693#48142693
<https://www.google.com/url?q=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F29910051%2Fintegrating-llvm-passes%2F48142693%2348142693&sa=D&sntz=1&usg=AFQjCNEKxZuk7ahlWbtZwE0gXezqn29vNA>
​

​HTH,
chenwj​

-- 
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180113/2db0047e/attachment.html>


More information about the llvm-dev mailing list