@@ -652,6 +652,10 @@ addToBBCounts(llvm::DenseMap<SILBasicBlock *, uint64_t> &BBToWeightMap,
652
652
}
653
653
}
654
654
655
+ static bool isInlineAlwaysCallSite (SILFunction *Callee) {
656
+ return Callee->getInlineStrategy () == AlwaysInline || Callee->isTransparent ();
657
+ }
658
+
655
659
static void
656
660
calculateBBWeights (SILFunction *Caller, DominanceInfo *DT,
657
661
llvm::DenseMap<SILBasicBlock *, uint64_t > &BBToWeightMap) {
@@ -787,6 +791,23 @@ void SILPerformanceInliner::collectAppliesToInline(
787
791
788
792
auto *Callee = getEligibleFunction (AI, WhatToInline);
789
793
if (Callee) {
794
+ // Check if we have an always_inline or transparent function. If we do,
795
+ // just add it to our final Applies list and continue.
796
+ if (isInlineAlwaysCallSite (Callee)) {
797
+ NumCallerBlocks += Callee->size ();
798
+ Applies.push_back (AI);
799
+ continue ;
800
+ }
801
+
802
+ // Next make sure that we do not have more blocks than our overall
803
+ // caller block limit at this point. In such a case, we continue. This
804
+ // will ensure that any further non inline always functions are skipped,
805
+ // but we /do/ inline any inline_always functions remaining.
806
+ if (NumCallerBlocks > OverallCallerBlockLimit)
807
+ continue ;
808
+
809
+ // Otherwise, calculate our block weights and determine if we want to
810
+ // inline this.
790
811
if (!BlockWeight.isValid ())
791
812
BlockWeight = SPA->getWeight (block, Weight (0 , 0 ));
792
813
@@ -798,8 +819,6 @@ void SILPerformanceInliner::collectAppliesToInline(
798
819
InitialCandidates.push_back (AI);
799
820
}
800
821
}
801
- if (NumCallerBlocks > OverallCallerBlockLimit)
802
- break ;
803
822
804
823
domOrder.pushChildrenIf (block, [&] (SILBasicBlock *child) {
805
824
if (CBI.isSlowPath (block, child)) {
0 commit comments