From b4301df61fc77a9d54ac236bc88742a731285f1c Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 21 Sep 2023 10:29:46 -0700 Subject: Revert "[InlineCost] Check for conflicting target attributes early" This reverts commit d6f994acb3d545b80161e24ab742c9c69d4bbf33. Several people have reported breakage resulting from this patch: - https://github.com/llvm/llvm-project/issues/65152 - https://github.com/llvm/llvm-project/issues/65205 --- llvm/lib/Analysis/InlineCost.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'llvm/lib/Analysis/InlineCost.cpp') diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index f5a31628..7582a43 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -2810,14 +2810,16 @@ LLVM_DUMP_METHOD void InlineCostCallAnalyzer::dump() { print(dbgs()); } /// Test that there are no attribute conflicts between Caller and Callee /// that prevent inlining. static bool functionsHaveCompatibleAttributes( - Function *Caller, Function *Callee, + Function *Caller, Function *Callee, TargetTransformInfo &TTI, function_ref &GetTLI) { // Note that CalleeTLI must be a copy not a reference. The legacy pass manager // caches the most recently created TLI in the TargetLibraryInfoWrapperPass // object, and always returns the same object (which is overwritten on each // GetTLI call). Therefore we copy the first result. auto CalleeTLI = GetTLI(*Callee); - return GetTLI(*Caller).areInlineCompatible(CalleeTLI, + return (IgnoreTTIInlineCompatible || + TTI.areInlineCompatible(Caller, Callee)) && + GetTLI(*Caller).areInlineCompatible(CalleeTLI, InlineCallerSupersetNoBuiltin) && AttributeFuncs::areInlineCompatible(*Caller, *Callee); } @@ -2933,12 +2935,6 @@ std::optional llvm::getAttributeBasedInliningDecision( " address space"); } - // Never inline functions with conflicting target attributes. - Function *Caller = Call.getCaller(); - if (!IgnoreTTIInlineCompatible && - !CalleeTTI.areInlineCompatible(Caller, Callee)) - return InlineResult::failure("conflicting target attributes"); - // Calls to functions with always-inline attributes should be inlined // whenever possible. if (Call.hasFnAttr(Attribute::AlwaysInline)) { @@ -2953,12 +2949,8 @@ std::optional llvm::getAttributeBasedInliningDecision( // Never inline functions with conflicting attributes (unless callee has // always-inline attribute). - // FIXME: functionsHaveCompatibleAttributes below checks for compatibilities - // of different kinds of function attributes -- sanitizer-related ones, - // checkDenormMode, no-builtin-memcpy, etc. It's unclear if we really want - // the always-inline attribute to take precedence over these different types - // of function attributes. - if (!functionsHaveCompatibleAttributes(Caller, Callee, GetTLI)) + Function *Caller = Call.getCaller(); + if (!functionsHaveCompatibleAttributes(Caller, Callee, CalleeTTI, GetTLI)) return InlineResult::failure("conflicting attributes"); // Don't inline this call if the caller has the optnone attribute. -- cgit v1.1