Skip to content

Commit 7e6c756

Browse files
committed
[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
1 parent 6ee4f25 commit 7e6c756

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2609,6 +2609,7 @@ static void sinkLifetimeStartMarkers(Function &F, coro::Shape &Shape,
26092609
static void collectFrameAllocas(Function &F, coro::Shape &Shape,
26102610
const SuspendCrossingInfo &Checker,
26112611
SmallVectorImpl<AllocaInfo> &Allocas) {
2612+
const DominatorTree DT(F);
26122613
for (Instruction &I : instructions(F)) {
26132614
auto *AI = dyn_cast<AllocaInst>(&I);
26142615
if (!AI)
@@ -2618,7 +2619,6 @@ static void collectFrameAllocas(Function &F, coro::Shape &Shape,
26182619
if (AI == Shape.SwitchLowering.PromiseAlloca) {
26192620
continue;
26202621
}
2621-
DominatorTree DT(F);
26222622
// The code that uses lifetime.start intrinsic does not work for functions
26232623
// with loops without exit. Disable it on ABIs we know to generate such
26242624
// code.

0 commit comments

Comments
 (0)