[PATCH] D140818: [NFC][Coroutines] Build DominatorTree only once before collecting frame allocas (PR58650)

Dawid Jurczak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 1 04:27:46 PST 2023


yurai007 created this revision.
yurai007 added reviewers: ChuanqiXu, nikic, xbolva00, momchil.velikov.
Herald added a subscriber: hiraditya.
Herald added a project: All.
yurai007 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Assuming that collecting frame allocas doesn't modify CFG we can safely
move DominatorTree construction outside loop and avoid expensive computations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140818

Files:
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp


Index: llvm/lib/Transforms/Coroutines/CoroFrame.cpp
===================================================================
--- llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -2576,6 +2576,7 @@
 static void collectFrameAllocas(Function &F, coro::Shape &Shape,
                                 const SuspendCrossingInfo &Checker,
                                 SmallVectorImpl<AllocaInfo> &Allocas) {
+  const DominatorTree DT(F);
   for (Instruction &I : instructions(F)) {
     auto *AI = dyn_cast<AllocaInst>(&I);
     if (!AI)
@@ -2585,7 +2586,6 @@
     if (AI == Shape.SwitchLowering.PromiseAlloca) {
       continue;
     }
-    DominatorTree DT(F);
     // The code that uses lifetime.start intrinsic does not work for functions
     // with loops without exit. Disable it on ABIs we know to generate such
     // code.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140818.485802.patch
Type: text/x-patch
Size: 874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230101/ecca522c/attachment.bin>


More information about the llvm-commits mailing list