Skip to content

Commit 4ec7cc5

Browse files
kazutakahiratallvmbot
authored andcommitted
Revert "[InlineCost] Check for conflicting target attributes early"
This reverts commit d6f994a. Several people have reported breakage resulting from this patch: - llvm/llvm-project#65152 - llvm/llvm-project#65205 (cherry picked from commit b4301df61fc77a9d54ac236bc88742a731285f1c)
1 parent 4813589 commit 4ec7cc5

File tree

2 files changed

+6
-50
lines changed

2 files changed

+6
-50
lines changed

llvm/lib/Analysis/InlineCost.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,14 +2806,16 @@ LLVM_DUMP_METHOD void InlineCostCallAnalyzer::dump() { print(dbgs()); }
28062806
/// Test that there are no attribute conflicts between Caller and Callee
28072807
/// that prevent inlining.
28082808
static bool functionsHaveCompatibleAttributes(
2809-
Function *Caller, Function *Callee,
2809+
Function *Caller, Function *Callee, TargetTransformInfo &TTI,
28102810
function_ref<const TargetLibraryInfo &(Function &)> &GetTLI) {
28112811
// Note that CalleeTLI must be a copy not a reference. The legacy pass manager
28122812
// caches the most recently created TLI in the TargetLibraryInfoWrapperPass
28132813
// object, and always returns the same object (which is overwritten on each
28142814
// GetTLI call). Therefore we copy the first result.
28152815
auto CalleeTLI = GetTLI(*Callee);
2816-
return GetTLI(*Caller).areInlineCompatible(CalleeTLI,
2816+
return (IgnoreTTIInlineCompatible ||
2817+
TTI.areInlineCompatible(Caller, Callee)) &&
2818+
GetTLI(*Caller).areInlineCompatible(CalleeTLI,
28172819
InlineCallerSupersetNoBuiltin) &&
28182820
AttributeFuncs::areInlineCompatible(*Caller, *Callee);
28192821
}
@@ -2929,12 +2931,6 @@ std::optional<InlineResult> llvm::getAttributeBasedInliningDecision(
29292931
" address space");
29302932
}
29312933

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-
29382934
// Calls to functions with always-inline attributes should be inlined
29392935
// whenever possible.
29402936
if (Call.hasFnAttr(Attribute::AlwaysInline)) {
@@ -2949,12 +2945,8 @@ std::optional<InlineResult> llvm::getAttributeBasedInliningDecision(
29492945

29502946
// Never inline functions with conflicting attributes (unless callee has
29512947
// 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))
29582950
return InlineResult::failure("conflicting attributes");
29592951

29602952
// Don't inline this call if the caller has the optnone attribute.

llvm/test/Transforms/Inline/target-features-vs-alwaysinline.ll

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)