[PATCH] D20984: add control flags to LICM

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 3 13:12:42 PDT 2016


I swear there was a more generic debug counting proposal a few months ago.


On Fri, Jun 3, 2016 at 1:10 PM, Sebastian Pop <sebpop at gmail.com> wrote:

> sebpop created this revision.
> sebpop added reviewers: dberlin, majnemer.
> sebpop added a subscriber: llvm-commits.
> sebpop set the repository for this revision to rL LLVM.
>
> This patch adds -licm-max-hoist and -licm-max-sink to debug the LICM pass.
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D20984
>
> Files:
>   llvm/lib/Transforms/Scalar/LICM.cpp
>
> Index: llvm/lib/Transforms/Scalar/LICM.cpp
> ===================================================================
> --- llvm/lib/Transforms/Scalar/LICM.cpp
> +++ llvm/lib/Transforms/Scalar/LICM.cpp
> @@ -77,6 +77,16 @@
>  static cl::opt<bool>
>      DisablePromotion("disable-licm-promotion", cl::Hidden,
>                       cl::desc("Disable memory promotion in LICM pass"));
> +static cl::opt<int>
> +    LICMMaxHoist("licm-max-hoist", cl::Hidden, cl::init(-1),
> +                 cl::desc("Max number of instructions to hoist "
> +                          "(default unlimited = -1)"));
> +static cl::opt<int>
> +    LICMMaxSink("licm-max-sink", cl::Hidden, cl::init(-1),
> +                cl::desc("Max number of instructions to sink "
> +                         "(default unlimited = -1)"));
> +static int HoistCtr = 0;
> +static int SinkCtr = 0;
>
>  static bool inSubLoop(BasicBlock *BB, Loop *CurLoop, LoopInfo *LI);
>  static bool isNotUsedInLoop(const Instruction &I, const Loop *CurLoop,
> @@ -628,14 +638,18 @@
>  static bool sink(Instruction &I, const LoopInfo *LI, const DominatorTree
> *DT,
>                   const Loop *CurLoop, AliasSetTracker *CurAST,
>                   const LICMSafetyInfo *SafetyInfo) {
> +  if (LICMMaxSink != -1) {
> +    if (SinkCtr >= LICMMaxSink)
> +      return false;
> +    ++SinkCtr;
> +  }
> +
>    DEBUG(dbgs() << "LICM sinking instruction: " << I << "\n");
> -  bool Changed = false;
>    if (isa<LoadInst>(I))
>      ++NumMovedLoads;
>    else if (isa<CallInst>(I))
>      ++NumMovedCalls;
>    ++NumSunk;
> -  Changed = true;
>
>  #ifndef NDEBUG
>    SmallVector<BasicBlock *, 32> ExitBlocks;
> @@ -688,14 +702,20 @@
>
>    CurAST->deleteValue(&I);
>    I.eraseFromParent();
> -  return Changed;
> +  return true;
>  }
>
> -/// When an instruction is found to only use loop invariant operands that
> -/// is safe to hoist, this instruction is called to do the dirty work.
> +/// When an instruction is found to only use loop invariant operands that
> is
> +/// safe to hoist, this function is called to do the dirty work.
>  ///
>  static bool hoist(Instruction &I, const DominatorTree *DT, const Loop
> *CurLoop,
>                    const LICMSafetyInfo *SafetyInfo) {
> +  if (LICMMaxHoist != -1) {
> +    if (HoistCtr >= LICMMaxHoist)
> +      return false;
> +    ++HoistCtr;
> +  }
> +
>    auto *Preheader = CurLoop->getLoopPreheader();
>    DEBUG(dbgs() << "LICM hoisting to " << Preheader->getName() << ": " << I
>                 << "\n");
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160603/bcb6eb82/attachment.html>


More information about the llvm-commits mailing list