File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,13 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
193
193
Helper.getArguments (), Inst->isNonThrowing (),
194
194
GenericSpecializationInformation::create (
195
195
Inst, getBuilder ()));
196
+ // Specialization can return noreturn applies that were not identified as
197
+ // such before.
198
+ if (N->isCalleeNoReturn () &&
199
+ !isa<UnreachableInst>(*std::next (SILBasicBlock::iterator (Inst)))) {
200
+ noReturnApplies.push_back (N);
201
+ }
202
+
196
203
recordClonedInstruction (Inst, N);
197
204
}
198
205
@@ -381,6 +388,9 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
381
388
SILFunction &Original;
382
389
// / True, if used for inlining.
383
390
bool Inlining;
391
+ // Generic specialization can create noreturn applications that where
392
+ // previously not identifiable as such.
393
+ SmallVector<ApplyInst *, 16 > noReturnApplies;
384
394
};
385
395
386
396
} // end namespace swift
Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ class GenericCloner
74
74
return SC.getCloned ();
75
75
}
76
76
77
+ void fixUp (SILFunction *calleeFunction);
78
+
77
79
protected:
78
80
void visitTerminator (SILBasicBlock *BB);
79
81
Original file line number Diff line number Diff line change @@ -191,3 +191,12 @@ const SILDebugScope *GenericCloner::remapScope(const SILDebugScope *DS) {
191
191
RemappedScopeCache.insert ({DS, RemappedScope});
192
192
return RemappedScope;
193
193
}
194
+
195
+ void GenericCloner::fixUp (SILFunction *f) {
196
+ for (auto *apply : noReturnApplies) {
197
+ auto applyBlock = apply->getParent ();
198
+ applyBlock->split (std::next (SILBasicBlock::iterator (apply)));
199
+ getBuilder ().setInsertionPoint (applyBlock);
200
+ getBuilder ().createUnreachable (apply->getLoc ());
201
+ }
202
+ }
You can’t perform that action at this time.
0 commit comments