Skip to content

[AArch64] Dont inline streaming fn into non-streaming caller #150595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ bool AArch64TTIImpl::areInlineCompatible(const Function *Caller,
const Function *Callee) const {
SMECallAttrs CallAttrs(*Caller, *Callee);

// Never inline a function explicitly marked as being streaming,
// into a non-streaming function. Assume it was marked as streaming
// for a reason.
if (CallAttrs.caller().hasNonStreamingInterfaceAndBody() &&
CallAttrs.callee().hasStreamingInterfaceOrBody())
return false;

// When inlining, we should consider the body of the function, not the
// interface.
if (CallAttrs.callee().hasStreamingBody()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ target triple = "aarch64"

declare void @streaming_compatible_f() #0 "aarch64_pstate_sm_compatible"

; Function @streaming_callee doesn't contain any operations that may use ZA
; Function @non_streaming_callee doesn't contain any operations that may use ZA
; state and therefore can be legally inlined into a normal function.
define void @streaming_callee() #0 "aarch64_pstate_sm_enabled" {
; CHECK-LABEL: define void @streaming_callee
define void @non_streaming_callee() #0 {
; CHECK-LABEL: define void @non_streaming_callee
; CHECK-SAME: () #[[ATTR1:[0-9]+]] {
; CHECK-NEXT: call void @streaming_compatible_f()
; CHECK-NEXT: call void @streaming_compatible_f()
Expand All @@ -21,26 +21,26 @@ define void @streaming_callee() #0 "aarch64_pstate_sm_enabled" {
ret void
}

; Inline call to @streaming_callee to remove a streaming mode change.
define void @non_streaming_caller_inline() #0 {
; CHECK-LABEL: define void @non_streaming_caller_inline
; Inline call to @non_streaming_callee to remove a streaming mode change.
define void @streaming_caller_inline() #0 "aarch64_pstate_sm_enabled" {
; CHECK-LABEL: define void @streaming_caller_inline
; CHECK-SAME: () #[[ATTR2:[0-9]+]] {
; CHECK-NEXT: call void @streaming_compatible_f()
; CHECK-NEXT: call void @streaming_compatible_f()
; CHECK-NEXT: ret void
;
call void @streaming_callee()
call void @non_streaming_callee()
ret void
}

; Don't inline call to @streaming_callee when the inline-threshold is set to 1, because it does not eliminate a streaming-mode change.
define void @streaming_caller_dont_inline() #0 "aarch64_pstate_sm_enabled" {
; CHECK-LABEL: define void @streaming_caller_dont_inline
; Don't inline call to @non_streaming_callee when the inline-threshold is set to 1, because it does not eliminate a streaming-mode change.
define void @non_streaming_caller_dont_inline() #0 {
; CHECK-LABEL: define void @non_streaming_caller_dont_inline
; CHECK-SAME: () #[[ATTR1]] {
; CHECK-NEXT: call void @streaming_callee()
; CHECK-NEXT: call void @non_streaming_callee()
; CHECK-NEXT: ret void
;
call void @streaming_callee()
call void @non_streaming_callee()
ret void
}

Expand Down
Loading