Skip to content
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
3 changes: 2 additions & 1 deletion llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9028,11 +9028,12 @@ bool AArch64TargetLowering::isEligibleForTailCallOptimization(
CallingConv::ID CallerCC = CallerF.getCallingConv();

// SME Streaming functions are not eligible for TCO as they may require
// the streaming mode or ZA to be restored after returning from the call.
// the streaming mode or ZA/ZT0 to be restored after returning from the call.
SMECallAttrs CallAttrs =
getSMECallAttrs(CallerF, getRuntimeLibcallsInfo(), CLI);
if (CallAttrs.requiresSMChange() || CallAttrs.requiresLazySave() ||
CallAttrs.requiresPreservingAllZAState() ||
CallAttrs.requiresPreservingZT0() ||
CallAttrs.caller().hasStreamingBody())
return false;

Expand Down
18 changes: 18 additions & 0 deletions llvm/test/CodeGen/AArch64/sme-zt0-state.ll
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,21 @@ define void @zt0_multiple_private_za_calls(ptr %callee) "aarch64_in_zt0" nounwin
call void %callee()
ret void
}

define void @disable_tailcallopt(ptr %callee) "aarch64_inout_zt0" nounwind {
; CHECK-COMMON-LABEL: disable_tailcallopt:
; CHECK-COMMON: // %bb.0:
; CHECK-COMMON-NEXT: sub sp, sp, #80
; CHECK-COMMON-NEXT: stp x30, x19, [sp, #64] // 16-byte Folded Spill
; CHECK-COMMON-NEXT: mov x19, sp
; CHECK-COMMON-NEXT: str zt0, [x19]
; CHECK-COMMON-NEXT: smstop za
; CHECK-COMMON-NEXT: blr x0
; CHECK-COMMON-NEXT: smstart za
; CHECK-COMMON-NEXT: ldr zt0, [x19]
; CHECK-COMMON-NEXT: ldp x30, x19, [sp, #64] // 16-byte Folded Reload
; CHECK-COMMON-NEXT: add sp, sp, #80
; CHECK-COMMON-NEXT: ret
tail call void %callee()
ret void
}