Skip to content

Commit 5df2623

Browse files
sdesmalen-armtstellar
authored andcommitted
[AArch64][SME] Fix inlining bug introduced in llvm#78703 (llvm#79994)
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)
1 parent d766ecd commit 5df2623

File tree

2 files changed

+195
-191
lines changed

2 files changed

+195
-191
lines changed

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,20 @@ static bool hasPossibleIncompatibleOps(const Function *F) {
233233

234234
bool AArch64TTIImpl::areInlineCompatible(const Function *Caller,
235235
const Function *Callee) const {
236-
SMEAttrs CallerAttrs(*Caller);
237-
SMEAttrs CalleeAttrs(*Callee);
236+
SMEAttrs CallerAttrs(*Caller), CalleeAttrs(*Callee);
237+
238+
// When inlining, we should consider the body of the function, not the
239+
// interface.
240+
if (CalleeAttrs.hasStreamingBody()) {
241+
CalleeAttrs.set(SMEAttrs::SM_Compatible, false);
242+
CalleeAttrs.set(SMEAttrs::SM_Enabled, true);
243+
}
244+
238245
if (CalleeAttrs.hasNewZABody())
239246
return false;
240247

241248
if (CallerAttrs.requiresLazySave(CalleeAttrs) ||
242-
(CallerAttrs.requiresSMChange(CalleeAttrs) &&
243-
(!CallerAttrs.hasStreamingInterfaceOrBody() ||
244-
!CalleeAttrs.hasStreamingBody()))) {
249+
CallerAttrs.requiresSMChange(CalleeAttrs)) {
245250
if (hasPossibleIncompatibleOps(Callee))
246251
return false;
247252
}
@@ -4062,4 +4067,4 @@ bool AArch64TTIImpl::shouldTreatInstructionLikeSelect(const Instruction *I) {
40624067
cast<BranchInst>(I->getNextNode())->isUnconditional())
40634068
return true;
40644069
return BaseT::shouldTreatInstructionLikeSelect(I);
4065-
}
4070+
}

0 commit comments

Comments
 (0)