Skip to content

Commit 431fb27

Browse files
committed
[NFC] OwnedValueCan: Typed pruneDebugMode.
1 parent e5a5674 commit 431fb27

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

include/swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ class CanonicalOSSAConsumeInfo final {
180180
SWIFT_ASSERT_ONLY_DECL(void dump() const LLVM_ATTRIBUTE_USED);
181181
};
182182

183+
enum PruneDebugInsts_t : bool {
184+
DontPruneDebugInsts = false,
185+
PruneDebugInsts = true,
186+
};
187+
183188
/// Canonicalize OSSA lifetimes.
184189
///
185190
/// Allows the allocation of analysis state to be reused across calls to
@@ -221,7 +226,7 @@ class CanonicalizeOSSALifetime final {
221226
private:
222227
/// If true, then debug_value instructions outside of non-debug
223228
/// liveness may be pruned during canonicalization.
224-
bool pruneDebugMode;
229+
const PruneDebugInsts_t pruneDebugMode;
225230

226231
/// If true, lifetimes will not be shortened except when necessary to avoid
227232
/// copies.
@@ -312,8 +317,8 @@ class CanonicalizeOSSALifetime final {
312317
}
313318
};
314319

315-
CanonicalizeOSSALifetime(bool pruneDebugMode, bool maximizeLifetime,
316-
SILFunction *function,
320+
CanonicalizeOSSALifetime(PruneDebugInsts_t pruneDebugMode,
321+
bool maximizeLifetime, SILFunction *function,
317322
NonLocalAccessBlockAnalysis *accessBlockAnalysis,
318323
DominanceInfo *domTree,
319324
BasicCalleeAnalysis *calleeAnalysis,

lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct OSSACanonicalizer {
4848

4949
OSSACanonicalizer(SILFunction *fn, DominanceInfo *domTree,
5050
InstructionDeleter &deleter)
51-
: canonicalizer(false /*pruneDebugMode*/,
51+
: canonicalizer(DontPruneDebugInsts,
5252
!fn->shouldOptimize() /*maximizeLifetime*/, fn,
5353
nullptr /*accessBlockAnalysis*/, domTree,
5454
nullptr /*calleeAnalysis*/, deleter) {}

lib/SILOptimizer/SILCombiner/SILCombine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ void SILCombiner::canonicalizeOSSALifetimes(SILInstruction *currentInst) {
351351

352352
DominanceInfo *domTree = DA->get(&Builder.getFunction());
353353
CanonicalizeOSSALifetime canonicalizer(
354-
false /*prune debug*/,
354+
DontPruneDebugInsts,
355355
!parentTransform->getFunction()->shouldOptimize() /*maximize lifetime*/,
356356
parentTransform->getFunction(), NLABA, domTree, CA, deleter);
357357
CanonicalizeBorrowScope borrowCanonicalizer(parentTransform->getFunction(),

lib/SILOptimizer/Transforms/CopyPropagation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,15 @@ namespace {
425425

426426
class CopyPropagation : public SILFunctionTransform {
427427
/// If true, debug_value instructions should be pruned.
428-
bool pruneDebug;
428+
PruneDebugInsts_t pruneDebug;
429429
/// If true, all values will be canonicalized.
430430
bool canonicalizeAll;
431431
/// If true, then borrow scopes will be canonicalized, allowing copies of
432432
/// guaranteed values to be optimized. Does *not* shrink the borrow scope.
433433
bool canonicalizeBorrows;
434434

435435
public:
436-
CopyPropagation(bool pruneDebug, bool canonicalizeAll,
436+
CopyPropagation(PruneDebugInsts_t pruneDebug, bool canonicalizeAll,
437437
bool canonicalizeBorrows)
438438
: pruneDebug(pruneDebug), canonicalizeAll(canonicalizeAll),
439439
canonicalizeBorrows(canonicalizeBorrows) {}
@@ -643,11 +643,11 @@ void CopyPropagation::run() {
643643
// MandatoryCopyPropagation is not currently enabled in the -Onone pipeline
644644
// because it may negatively affect the debugging experience.
645645
SILTransform *swift::createMandatoryCopyPropagation() {
646-
return new CopyPropagation(/*pruneDebug*/ true, /*canonicalizeAll*/ true,
646+
return new CopyPropagation(PruneDebugInsts, /*canonicalizeAll*/ true,
647647
/*canonicalizeBorrows*/ false);
648648
}
649649

650650
SILTransform *swift::createCopyPropagation() {
651-
return new CopyPropagation(/*pruneDebug*/ true, /*canonicalizeAll*/ true,
651+
return new CopyPropagation(PruneDebugInsts, /*canonicalizeAll*/ true,
652652
/*canonicalizeBorrows*/ EnableRewriteBorrows);
653653
}

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-
/*pruneDebug=*/true, /*maximizeLifetime=*/!f.shouldOptimize(), &f,
2073+
PruneDebugInsts, /*maximizeLifetime=*/!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
@@ -1252,7 +1252,7 @@ static FunctionTest CanonicalizeOSSALifetimeTest(
12521252
auto *dominanceAnalysis = test.template getAnalysis<DominanceAnalysis>();
12531253
DominanceInfo *domTree = dominanceAnalysis->get(&function);
12541254
auto *calleeAnalysis = test.template getAnalysis<BasicCalleeAnalysis>();
1255-
auto pruneDebug = arguments.takeBool();
1255+
auto pruneDebug = PruneDebugInsts_t(arguments.takeBool());
12561256
auto maximizeLifetimes = arguments.takeBool();
12571257
auto respectAccessScopes = arguments.takeBool();
12581258
InstructionDeleter deleter;

0 commit comments

Comments
 (0)