Skip to content

Commit 54dbdbc

Browse files
committed
[mandatory-inline] Add a note about the weird behavior where II later in Mandatory inlining may no longer be the original apply.
This is one reason for the weird iteration maintainance code in MandatoryInlining. This comment at least makes it clear what is going on (more for historical purposes, since I am hoping to fix this soon). rdar://31521023
1 parent 0cebfc3 commit 54dbdbc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/SILOptimizer/Mandatory/MandatoryInlining.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ runOnFunctionRecursively(SILFunction *F, FullApplySite AI,
395395

396396
auto *ApplyBlock = InnerAI.getParent();
397397

398+
// *NOTE* If devirtualization succeeds, sometimes II will not be InnerAI,
399+
// but a casted result of InnerAI or even a block argument due to
400+
// abstraction changes when calling the witness or class method. We still
401+
// know that InnerAI dominates II though.
398402
std::tie(InnerAI, II) = tryDevirtualizeApplyHelper(InnerAI, II, CHA);
399403
if (!InnerAI)
400404
continue;
@@ -465,6 +469,9 @@ runOnFunctionRecursively(SILFunction *F, FullApplySite AI,
465469
SILInliner::InlineKind::MandatoryInline, ApplySubs,
466470
OpenedArchetypesTracker);
467471
if (!Inliner.canInlineFunction(InnerAI)) {
472+
// See comment above about casting when devirtualizing and how this
473+
// sometimes causes II and InnerAI to be different and even in different
474+
// blocks.
468475
II = InnerAI.getInstruction()->getIterator();
469476
continue;
470477
}

0 commit comments

Comments
 (0)