[llvm] [Coroutines] Remove one construction of DominatorTree (PR #93507)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 27 23:55:49 PDT 2024
https://github.com/ruiling created https://github.com/llvm/llvm-project/pull/93507
The DominatorTree can be reused if no CFG changes.
>From a31ae9847762d9bfd0d8d73dda7ccaa53d2e6294 Mon Sep 17 00:00:00 2001
From: Ruiling Song <ruiling.song at amd.com>
Date: Tue, 28 May 2024 14:46:38 +0800
Subject: [PATCH] [Coroutines] Remove on construction of DominatorTree
The DominatorTree can be reused if no CFG changes.
---
llvm/lib/Transforms/Coroutines/CoroFrame.cpp | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
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