<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Look back to the SO link [1] you posted, I assume you register your pass by writing something like below already,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> INITIALIZE_PASS_BEGIN</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> ...</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> INITIALIZE_PASS_END</div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> ModulePass *llvm::createYourPass() { return new YourPass(); }</font><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">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.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> $ clang -mllvm -disable-x86-lea-opt test.c</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> $ opt -disable-x86-lea-opt test.ll</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">On the other hand, Mem2Reg.cpp fail to be used on clang.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><div class="gmail_default"> $ clang -mllvm -mem2reg test.c</div><div class="gmail_default"> $ clang (LLVM option parsing): Unknown command line argument '-mem2reg'. Try: 'clang (LLVM option parsing) -help'</div><div class="gmail_default"><br></div><div class="gmail_default">I guess you need to implement the code below for your pass just like X86OptimizeLEAS.cpp does.</div><div class="gmail_default"><br></div><div class="gmail_default"><div class="gmail_default"> static cl::opt<bool></div><div class="gmail_default"> DisableX86LEAOpt("disable-x86-lea-opt", cl::Hidden,</div><div class="gmail_default"> cl::desc("X86: Disable LEA optimizations."),</div><div class="gmail_default"> cl::init(false));</div></div></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_extra"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">[1] <a href="https://www.google.com/url?q=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F29910051%2Fintegrating-llvm-passes%2F48142693%2348142693&sa=D&sntz=1&usg=AFQjCNEKxZuk7ahlWbtZwE0gXezqn29vNA" target="_blank" rel="nofollow" style="margin:0px;padding:0px;border:0px;text-decoration-line:none;color:rgb(102,17,204);font-family:Arial,Helvetica,sans-serif;font-size:14px">https://stackoverflow.com/<wbr>questions/29910051/<wbr>integrating-llvm-passes/<wbr>48142693#48142693</a></div><br clear="all"><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">HTH,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">chenwj</div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Wei-Ren Chen (陳韋任)<br>Homepage: <a href="https://people.cs.nctu.edu.tw/~chenwj" target="_blank">https://people.cs.nctu.edu.tw/~chenwj</a></div></div></div>
</div></div>