[compiler-rt] [compiler-rt][ARM] Make interworking test compatible with BTI (PR #226154)
Ties Stuij via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 06:01:33 PDT 2026
https://github.com/stuij created https://github.com/llvm/llvm-project/pull/226154
In the aeabi_cmpflags_interwork_test.c test wrappers, we should return through lr instead of r3 so that runs with BTI enabled don't fail. As returns through lr don't require a landing pad, and returns through r3 do.
>From 6d3b2b321d6ee599d12c3a1dcdcf8f334d99ab10 Mon Sep 17 00:00:00 2001
From: Ties Stuij <ties.stuij at arm.com>
Date: Thu, 24 Sep 2026 13:42:50 +0100
Subject: [PATCH] [compiler-rt][ARM] Make interworking test compatible with BTI
In the aeabi_cmpflags_interwork_test.c test wrappers, we should return through
lr instead of r3 so that runs with BTI enabled don't fail. As returns through lr
don't require a landing pad, and returns through r3 do.
---
.../builtins/Unit/arm/aeabi_cmpflags_interwork_test.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/test/builtins/Unit/arm/aeabi_cmpflags_interwork_test.c b/compiler-rt/test/builtins/Unit/arm/aeabi_cmpflags_interwork_test.c
index 50c2dafeae2a81..e6e90c340b1739 100644
--- a/compiler-rt/test/builtins/Unit/arm/aeabi_cmpflags_interwork_test.c
+++ b/compiler-rt/test/builtins/Unit/arm/aeabi_cmpflags_interwork_test.c
@@ -6,6 +6,9 @@
// ARMv4T Thumb code can not read status register. These helpers call
// the EABI comparison functions and turn Z/C flags into numbers:
// -1 for less, 0 for equal, and 1 for greater or unordered
+//
+// We need to return through LR so BTI does not need a landing pad.
+// But as thumb-1 cannot pop into LR, we go through r3.
__asm__(".globl call_aeabi_cfcmple\n"
".thumb_func\n"
"call_aeabi_cfcmple:\n"
@@ -24,7 +27,8 @@ __asm__(".globl call_aeabi_cfcmple\n"
"3:\n"
" pop {r4}\n"
" pop {r3}\n"
- " bx r3\n"
+ " mov lr, r3\n"
+ " bx lr\n"
".globl call_aeabi_cdcmple\n"
".thumb_func\n"
@@ -44,7 +48,8 @@ __asm__(".globl call_aeabi_cfcmple\n"
"3:\n"
" pop {r4}\n"
" pop {r3}\n"
- " bx r3\n");
+ " mov lr, r3\n"
+ " bx lr\n");
extern int call_aeabi_cfcmple(float, float);
extern int call_aeabi_cdcmple(double, double);
More information about the llvm-commits
mailing list