YSU_Student

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
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.

how can I do it ?

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.

You will need to run these two transform passes before your pass is run. If you're running your pass via opt, then simply tell opt to explicitly run them before running your pass. If you're building your own tool that creates a PassManager object and adds passes to it, then add these passes to the PassManager object before you add your own pass.

-- John T.