Skip to content

Commit 371c242

Browse files
committed
[NFC] OwnedValueCan: Typed maximizeLifetime.
1 parent 431fb27 commit 371c242

File tree

6 files changed

+13
-7
lines changed

6 files changed

+13
-7
lines changed

include/swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ enum PruneDebugInsts_t : bool {
185185
PruneDebugInsts = true,
186186
};
187187

188+
enum MaximizeLifetime_t : bool {
189+
DontMaximizeLifetime = false,
190+
MaximizeLifetime = true,
191+
};
192+
188193
/// Canonicalize OSSA lifetimes.
189194
///
190195
/// Allows the allocation of analysis state to be reused across calls to
@@ -230,7 +235,7 @@ class CanonicalizeOSSALifetime final {
230235

231236
/// If true, lifetimes will not be shortened except when necessary to avoid
232237
/// copies.
233-
bool maximizeLifetime;
238+
const MaximizeLifetime_t maximizeLifetime;
234239

235240
// If present, will be used to ensure that the lifetime is not shortened to
236241
// end inside an access scope which it previously enclosed. (Note that ending
@@ -318,7 +323,8 @@ class CanonicalizeOSSALifetime final {
318323
};
319324

320325
CanonicalizeOSSALifetime(PruneDebugInsts_t pruneDebugMode,
321-
bool maximizeLifetime, SILFunction *function,
326+
MaximizeLifetime_t maximizeLifetime,
327+
SILFunction *function,
322328
NonLocalAccessBlockAnalysis *accessBlockAnalysis,
323329
DominanceInfo *domTree,
324330
BasicCalleeAnalysis *calleeAnalysis,

lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct OSSACanonicalizer {
4949
OSSACanonicalizer(SILFunction *fn, DominanceInfo *domTree,
5050
InstructionDeleter &deleter)
5151
: canonicalizer(DontPruneDebugInsts,
52-
!fn->shouldOptimize() /*maximizeLifetime*/, fn,
52+
MaximizeLifetime_t(!fn->shouldOptimize()), fn,
5353
nullptr /*accessBlockAnalysis*/, domTree,
5454
nullptr /*calleeAnalysis*/, deleter) {}
5555

lib/SILOptimizer/SILCombiner/SILCombine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ void SILCombiner::canonicalizeOSSALifetimes(SILInstruction *currentInst) {
352352
DominanceInfo *domTree = DA->get(&Builder.getFunction());
353353
CanonicalizeOSSALifetime canonicalizer(
354354
DontPruneDebugInsts,
355-
!parentTransform->getFunction()->shouldOptimize() /*maximize lifetime*/,
355+
MaximizeLifetime_t(!parentTransform->getFunction()->shouldOptimize()),
356356
parentTransform->getFunction(), NLABA, domTree, CA, deleter);
357357
CanonicalizeBorrowScope borrowCanonicalizer(parentTransform->getFunction(),
358358
deleter);

lib/SILOptimizer/Transforms/CopyPropagation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ void CopyPropagation::run() {
493493
// canonicalizer performs all modifications through deleter's callbacks, so we
494494
// don't need to explicitly check for changes.
495495
CanonicalizeOSSALifetime canonicalizer(
496-
pruneDebug, /*maximizeLifetime=*/!getFunction()->shouldOptimize(),
496+
pruneDebug, MaximizeLifetime_t(!getFunction()->shouldOptimize()),
497497
getFunction(), accessBlockAnalysis, domTree, calleeAnalysis, deleter);
498498
// NOTE: We assume that the function is in reverse post order so visiting the
499499
// blocks and pushing begin_borrows as we see them and then popping them

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2070,7 +2070,7 @@ void MemoryToRegisters::canonicalizeValueLifetimes(
20702070
}
20712071
}
20722072
CanonicalizeOSSALifetime canonicalizer(
2073-
PruneDebugInsts, /*maximizeLifetime=*/!f.shouldOptimize(), &f,
2073+
PruneDebugInsts, MaximizeLifetime_t(!f.shouldOptimize()), &f,
20742074
accessBlockAnalysis, domInfo, calleeAnalysis, deleter);
20752075
for (auto value : owned) {
20762076
if (isa<SILUndef>(value) || value->isMarkedAsDeleted())

lib/SILOptimizer/Utils/CanonicalizeOSSALifetime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ static FunctionTest CanonicalizeOSSALifetimeTest(
12531253
DominanceInfo *domTree = dominanceAnalysis->get(&function);
12541254
auto *calleeAnalysis = test.template getAnalysis<BasicCalleeAnalysis>();
12551255
auto pruneDebug = PruneDebugInsts_t(arguments.takeBool());
1256-
auto maximizeLifetimes = arguments.takeBool();
1256+
auto maximizeLifetimes = MaximizeLifetime_t(arguments.takeBool());
12571257
auto respectAccessScopes = arguments.takeBool();
12581258
InstructionDeleter deleter;
12591259
CanonicalizeOSSALifetime canonicalizer(

0 commit comments

Comments
 (0)