@@ -2810,14 +2810,16 @@ LLVM_DUMP_METHOD void InlineCostCallAnalyzer::dump() { print(dbgs()); }
28102810// / Test that there are no attribute conflicts between Caller and Callee
28112811// / that prevent inlining.
28122812static bool functionsHaveCompatibleAttributes (
2813- Function *Caller, Function *Callee,
2813+ Function *Caller, Function *Callee, TargetTransformInfo &TTI,
28142814 function_ref<const TargetLibraryInfo &(Function &)> &GetTLI) {
28152815 // Note that CalleeTLI must be a copy not a reference. The legacy pass manager
28162816 // caches the most recently created TLI in the TargetLibraryInfoWrapperPass
28172817 // object, and always returns the same object (which is overwritten on each
28182818 // GetTLI call). Therefore we copy the first result.
28192819 auto CalleeTLI = GetTLI (*Callee);
2820- return GetTLI (*Caller).areInlineCompatible (CalleeTLI,
2820+ return (IgnoreTTIInlineCompatible ||
2821+ TTI.areInlineCompatible (Caller, Callee)) &&
2822+ GetTLI (*Caller).areInlineCompatible (CalleeTLI,
28212823 InlineCallerSupersetNoBuiltin) &&
28222824 AttributeFuncs::areInlineCompatible (*Caller, *Callee);
28232825}
@@ -2933,12 +2935,6 @@ std::optional<InlineResult> llvm::getAttributeBasedInliningDecision(
29332935 " address space" );
29342936 }
29352937
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-
29422938 // Calls to functions with always-inline attributes should be inlined
29432939 // whenever possible.
29442940 if (Call.hasFnAttr (Attribute::AlwaysInline)) {
@@ -2953,12 +2949,8 @@ std::optional<InlineResult> llvm::getAttributeBasedInliningDecision(
29532949
29542950 // Never inline functions with conflicting attributes (unless callee has
29552951 // 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))
29622954 return InlineResult::failure (" conflicting attributes" );
29632955
29642956 // Don't inline this call if the caller has the optnone attribute.
0 commit comments