@@ -2806,14 +2806,16 @@ LLVM_DUMP_METHOD void InlineCostCallAnalyzer::dump() { print(dbgs()); }
2806
2806
// / Test that there are no attribute conflicts between Caller and Callee
2807
2807
// / that prevent inlining.
2808
2808
static bool functionsHaveCompatibleAttributes (
2809
- Function *Caller, Function *Callee,
2809
+ Function *Caller, Function *Callee, TargetTransformInfo &TTI,
2810
2810
function_ref<const TargetLibraryInfo &(Function &)> &GetTLI) {
2811
2811
// Note that CalleeTLI must be a copy not a reference. The legacy pass manager
2812
2812
// caches the most recently created TLI in the TargetLibraryInfoWrapperPass
2813
2813
// object, and always returns the same object (which is overwritten on each
2814
2814
// GetTLI call). Therefore we copy the first result.
2815
2815
auto CalleeTLI = GetTLI (*Callee);
2816
- return GetTLI (*Caller).areInlineCompatible (CalleeTLI,
2816
+ return (IgnoreTTIInlineCompatible ||
2817
+ TTI.areInlineCompatible (Caller, Callee)) &&
2818
+ GetTLI (*Caller).areInlineCompatible (CalleeTLI,
2817
2819
InlineCallerSupersetNoBuiltin) &&
2818
2820
AttributeFuncs::areInlineCompatible (*Caller, *Callee);
2819
2821
}
@@ -2929,12 +2931,6 @@ std::optional<InlineResult> llvm::getAttributeBasedInliningDecision(
2929
2931
" address space" );
2930
2932
}
2931
2933
2932
- // Never inline functions with conflicting target attributes.
2933
- Function *Caller = Call.getCaller ();
2934
- if (!IgnoreTTIInlineCompatible &&
2935
- !CalleeTTI.areInlineCompatible (Caller, Callee))
2936
- return InlineResult::failure (" conflicting target attributes" );
2937
-
2938
2934
// Calls to functions with always-inline attributes should be inlined
2939
2935
// whenever possible.
2940
2936
if (Call.hasFnAttr (Attribute::AlwaysInline)) {
@@ -2949,12 +2945,8 @@ std::optional<InlineResult> llvm::getAttributeBasedInliningDecision(
2949
2945
2950
2946
// Never inline functions with conflicting attributes (unless callee has
2951
2947
// always-inline attribute).
2952
- // FIXME: functionsHaveCompatibleAttributes below checks for compatibilities
2953
- // of different kinds of function attributes -- sanitizer-related ones,
2954
- // checkDenormMode, no-builtin-memcpy, etc. It's unclear if we really want
2955
- // the always-inline attribute to take precedence over these different types
2956
- // of function attributes.
2957
- if (!functionsHaveCompatibleAttributes (Caller, Callee, GetTLI))
2948
+ Function *Caller = Call.getCaller ();
2949
+ if (!functionsHaveCompatibleAttributes (Caller, Callee, CalleeTTI, GetTLI))
2958
2950
return InlineResult::failure (" conflicting attributes" );
2959
2951
2960
2952
// Don't inline this call if the caller has the optnone attribute.
0 commit comments