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)
33
33
: callerStates(),
34
34
// TODO: Make this more aggressive by considering
35
35
// final/visibility/etc.
36
- mayHaveIndirectCallers(f->getDynamicallyReplacedFunction () ||
37
- canBeCalledIndirectly(f->getRepresentation ())),
36
+ mayHaveIndirectCallers(
37
+ f->getDynamicallyReplacedFunction () ||
38
+ f->getReferencedAdHocRequirementWitnessFunction() ||
39
+ canBeCalledIndirectly(f->getRepresentation ())),
38
40
mayHaveExternalCallers(f->isPossiblyUsedExternally () ||
39
41
f->isAvailableExternally()) {}
40
42
Original file line number Diff line number Diff line change @@ -646,6 +646,7 @@ bool FunctionSignatureTransform::run(bool hasCaller) {
646
646
hasCaller |= FSOOptimizeIfNotCalled;
647
647
648
648
if (!hasCaller && (F->getDynamicallyReplacedFunction () ||
649
+ F->getReferencedAdHocRequirementWitnessFunction () ||
649
650
canBeCalledIndirectly (F->getRepresentation ()))) {
650
651
LLVM_DEBUG (llvm::dbgs () << " function has no caller -> abort\n " );
651
652
return false ;
Original file line number Diff line number Diff line change @@ -101,6 +101,9 @@ class DeadFunctionAndGlobalElimination {
101
101
if (F->isDynamicallyReplaceable ())
102
102
return true ;
103
103
104
+ if (F->getReferencedAdHocRequirementWitnessFunction ())
105
+ return true ;
106
+
104
107
// Don't remove pre-specialized functions. We need to preserver the
105
108
// pre-specialization specifications from other modules.
106
109
if (F->hasPrespecialization ())
@@ -325,6 +328,9 @@ class DeadFunctionAndGlobalElimination {
325
328
326
329
LLVM_DEBUG (llvm::dbgs () << " scan function " << F->getName () << ' \n ' );
327
330
331
+ if (auto *adHocWitness = F->getReferencedAdHocRequirementWitnessFunction ())
332
+ ensureAlive (adHocWitness);
333
+
328
334
// First scan all instructions of the function.
329
335
for (SILBasicBlock &BB : *F) {
330
336
for (SILInstruction &I : BB) {
You can’t perform that action at this time.
0 commit comments