[LLVMdev] How to call some transformation passes (LoopRotate and LoopUnroll) from my own pass

Raphael Ernani Rodrigues raphael at dcc.ufmg.br
Mon Aug 6 06:27:20 PDT 2012


Hi, Jorge.

When you put these "AU.addRequired<OtherPass>();", you are telling to
the pass manager that your pass will use the other passes.

You can actually call the other passes with get analysis, like this:

LoopInfo &li = getAnalysis<LoopInfo>();

I hope it helps.

Regards,

Raphael Ernani

2012/8/6 Jorge Navas <navas at comp.nus.edu.sg>:
>
> 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
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list