mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SILOptimizer: Fix analysis invalidation after devirtualization.
Devirtualizing try_apply modified the CFG, but passes that run devirtualization were not invalidating any CFG analyses, such as the domtree. This could hypothetically have caused miscompilation, but will be caught by running with -sil-verify-all.
This commit is contained in:
@@ -229,7 +229,8 @@ static FullApplySite speculateMonomorphicTarget(FullApplySite AI,
|
||||
|
||||
// Devirtualize the apply instruction on the identical path.
|
||||
auto NewInst =
|
||||
devirtualizeClassMethod(IdenAI, DownCastedClassInstance, CD, nullptr);
|
||||
devirtualizeClassMethod(IdenAI, DownCastedClassInstance, CD, nullptr)
|
||||
.first;
|
||||
assert(NewInst && "Expected to be able to devirtualize apply!");
|
||||
(void)NewInst;
|
||||
|
||||
@@ -414,7 +415,8 @@ static bool tryToSpeculateTarget(FullApplySite AI, ClassHierarchyAnalysis *CHA,
|
||||
// try to devirtualize it completely.
|
||||
ClassHierarchyAnalysis::ClassList Subs;
|
||||
if (isDefaultCaseKnown(CHA, AI, CD, Subs)) {
|
||||
auto NewInst = tryDevirtualizeClassMethod(AI, SubTypeValue, CD, &ORE);
|
||||
auto NewInst =
|
||||
tryDevirtualizeClassMethod(AI, SubTypeValue, CD, &ORE).first;
|
||||
if (NewInst)
|
||||
deleteDevirtualizedApply(AI);
|
||||
return bool(NewInst);
|
||||
@@ -574,7 +576,8 @@ static bool tryToSpeculateTarget(FullApplySite AI, ClassHierarchyAnalysis *CHA,
|
||||
ORE.emit(RB);
|
||||
return true;
|
||||
}
|
||||
auto NewInst = tryDevirtualizeClassMethod(AI, SubTypeValue, CD, nullptr);
|
||||
auto NewInst =
|
||||
tryDevirtualizeClassMethod(AI, SubTypeValue, CD, nullptr).first;
|
||||
if (NewInst) {
|
||||
ORE.emit(RB);
|
||||
deleteDevirtualizedApply(AI);
|
||||
|
||||
Reference in New Issue
Block a user