File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed
FunctionSignatureTransforms Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,10 @@ CallerAnalysis::FunctionInfo::FunctionInfo(SILFunction *f)
3333 : callerStates(),
3434 // TODO: Make this more aggressive by considering
3535 // final/visibility/etc.
36- mayHaveIndirectCallers(f->getDynamicallyReplacedFunction () ||
37- canBeCalledIndirectly(f->getRepresentation ())),
36+ mayHaveIndirectCallers(
37+ f->getDynamicallyReplacedFunction () ||
38+ f->getReferencedAdHocRequirementWitnessFunction() ||
39+ canBeCalledIndirectly(f->getRepresentation ())),
3840 mayHaveExternalCallers(f->isPossiblyUsedExternally () ||
3941 f->isAvailableExternally()) {}
4042
Original file line number Diff line number Diff line change @@ -646,6 +646,7 @@ bool FunctionSignatureTransform::run(bool hasCaller) {
646646 hasCaller |= FSOOptimizeIfNotCalled;
647647
648648 if (!hasCaller && (F->getDynamicallyReplacedFunction () ||
649+ F->getReferencedAdHocRequirementWitnessFunction () ||
649650 canBeCalledIndirectly (F->getRepresentation ()))) {
650651 LLVM_DEBUG (llvm::dbgs () << " function has no caller -> abort\n " );
651652 return false ;
Original file line number Diff line number Diff line change @@ -101,6 +101,9 @@ class DeadFunctionAndGlobalElimination {
101101 if (F->isDynamicallyReplaceable ())
102102 return true ;
103103
104+ if (F->getReferencedAdHocRequirementWitnessFunction ())
105+ return true ;
106+
104107 // Don't remove pre-specialized functions. We need to preserver the
105108 // pre-specialization specifications from other modules.
106109 if (F->hasPrespecialization ())
@@ -325,6 +328,9 @@ class DeadFunctionAndGlobalElimination {
325328
326329 LLVM_DEBUG (llvm::dbgs () << " scan function " << F->getName () << ' \n ' );
327330
331+ if (auto *adHocWitness = F->getReferencedAdHocRequirementWitnessFunction ())
332+ ensureAlive (adHocWitness);
333+
328334 // First scan all instructions of the function.
329335 for (SILBasicBlock &BB : *F) {
330336 for (SILInstruction &I : BB) {
You can’t perform that action at this time.
0 commit comments