Skip to content

Commit 4c47982

Browse files
committed
[SILOptimizer] Eliminate non-case handling for implicit Optional non-Optional casting of unchecked_ref_cast in ValueDefUseWalker.
1 parent 2237fac commit 4c47982

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

SwiftCompilerSources/Sources/Optimizer/TestPasses/EscapeInfoDumper.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import SIL
1414

1515
/// Dumps the results of escape analysis.
1616
///
17-
/// Dumps the EscapeInfo query results for all `alloc_stack` instructions in a function.
17+
/// Dumps the EscapeInfo query results for all `alloc_ref` instructions in a function.
1818
///
1919
/// This pass is used for testing EscapeInfo.
2020
let escapeInfoDumper = FunctionPass(name: "dump-escape-info") {

SwiftCompilerSources/Sources/SIL/Utilities/WalkUtils.swift

+7-22
Original file line numberDiff line numberDiff line change
@@ -376,19 +376,12 @@ extension ValueDefUseWalker {
376376
// accordingly.
377377
switch (urc.type.isOptional, urc.fromInstance.type.isOptional) {
378378
case (true, false):
379-
if walkDownUses(ofValue: urc, path: path.push(.enumCase, index: 0)) == .abortWalk {
380-
return .abortWalk
381-
}
382379
return walkDownUses(ofValue: urc, path: path.push(.enumCase, index: 1))
383380
case (false, true):
384-
if let path = path.popIfMatches(.enumCase, index: 0) {
385-
if walkDownUses(ofValue: urc, path: path) == .abortWalk {
386-
return .abortWalk
387-
} else if let path = path.popIfMatches(.enumCase, index: 1) {
388-
return walkDownUses(ofValue: urc, path: path)
389-
}
381+
if let path = path.popIfMatches(.enumCase, index: 1) {
382+
return walkDownUses(ofValue: urc, path: path)
390383
}
391-
return .abortWalk
384+
return unmatchedPath(value: operand, path: path)
392385
default:
393386
return walkDownUses(ofValue: urc, path: path)
394387
}
@@ -726,20 +719,12 @@ extension ValueUseDefWalker {
726719
// accordingly.
727720
switch (urc.type.isOptional, urc.fromInstance.type.isOptional) {
728721
case (true, false):
729-
if let path = path.popIfMatches(.enumCase, index: 0) {
730-
if walkUp(value: urc.fromInstance, path: path) == .abortWalk {
731-
return .abortWalk
732-
} else if let path = path.popIfMatches(.enumCase, index: 1) {
733-
return walkUp(value: urc.fromInstance, path: path)
734-
}
722+
if let path = path.popIfMatches(.enumCase, index: 1) {
723+
return walkUp(value: urc.fromInstance, path: path)
735724
}
736-
return .abortWalk
725+
return unmatchedPath(value: urc.fromInstance, path: path)
737726
case (false, true):
738-
if walkUp(value: urc.fromInstance, path: path.push(.enumCase, index: 0)) == .abortWalk {
739-
return .abortWalk
740-
} else {
741-
return walkUp(value: urc.fromInstance, path: path.push(.enumCase, index: 1))
742-
}
727+
return walkUp(value: urc.fromInstance, path: path.push(.enumCase, index: 1))
743728
default:
744729
return walkUp(value: urc.fromInstance, path: path)
745730
}

0 commit comments

Comments
 (0)