[LLVMdev] How to call some transformation passes (LoopRotate and LoopUnroll) from my own pass
Jorge Navas
navas at comp.nus.edu.sg
Mon Aug 6 06:04:29 PDT 2012
Hello,
I wrote my own pass which needs to do some loop unrolling.
I can perform loop unrolling via opt:
opt -mem2reg -loops -loop-simplify -loop-rotate -lcssa -loop-unroll
-unroll-count=50 mytest.bc -o mytest.bc
This command works perfectly.
However, what I really want is to produce the **same behavior** but
from my own pass (i.e., I don't want to use opt). I wrote a Module
pass which already calls other analysis and transformation passes in
its getAnalysisUsage method:
void MyPass::getAnalysisUsage(AnalysisUsage& AU) const {
AU.addRequired<LoopInfo>();
AU.addPreserved<LoopInfo>();
AU.addRequiredID(LoopSimplifyID);
AU.addPreservedID(LoopSimplifyID);
AU.addRequiredID(LCSSAID);
AU.addPreservedID(LCSSAID);
}
However, I couldn't figure out how to call the LoopRotate and
LoopUnroll passes since I cannot use addRequiredID or addRequired for
these two transformations.
In Scalar.h, I found:
> Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1, int AllowPartial = -1);
> Pass *createLoopRotatePass();
Is to call these methods the way to go? How?, can somebody show me an
excerpt?
P.S. I tried hard on Google but I couldn't find anything related.
Thanks!
Jorge
More information about the llvm-dev
mailing list