Skip to content

Commit 932c27b

Browse files
committed
[AArch64] Dont inline streaming fn into non-streaming caller
Without this change, the following test would fail to compile with `-march=armv8-a+sme`: void func1(const svuint32_t *in, svuint32_t *out) { [&]() __arm_streaming { *out = *in; }(); } But in general, it's probably better never to inline streaming functions into non-streaming functions, because they will have been marked as 'streaming' for a reason by the user.
1 parent 7cfc23c commit 932c27b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ bool AArch64TTIImpl::areInlineCompatible(const Function *Caller,
270270
const Function *Callee) const {
271271
SMECallAttrs CallAttrs(*Caller, *Callee);
272272

273+
// Never inline a function explicitly marked as being streaming,
274+
// into a non-streaming function. Assume it was marked as streaming
275+
// for a reason.
276+
if (CallAttrs.caller().hasNonStreamingInterfaceAndBody() &&
277+
CallAttrs.callee().hasStreamingInterfaceOrBody())
278+
return false;
279+
273280
// When inlining, we should consider the body of the function, not the
274281
// interface.
275282
if (CallAttrs.callee().hasStreamingBody()) {

llvm/test/Transforms/Inline/AArch64/sme-pstatesm-attrs.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ define void @simple_streaming_function(ptr %ptr) #0 "aarch64_pstate_sm_enabled"
690690
define void @non_streaming_caller_streaming_callee_dont_inline(ptr %ptr) #0 {
691691
; CHECK-LABEL: define void @non_streaming_caller_streaming_callee_dont_inline
692692
; CHECK-SAME: (ptr [[PTR:%.*]]) #[[ATTR1]] {
693-
; CHECK-NEXT: store <vscale x 4 x i32> zeroinitializer, ptr [[PTR]], align 16
693+
; CHECK-NEXT: call void @simple_streaming_function(ptr [[PTR]])
694694
; CHECK-NEXT: ret void
695695
;
696696
call void @simple_streaming_function(ptr %ptr)
@@ -711,7 +711,7 @@ define void @simple_locally_streaming_function(ptr %ptr) #0 "aarch64_pstate_sm_b
711711
define void @non_streaming_caller_locally_streaming_callee_dont_inline(ptr %ptr) #0 {
712712
; CHECK-LABEL: define void @non_streaming_caller_locally_streaming_callee_dont_inline
713713
; CHECK-SAME: (ptr [[PTR:%.*]]) #[[ATTR1]] {
714-
; CHECK-NEXT: store <vscale x 4 x i32> zeroinitializer, ptr [[PTR]], align 16
714+
; CHECK-NEXT: call void @simple_locally_streaming_function(ptr [[PTR]])
715715
; CHECK-NEXT: ret void
716716
;
717717
call void @simple_locally_streaming_function(ptr %ptr)

0 commit comments

Comments
 (0)