[llvm] dbf9b93 - [AArch64][SME] Disable tail-call optimization for __arm_locally_streaming functions. (#65258)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 4 07:11:26 PDT 2023
Author: sdesmalen-arm
Date: 2023-09-04T15:11:22+01:00
New Revision: dbf9b93f25d60cdad11aa624d6b58f6ee6c5075f
URL: https://github.com/llvm/llvm-project/commit/dbf9b93f25d60cdad11aa624d6b58f6ee6c5075f
DIFF: https://github.com/llvm/llvm-project/commit/dbf9b93f25d60cdad11aa624d6b58f6ee6c5075f.diff
LOG: [AArch64][SME] Disable tail-call optimization for __arm_locally_streaming functions. (#65258)
When calling a function which requires no streaming-mode change from an
__arm_locally_streaming function, LLVM would otherwise emit:
// function prologue
smstart
b streaming_compatible_function // tail call
// never an smstop
Added:
Modified:
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/sme-streaming-body.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 4c54dcea693668..16fe5bc2786318 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -6980,7 +6980,8 @@ bool AArch64TargetLowering::isEligibleForTailCallOptimization(
SMEAttrs CallerAttrs(MF.getFunction());
auto CalleeAttrs = CLI.CB ? SMEAttrs(*CLI.CB) : SMEAttrs(SMEAttrs::Normal);
if (CallerAttrs.requiresSMChange(CalleeAttrs) ||
- CallerAttrs.requiresLazySave(CalleeAttrs))
+ CallerAttrs.requiresLazySave(CalleeAttrs) ||
+ CallerAttrs.hasStreamingBody())
return false;
// Functions using the C or Fast calling convention that have an SVE signature
diff --git a/llvm/test/CodeGen/AArch64/sme-streaming-body.ll b/llvm/test/CodeGen/AArch64/sme-streaming-body.ll
index 74dd66fedceb77..a92a815e93bea4 100644
--- a/llvm/test/CodeGen/AArch64/sme-streaming-body.ll
+++ b/llvm/test/CodeGen/AArch64/sme-streaming-body.ll
@@ -308,3 +308,24 @@ for.cond.cleanup:
ret float %add
}
+
+define void @disable_tailcallopt() "aarch64_pstate_sm_body" nounwind {
+; CHECK-LABEL: disable_tailcallopt:
+; CHECK: // %bb.0:
+; CHECK-NEXT: stp d15, d14, [sp, #-80]! // 16-byte Folded Spill
+; CHECK-NEXT: stp d13, d12, [sp, #16] // 16-byte Folded Spill
+; CHECK-NEXT: stp d11, d10, [sp, #32] // 16-byte Folded Spill
+; CHECK-NEXT: stp d9, d8, [sp, #48] // 16-byte Folded Spill
+; CHECK-NEXT: str x30, [sp, #64] // 8-byte Folded Spill
+; CHECK-NEXT: smstart sm
+; CHECK-NEXT: bl streaming_compatible_callee
+; CHECK-NEXT: smstop sm
+; CHECK-NEXT: ldp d9, d8, [sp, #48] // 16-byte Folded Reload
+; CHECK-NEXT: ldr x30, [sp, #64] // 8-byte Folded Reload
+; CHECK-NEXT: ldp d11, d10, [sp, #32] // 16-byte Folded Reload
+; CHECK-NEXT: ldp d13, d12, [sp, #16] // 16-byte Folded Reload
+; CHECK-NEXT: ldp d15, d14, [sp], #80 // 16-byte Folded Reload
+; CHECK-NEXT: ret
+ tail call void @streaming_compatible_callee();
+ ret void;
+}
More information about the llvm-commits
mailing list