[PATCH] D49982: [TailCallElim] Preserve DT and PDT

Chijun Sima via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 30 06:09:56 PDT 2018


NutshellySima created this revision.
NutshellySima added reviewers: kuhar, dmgreen, brzycki, grosser, davide.
Herald added a subscriber: llvm-commits.

Previously, in the NewPM pipeline, TailCallElim recalculates the DomTree when it modifies any instruction in the Function.
For example,

  CallInst *CI = dyn_cast<CallInst>(&I);
  ...
  CI->setTailCall();
  Modified = true;
  ...
  if (!Modified || ...)
    return PreservedAnalyses::all();

After applying this patch, the DomTree only recalculates if needed (plus an extra insertEdge() + an extra deleteEdge() call).

When optimizing SQLite with `-passes="default<O3>"` pipeline of the newPM, the number of DomTree recalculation decreases by 6.2%, the number of nodes visited by DFS decreases by 2.9%. The time used by DomTree will decrease approximately 1%~2.5% after applying the patch.

Statistics:

  Before the patch:
   23010 dom-tree-stats               - Number of DomTree recalculations
  489264 dom-tree-stats               - Number of nodes visited by DFS -- DomTree
  After the patch:
   21581 dom-tree-stats               - Number of DomTree recalculations
  475088 dom-tree-stats               - Number of nodes visited by DFS -- DomTree


Repository:
  rL LLVM

https://reviews.llvm.org/D49982

Files:
  include/llvm/Transforms/Utils/BasicBlockUtils.h
  lib/Transforms/Scalar/TailRecursionElimination.cpp
  lib/Transforms/Utils/BasicBlockUtils.cpp
  test/Transforms/TailCallElim/2010-06-26-MultipleReturnValues.ll
  test/Transforms/TailCallElim/EraseBB.ll
  test/Transforms/TailCallElim/accum_recursion.ll
  test/Transforms/TailCallElim/ackermann.ll
  test/Transforms/TailCallElim/basic.ll
  test/Transforms/TailCallElim/deopt-bundle.ll
  test/Transforms/TailCallElim/dont_reorder_load.ll
  test/Transforms/TailCallElim/dup_tail.ll
  test/Transforms/TailCallElim/inf-recursion.ll
  test/Transforms/TailCallElim/notail.ll
  test/Transforms/TailCallElim/opt-remarks-recursion.ll
  test/Transforms/TailCallElim/reorder_load.ll
  test/Transforms/TailCallElim/setjmp.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49982.157951.patch
Type: text/x-patch
Size: 16590 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180730/7d015c99/attachment.bin>


More information about the llvm-commits mailing list