Hi Susan,<div><br></div><div>The meaning of "addRequired(X)" is that your pass needs X to be run, and for X to be preserved by all passes that run after X and before your pass. The PHIElemination and TwoAddressInstruction passes do not preserve each other, hence there's no way for the pass manager to schedule them for you if you addRequire(...) them.</div>
<div><br></div><div>The trick is that CodeGen will schedule both of these passes to be run before _any_ register allocation pass (see Passes.cpp), so you needn't require them explicitly - you can just assume they have been run. If you just remove those lines from your getAnalysisUsage method your pass should now run as you expect.</div>
<div><br></div><div>Cheers,</div><div>Lang. <br><br><div class="gmail_quote">On Wed, Oct 31, 2012 at 1:46 PM, Susan Horwitz <span dir="ltr"><<a href="mailto:horwitz@cs.wisc.edu" target="_blank">horwitz@cs.wisc.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm trying to write a MachineFunctionPass to do register allocation.  I have code that worked with an old version of LLVM.  It does not work with llvm-3.1. (or various other versions that I've tried).<br>

<br>
The first problem is that including this line:<br>
<br>
 AU.addRequiredID(<u></u>TwoAddressInstructionPassID);<br>
<br>
in method getAnalysisUsage causes a runtime error:<br>
<br>
Unable to schedule 'Eliminate PHI nodes for register allocation' required by 'Unnamed pass: implement Pass::getPassName()'<br>
Unable to schedule pass<br>
UNREACHABLE executed at ...<br>
<br>
I'm invoking the pass like this (given input file foo.c):<br>
<br>
clang -emit-llvm -O0 -c foo.c -o foo.bc<br>
opt -mem2reg foo.bc > foo.ssa<br>
mv foo.ssa foo.bc<br>
llc -load Debug/lib/P4.so -regalloc=gc foo.bc<br>
<br>
<br>
I've attached my entire file (it's very short).  Any help would be much appreciated!<span class="HOEnZb"><font color="#888888"><br>
<br>
Susan Horwitz<br>
</font></span><br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>