Skip to content

Commit 8cf0869

Browse files
committed
Mandatory Inlining: Use loadFunction() instead of linkFunction()
We only need to deserialize the function itself, not its transitive dependencies. Also, only deserialize a function after we've checked that its transparent. For now, this doesn't reduce the volume of SIL linking, because the mandatory linker pass still links everything. But we're almost there.
1 parent 839d00a commit 8cf0869

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/SILOptimizer/Mandatory/MandatoryInlining.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -404,17 +404,22 @@ static SILFunction *getCalleeFunction(
404404
return nullptr;
405405
}
406406

407-
// If CalleeFunction is a declaration, see if we can load it. If we fail to
408-
// load it, bail.
409-
if (CalleeFunction->empty()
410-
&& !AI.getModule().linkFunction(CalleeFunction, Mode))
411-
return nullptr;
412-
413407
// If the CalleeFunction is a not-transparent definition, we can not process
414408
// it.
415409
if (CalleeFunction->isTransparent() == IsNotTransparent)
416410
return nullptr;
417411

412+
// If CalleeFunction is a declaration, see if we can load it.
413+
if (CalleeFunction->empty()) {
414+
// FIXME: Remove 'Mode'
415+
if (Mode != SILOptions::LinkingMode::LinkNone)
416+
AI.getModule().loadFunction(CalleeFunction);
417+
}
418+
419+
// If we fail to load it, bail.
420+
if (CalleeFunction->empty())
421+
return nullptr;
422+
418423
if (F->isSerialized() &&
419424
!CalleeFunction->hasValidLinkageForFragileInline()) {
420425
if (!CalleeFunction->hasValidLinkageForFragileRef()) {

0 commit comments

Comments
 (0)