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