[llvm] f0b57b6 - [Coroutines] Remove one construction of DominatorTree (#93507)
via llvm-commits
llvm-commits at lists.llvm.org
Tue May 28 17:58:22 PDT 2024
Author: Ruiling, Song
Date: 2024-05-29T08:58:19+08:00
New Revision: f0b57b60e3b47bb9f9181d8be68473706b883430
URL: https://github.com/llvm/llvm-project/commit/f0b57b60e3b47bb9f9181d8be68473706b883430
DIFF: https://github.com/llvm/llvm-project/commit/f0b57b60e3b47bb9f9181d8be68473706b883430.diff
LOG: [Coroutines] Remove one construction of DominatorTree (#93507)
The DominatorTree can be reused if no CFG changes.
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 38b8dab984db3..8e829a53aeca2 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -2756,12 +2756,11 @@ static void sinkSpillUsesAfterCoroBegin(Function &F,
/// after the suspend block. Doing so minimizes the lifetime of each variable,
/// hence minimizing the amount of data we end up putting on the frame.
static void sinkLifetimeStartMarkers(Function &F, coro::Shape &Shape,
- SuspendCrossingInfo &Checker) {
+ SuspendCrossingInfo &Checker,
+ const DominatorTree &DT) {
if (F.hasOptNone())
return;
- DominatorTree DT(F);
-
// Collect all possible basic blocks which may dominate all uses of allocas.
SmallPtrSet<BasicBlock *, 4> DomSet;
DomSet.insert(&F.getEntryBlock());
@@ -3149,12 +3148,13 @@ void coro::buildCoroutineFrame(
doRematerializations(F, Checker, MaterializableCallback);
+ const DominatorTree DT(F);
FrameDataInfo FrameData;
SmallVector<CoroAllocaAllocInst*, 4> LocalAllocas;
SmallVector<Instruction*, 4> DeadInstructions;
if (Shape.ABI != coro::ABI::Async && Shape.ABI != coro::ABI::Retcon &&
Shape.ABI != coro::ABI::RetconOnce)
- sinkLifetimeStartMarkers(F, Shape, Checker);
+ sinkLifetimeStartMarkers(F, Shape, Checker, DT);
// Collect the spills for arguments and other not-materializable values.
for (Argument &A : F.args())
@@ -3162,7 +3162,6 @@ void coro::buildCoroutineFrame(
if (Checker.isDefinitionAcrossSuspend(A, U))
FrameData.Spills[&A].push_back(cast<Instruction>(U));
- const DominatorTree DT(F);
for (Instruction &I : instructions(F)) {
// Values returned from coroutine structure intrinsics should not be part
// of the Coroutine Frame.
More information about the llvm-commits
mailing list