<div dir="ltr">Hi Skye, I don't know exactly which pass / combination of passes do it, but I went through something similar with some success.  What I did was copy the body of lib/Transforms/IPO/PassManagerBuilder.cpp::populateModulePassManager() which is what I believe sets up the "standard" passes for opt.  That function adds the passes to a module passmanager, but it looks like almost all of the passes it adds are FunctionPass's, and I was able to add all those passes to my FunctionPassManager.  I wasn't focusing on loop unrolling but I just checked and this setup does unroll loops; if you want to find the minimal set maybe you could do something similar and then whittle down?<div>

<br></div><div>My understanding (I don't know the pass manager infrastructure too well) is that the "larger" pass managers automatically create sub-managers, ie the module passmanager will create a function passmanager to run on all the functions, and I assume that the function passmanager will create a loop passmanager to run on the loops.  But again, I haven't traced through it that much so someone else might have to correct me.</div>

<div><br></div><div style>Kevin</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 15, 2014 at 2:18 PM, Skye Wanderman-Milne <span dir="ltr"><<a href="mailto:skye@cloudera.com" target="_blank">skye@cloudera.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The loop rotation pass does modify the function, which I'm guessing means that a FunctionPassManager can be used to run LoopPasses (this is not obvious to me after looking through the FunctionPassManager code). Unfortunately none of the other passes I'm using (ScalarEvolution, LCSSA, IndVarSimplify, and LoopUnroll) appear to have an effect.<div>



<br></div><div>I verified that the function can be loop unrolled by opt, so I'm currently using opt to narrow down which passes are required to get this result. Once I figure that out I'll see if I can get a FunctionPassManager to run those passes over just the function. I am open to other suggestions though :)</div>

<span class="HOEnZb"><font color="#888888">

<div><br></div><div>Skye</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 14, 2014 at 10:22 PM, Owen Anderson <span dir="ltr"><<a href="mailto:resistor@mac.com" target="_blank">resistor@mac.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>Hi Skye,</div><div><br></div><div>If I remember correctly, our loop unrolling pass requires loop rotation in order to be very effective.  Can you try adding that before you run the unroller to see if it helps?</div>



<div><br></div><div>--Owen</div><div><div><div><br>On Jan 14, 2014, at 09:32 PM, Skye Wanderman-Milne <<a href="mailto:skye@cloudera.com" target="_blank">skye@cloudera.com</a>> wrote:<br><br></div></div>
</div>
<div><blockquote type="cite"><div><div><div><div dir="ltr">Hi all,<div><br></div><div>I'm attempting to perform loop unrolling on a single function using the C++ API. Maybe I missed something in the docs, but I cannot figure out a way to do this. The function I'm working with is very simple, containing a single for loop and not much else. I compiled the function to IR using clang with no optimizations enabled.</div>



<div><br></div><div>My initial plan was to first run the IndVarSimplify pass (as suggested <a href="http://llvm.org/docs/Passes.html#loop-unroll-unroll-loops" target="_blank">here</a>) and then the LoopUnroll pass on the function. I tried using a FunctionPassManager to do this, even though the docs state FPMs are used with FunctionPasses and not LoopPasses, which didn't complain but had no effect on the function. Is adding LoopPasses to a FPM supposed to be a no-op? Is this supposed to work and I'm not running the right combination of passes to get loop unrolling?</div>



<div><br></div><div>I also tried creating a LoopInfo object over my function with a FPM so I could call UnrollLoop() manually, but the LoopInfo didn't return any loops, perhaps because I'm missing some preliminary passes.</div>



<div><br></div><div>The last option I considered was copying the function into it's own module, using a PassManager, and then copying the function back into the original module. I didn't try this option as creating a valid stand-alone module with the single function will potentially be difficult.</div>



<div><br></div><div>Does anyone have a suggestion for how to do this?</div><div><br></div><div>Thanks,<br></div><div>Skye</div></div></div></div><div>_______________________________________________<br> LLVM Developers mailing list<br>



 <a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">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>



</div></div></blockquote></div></div></blockquote></div><br></div>
</div></div><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>