Skip to content

Commit

Permalink
[AArch64][SME] Fix inlining bug introduced in llvm#78703 (llvm#79994)
Browse files Browse the repository at this point in the history
Calling a `__arm_locally_streaming` function from a function that
is not a streaming-SVE function would lead to incorrect inlining.

The issue didn't surface because the tests were not testing what
they were supposed to test.

(cherry picked from commit 3abf55a)
  • Loading branch information
sdesmalen-arm authored and tstellar committed Feb 14, 2024
1 parent d766ecd commit 5df2623
Show file tree
Hide file tree
Showing 2 changed files with 195 additions and 191 deletions.
17 changes: 11 additions & 6 deletions llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,20 @@ static bool hasPossibleIncompatibleOps(const Function *F) {

bool AArch64TTIImpl::areInlineCompatible(const Function *Caller,
const Function *Callee) const {
SMEAttrs CallerAttrs(*Caller);
SMEAttrs CalleeAttrs(*Callee);
SMEAttrs CallerAttrs(*Caller), CalleeAttrs(*Callee);

// When inlining, we should consider the body of the function, not the
// interface.
if (CalleeAttrs.hasStreamingBody()) {
CalleeAttrs.set(SMEAttrs::SM_Compatible, false);
CalleeAttrs.set(SMEAttrs::SM_Enabled, true);
}

if (CalleeAttrs.hasNewZABody())
return false;

if (CallerAttrs.requiresLazySave(CalleeAttrs) ||
(CallerAttrs.requiresSMChange(CalleeAttrs) &&
(!CallerAttrs.hasStreamingInterfaceOrBody() ||
!CalleeAttrs.hasStreamingBody()))) {
CallerAttrs.requiresSMChange(CalleeAttrs)) {
if (hasPossibleIncompatibleOps(Callee))
return false;
}
Expand Down Expand Up @@ -4062,4 +4067,4 @@ bool AArch64TTIImpl::shouldTreatInstructionLikeSelect(const Instruction *I) {
cast<BranchInst>(I->getNextNode())->isUnconditional())
return true;
return BaseT::shouldTreatInstructionLikeSelect(I);
}
}
Loading

0 comments on commit 5df2623

Please sign in to comment.