[llvm] 7e6c756 - [NFC][Coroutines] Build DominatorTree only once before collecting frame allocas (PR58650)

Dawid Jurczak via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 5 01:32:48 PST 2023


Author: Dawid Jurczak
Date: 2023-01-05T10:32:28+01:00
New Revision: 7e6c7562cbfc94368c4af51976649db907ebf0d1

URL: https://github.com/llvm/llvm-project/commit/7e6c7562cbfc94368c4af51976649db907ebf0d1
DIFF: https://github.com/llvm/llvm-project/commit/7e6c7562cbfc94368c4af51976649db907ebf0d1.diff

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

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

Differential Revision: https://reviews.llvm.org/D140818

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 40bf160f119c9..ce350a092c9b1 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -2609,6 +2609,7 @@ static void sinkLifetimeStartMarkers(Function &F, coro::Shape &Shape,
 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)
@@ -2618,7 +2619,6 @@ static void collectFrameAllocas(Function &F, coro::Shape &Shape,
     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.


        


More information about the llvm-commits mailing list