mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[sil-devirtualizer] Fix a bug in devirtualization of methods that never return
This bug was caught by the SIL verifier. Any invocation of a NoReturn function should be followed by an `unreachable` instruction. Fixes rdar://problem/33591235
This commit is contained in:
@@ -150,10 +150,15 @@ static FullApplySite speculateMonomorphicTarget(FullApplySite AI,
|
||||
SILArgument *Arg =
|
||||
Continue->createPHIArgument(AI.getType(), ValueOwnershipKind::Owned);
|
||||
if (!isa<TryApplyInst>(AI)) {
|
||||
IdenBuilder.createBranch(AI.getLoc(), Continue,
|
||||
ArrayRef<SILValue>(IdenAI.getInstruction()));
|
||||
VirtBuilder.createBranch(AI.getLoc(), Continue,
|
||||
ArrayRef<SILValue>(VirtAI.getInstruction()));
|
||||
if (AI.getSubstCalleeType()->isNoReturnFunction()) {
|
||||
IdenBuilder.createUnreachable(AI.getLoc());
|
||||
VirtBuilder.createUnreachable(AI.getLoc());
|
||||
} else {
|
||||
IdenBuilder.createBranch(AI.getLoc(), Continue,
|
||||
ArrayRef<SILValue>(IdenAI.getInstruction()));
|
||||
VirtBuilder.createBranch(AI.getLoc(), Continue,
|
||||
ArrayRef<SILValue>(VirtAI.getInstruction()));
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the old Apply instruction.
|
||||
|
||||
Reference in New Issue
Block a user