Skip to content

Commit

Permalink
Revert "[InlineCost] Check for conflicting target attributes early"
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
kazutakahirata authored and tru committed Sep 27, 2023
1 parent 4813589 commit 25a150b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 50 deletions.
20 changes: 6 additions & 14 deletions llvm/lib/Analysis/InlineCost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2806,14 +2806,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<const TargetLibraryInfo &(Function &)> &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);
}
Expand Down Expand Up @@ -2929,12 +2931,6 @@ std::optional<InlineResult> 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)) {
Expand All @@ -2949,12 +2945,8 @@ std::optional<InlineResult> 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.
Expand Down
36 changes: 0 additions & 36 deletions llvm/test/Transforms/Inline/target-features-vs-alwaysinline.ll

This file was deleted.

0 comments on commit 25a150b

Please sign in to comment.