Skip to content

Commit

Permalink
[NFC] [Coroutines] Remove EnableReuseStorageInFrame option
Browse files Browse the repository at this point in the history
The EnableReuseStorageInFrame option is designed for testing only.
But it is better to use *_PASS_WITH_PARAMS macro to keep consistent with
other passes.
  • Loading branch information
ChuanqiXu9 committed May 10, 2022
1 parent d222bab commit 02d6845
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 16 deletions.
4 changes: 4 additions & 0 deletions llvm/lib/Passes/PassBuilder.cpp
Expand Up @@ -589,6 +589,10 @@ Expected<bool> parseInlinerPassOptions(StringRef Params) {
return parseSinglePassOption(Params, "only-mandatory", "InlinerPass");
}

Expected<bool> parseCoroSplitPassOptions(StringRef Params) {
return parseSinglePassOption(Params, "reuse-storage", "CoroSplitPass");
}

Expected<bool> parseEarlyCSEPassOptions(StringRef Params) {
return parseSinglePassOption(Params, "memssa", "EarlyCSE");
}
Expand Down
8 changes: 7 additions & 1 deletion llvm/lib/Passes/PassRegistry.def
Expand Up @@ -171,7 +171,6 @@ CGSCC_PASS("invalidate<all>", InvalidateAllAnalysesPass())
CGSCC_PASS("function-attrs", PostOrderFunctionAttrsPass())
CGSCC_PASS("attributor-cgscc", AttributorCGSCCPass())
CGSCC_PASS("openmp-opt-cgscc", OpenMPOptCGSCCPass())
CGSCC_PASS("coro-split", CoroSplitPass())
CGSCC_PASS("no-op-cgscc", NoOpCGSCCPass())
#undef CGSCC_PASS

Expand All @@ -185,6 +184,13 @@ CGSCC_PASS_WITH_PARAMS("inline",
},
parseInlinerPassOptions,
"only-mandatory")
CGSCC_PASS_WITH_PARAMS("coro-split",
"CoroSplitPass",
[](bool OptimizeFrame) {
return CoroSplitPass(OptimizeFrame);
},
parseCoroSplitPassOptions,
"reuse-storage")
#undef CGSCC_PASS_WITH_PARAMS

#ifndef FUNCTION_ANALYSIS
Expand Down
11 changes: 2 additions & 9 deletions llvm/lib/Transforms/Coroutines/CoroFrame.cpp
Expand Up @@ -45,13 +45,6 @@ using namespace llvm;
// "coro-frame", which results in leaner debug spew.
#define DEBUG_TYPE "coro-suspend-crossing"

static cl::opt<bool> EnableReuseStorageInFrame(
"reuse-storage-in-coroutine-frame", cl::Hidden,
cl::desc(
"Enable the optimization which would reuse the storage in the coroutine \
frame for allocas whose liferanges are not overlapped, for testing purposes"),
llvm::cl::init(false));

enum { SmallVectorThreshold = 32 };

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

if (!Shape.OptimizeFrame && !EnableReuseStorageInFrame) {
if (!Shape.OptimizeFrame) {
for (const auto &A : FrameData.Allocas) {
AllocaInst *Alloca = A.Alloca;
NonOverlapedAllocas.emplace_back(AllocaSetType(1, Alloca));
Expand Down Expand Up @@ -2567,7 +2560,7 @@ void coro::salvageDebugInfo(
//
// Avoid to create the alloca would be eliminated by optimization
// passes and the corresponding dbg.declares would be invalid.
if (!OptimizeFrame && !EnableReuseStorageInFrame)
if (!OptimizeFrame)
if (auto *Arg = dyn_cast<llvm::Argument>(Storage)) {
auto &Cached = DbgPtrAllocaCache[Storage];
if (!Cached) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/Coroutines/coro-debug-O2.ll
@@ -1,4 +1,4 @@
; RUN: opt < %s -passes='module(coro-early),cgscc(coro-split,coro-split),function(sroa)' --reuse-storage-in-coroutine-frame -S | FileCheck %s
; RUN: opt < %s -passes='module(coro-early),cgscc(coro-split<reuse-storage>),function(sroa)' -S | FileCheck %s

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

Expand Down
@@ -1,5 +1,5 @@
; Check that we can handle spills of array allocas
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -reuse-storage-in-coroutine-frame -S | FileCheck %s
; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s

%struct.big_structure = type { [500 x i8] }
declare void @consume(%struct.big_structure*)
Expand Down
@@ -1,6 +1,6 @@
; Tests that variables in a Corotuine whose lifetime range is not overlapping each other
; re-use the same slot in Coroutine frame.
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -reuse-storage-in-coroutine-frame -S | FileCheck %s
; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s
%"struct.task::promise_type" = type { i8 }
%struct.awaitable = type { i8 }
%struct.big_structure = type { [500 x i8] }
Expand Down
@@ -1,6 +1,6 @@
; Tests that variables of different type in a Corotuine whose lifetime range is not overlapping each other
; re-use the same slot in Coroutine frame.
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -reuse-storage-in-coroutine-frame -S | FileCheck %s
; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s
%"struct.task::promise_type" = type { i8 }
%struct.awaitable = type { i8 }
%struct.big_structure = type { [500 x i8] }
Expand Down
@@ -1,6 +1,6 @@
; Tests that variables of different type with incompatible alignment in a Corotuine whose lifetime
; range is not overlapping each other should not re-use the same slot in Coroutine frame.
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -reuse-storage-in-coroutine-frame -S | FileCheck %s
; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s
%"struct.task::promise_type" = type { i8 }
%struct.awaitable = type { i8 }
%struct.big_structure = type { [500 x i8] }
Expand Down
@@ -1,6 +1,6 @@
; Tests that variables of different type with incompatible alignment in a Corotuine whose
; lifetime range is not overlapping each other re-use the same slot in CorotuineFrame.
; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -reuse-storage-in-coroutine-frame -S | FileCheck %s
; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s
%"struct.task::promise_type" = type { i8 }
%struct.awaitable = type { i8 }
%struct.big_structure = type { [500 x i8] }
Expand Down

0 comments on commit 02d6845

Please sign in to comment.