|
11 | 11 | //===----------------------------------------------------------------------===//
|
12 | 12 |
|
13 | 13 | #include "swift/SILOptimizer/Utils/PerformanceInlinerUtils.h"
|
| 14 | +#include "swift/Strings.h" |
14 | 15 |
|
15 | 16 | //===----------------------------------------------------------------------===//
|
16 | 17 | // ConstantTracker
|
@@ -630,20 +631,32 @@ SILFunction *swift::getEligibleFunction(FullApplySite AI,
|
630 | 631 | if (!Callee) {
|
631 | 632 | return nullptr;
|
632 | 633 | }
|
| 634 | + auto ModuleName = Callee->getModule().getSwiftModule()->getName().str(); |
| 635 | + bool IsInStdlib = (ModuleName == STDLIB_NAME || ModuleName == SWIFT_ONONE_SUPPORT); |
633 | 636 |
|
634 | 637 | // Don't inline functions that are marked with the @_semantics or @effects
|
635 | 638 | // attribute if the inliner is asked not to inline them.
|
636 | 639 | if (Callee->hasSemanticsAttrs() || Callee->hasEffectsKind()) {
|
637 | 640 | if (WhatToInline == InlineSelection::NoSemanticsAndGlobalInit) {
|
638 | 641 | if (shouldSkipApplyDuringEarlyInlining(AI))
|
639 | 642 | return nullptr;
|
| 643 | + if (Callee->hasSemanticsAttr("inline_late")) |
| 644 | + return nullptr; |
640 | 645 | }
|
641 | 646 | // The "availability" semantics attribute is treated like global-init.
|
642 | 647 | if (Callee->hasSemanticsAttrs() &&
|
643 | 648 | WhatToInline != InlineSelection::Everything &&
|
644 |
| - Callee->hasSemanticsAttrThatStartsWith("availability")) { |
| 649 | + (Callee->hasSemanticsAttrThatStartsWith("availability") || |
| 650 | + (Callee->hasSemanticsAttrThatStartsWith("inline_late")))) { |
645 | 651 | return nullptr;
|
646 | 652 | }
|
| 653 | + if (Callee->hasSemanticsAttrs() && |
| 654 | + WhatToInline == InlineSelection::Everything) { |
| 655 | + if (Callee->hasSemanticsAttrThatStartsWith("inline_late") && IsInStdlib) { |
| 656 | + return nullptr; |
| 657 | + } |
| 658 | + } |
| 659 | + |
647 | 660 | } else if (Callee->isGlobalInit()) {
|
648 | 661 | if (WhatToInline != InlineSelection::Everything) {
|
649 | 662 | return nullptr;
|
|
0 commit comments