Skip to content

Commit 02d6845

Browse files
committed
[NFC] [Coroutines] Remove EnableReuseStorageInFrame option
The EnableReuseStorageInFrame option is designed for testing only. But it is better to use *_PASS_WITH_PARAMS macro to keep consistent with other passes.
1 parent d222bab commit 02d6845

File tree

9 files changed

+19
-16
lines changed

9 files changed

+19
-16
lines changed

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,10 @@ Expected<bool> parseInlinerPassOptions(StringRef Params) {
589589
return parseSinglePassOption(Params, "only-mandatory", "InlinerPass");
590590
}
591591

592+
Expected<bool> parseCoroSplitPassOptions(StringRef Params) {
593+
return parseSinglePassOption(Params, "reuse-storage", "CoroSplitPass");
594+
}
595+
592596
Expected<bool> parseEarlyCSEPassOptions(StringRef Params) {
593597
return parseSinglePassOption(Params, "memssa", "EarlyCSE");
594598
}

llvm/lib/Passes/PassRegistry.def

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ CGSCC_PASS("invalidate<all>", InvalidateAllAnalysesPass())
171171
CGSCC_PASS("function-attrs", PostOrderFunctionAttrsPass())
172172
CGSCC_PASS("attributor-cgscc", AttributorCGSCCPass())
173173
CGSCC_PASS("openmp-opt-cgscc", OpenMPOptCGSCCPass())
174-
CGSCC_PASS("coro-split", CoroSplitPass())
175174
CGSCC_PASS("no-op-cgscc", NoOpCGSCCPass())
176175
#undef CGSCC_PASS
177176

@@ -185,6 +184,13 @@ CGSCC_PASS_WITH_PARAMS("inline",
185184
},
186185
parseInlinerPassOptions,
187186
"only-mandatory")
187+
CGSCC_PASS_WITH_PARAMS("coro-split",
188+
"CoroSplitPass",
189+
[](bool OptimizeFrame) {
190+
return CoroSplitPass(OptimizeFrame);
191+
},
192+
parseCoroSplitPassOptions,
193+
"reuse-storage")
188194
#undef CGSCC_PASS_WITH_PARAMS
189195

190196
#ifndef FUNCTION_ANALYSIS

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,6 @@ using namespace llvm;
4545
// "coro-frame", which results in leaner debug spew.
4646
#define DEBUG_TYPE "coro-suspend-crossing"
4747

48-
static cl::opt<bool> EnableReuseStorageInFrame(
49-
"reuse-storage-in-coroutine-frame", cl::Hidden,
50-
cl::desc(
51-
"Enable the optimization which would reuse the storage in the coroutine \
52-
frame for allocas whose liferanges are not overlapped, for testing purposes"),
53-
llvm::cl::init(false));
54-
5548
enum { SmallVectorThreshold = 32 };
5649

5750
// Provides two way mapping between the blocks and numbers.
@@ -589,7 +582,7 @@ void FrameTypeBuilder::addFieldForAllocas(const Function &F,
589582
}
590583
});
591584

592-
if (!Shape.OptimizeFrame && !EnableReuseStorageInFrame) {
585+
if (!Shape.OptimizeFrame) {
593586
for (const auto &A : FrameData.Allocas) {
594587
AllocaInst *Alloca = A.Alloca;
595588
NonOverlapedAllocas.emplace_back(AllocaSetType(1, Alloca));
@@ -2567,7 +2560,7 @@ void coro::salvageDebugInfo(
25672560
//
25682561
// Avoid to create the alloca would be eliminated by optimization
25692562
// passes and the corresponding dbg.declares would be invalid.
2570-
if (!OptimizeFrame && !EnableReuseStorageInFrame)
2563+
if (!OptimizeFrame)
25712564
if (auto *Arg = dyn_cast<llvm::Argument>(Storage)) {
25722565
auto &Cached = DbgPtrAllocaCache[Storage];
25732566
if (!Cached) {

llvm/test/Transforms/Coroutines/coro-debug-O2.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt < %s -passes='module(coro-early),cgscc(coro-split,coro-split),function(sroa)' --reuse-storage-in-coroutine-frame -S | FileCheck %s
1+
; RUN: opt < %s -passes='module(coro-early),cgscc(coro-split<reuse-storage>),function(sroa)' -S | FileCheck %s
22

33
; Checks whether the dbg.declare for `__promise` remains valid under O2.
44

llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-00.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; Check that we can handle spills of array allocas
2-
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -reuse-storage-in-coroutine-frame -S | FileCheck %s
2+
; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s
33

44
%struct.big_structure = type { [500 x i8] }
55
declare void @consume(%struct.big_structure*)

llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-01.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; Tests that variables in a Corotuine whose lifetime range is not overlapping each other
22
; re-use the same slot in Coroutine frame.
3-
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -reuse-storage-in-coroutine-frame -S | FileCheck %s
3+
; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s
44
%"struct.task::promise_type" = type { i8 }
55
%struct.awaitable = type { i8 }
66
%struct.big_structure = type { [500 x i8] }

llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-02.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; Tests that variables of different type in a Corotuine whose lifetime range is not overlapping each other
22
; re-use the same slot in Coroutine frame.
3-
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -reuse-storage-in-coroutine-frame -S | FileCheck %s
3+
; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s
44
%"struct.task::promise_type" = type { i8 }
55
%struct.awaitable = type { i8 }
66
%struct.big_structure = type { [500 x i8] }

llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-04.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; Tests that variables of different type with incompatible alignment in a Corotuine whose lifetime
22
; range is not overlapping each other should not re-use the same slot in Coroutine frame.
3-
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -reuse-storage-in-coroutine-frame -S | FileCheck %s
3+
; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s
44
%"struct.task::promise_type" = type { i8 }
55
%struct.awaitable = type { i8 }
66
%struct.big_structure = type { [500 x i8] }

llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-05.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; Tests that variables of different type with incompatible alignment in a Corotuine whose
22
; lifetime range is not overlapping each other re-use the same slot in CorotuineFrame.
3-
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -reuse-storage-in-coroutine-frame -S | FileCheck %s
3+
; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s
44
%"struct.task::promise_type" = type { i8 }
55
%struct.awaitable = type { i8 }
66
%struct.big_structure = type { [500 x i8] }

0 commit comments

Comments
 (0)