[compiler-rt] a11d1cc - [builtins] Use mcr for dmb instruction on armv6
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 10 19:30:06 PST 2022
Author: Khem Raj
Date: 2022-03-10T19:30:00-08:00
New Revision: a11d1cc41c725ec6dee58f75e4a852a658dd7543
URL: https://github.com/llvm/llvm-project/commit/a11d1cc41c725ec6dee58f75e4a852a658dd7543
DIFF: https://github.com/llvm/llvm-project/commit/a11d1cc41c725ec6dee58f75e4a852a658dd7543.diff
LOG: [builtins] Use mcr for dmb instruction on armv6
At present compiler-rt cross compiles for armv6 ( -march=armv6 ) but includes
dmb instructions which are only available in armv7+ this causes SIGILL on
clang+compiler-rt compiled components on rpi0w platforms.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D99282
Added:
Modified:
compiler-rt/lib/builtins/arm/sync-ops.h
compiler-rt/lib/builtins/assembly.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/builtins/arm/sync-ops.h b/compiler-rt/lib/builtins/arm/sync-ops.h
index c9623249e5d20..7a26170741ad2 100644
--- a/compiler-rt/lib/builtins/arm/sync-ops.h
+++ b/compiler-rt/lib/builtins/arm/sync-ops.h
@@ -19,14 +19,14 @@
.thumb; \
.syntax unified; \
DEFINE_COMPILERRT_THUMB_FUNCTION(__sync_fetch_and_##op) \
- dmb; \
+ DMB; \
mov r12, r0; \
LOCAL_LABEL(tryatomic_##op) : ldrex r0, [r12]; \
op(r2, r0, r1); \
strex r3, r2, [r12]; \
cmp r3, #0; \
bne LOCAL_LABEL(tryatomic_##op); \
- dmb; \
+ DMB; \
bx lr
#define SYNC_OP_8(op) \
@@ -35,14 +35,14 @@
.syntax unified; \
DEFINE_COMPILERRT_THUMB_FUNCTION(__sync_fetch_and_##op) \
push {r4, r5, r6, lr}; \
- dmb; \
+ DMB; \
mov r12, r0; \
LOCAL_LABEL(tryatomic_##op) : ldrexd r0, r1, [r12]; \
op(r4, r5, r0, r1, r2, r3); \
strexd r6, r4, r5, [r12]; \
cmp r6, #0; \
bne LOCAL_LABEL(tryatomic_##op); \
- dmb; \
+ DMB; \
pop { r4, r5, r6, pc }
#define MINMAX_4(rD, rN, rM, cmp_kind) \
diff --git a/compiler-rt/lib/builtins/assembly.h b/compiler-rt/lib/builtins/assembly.h
index 69a3d8620f924..06aa18162e3b4 100644
--- a/compiler-rt/lib/builtins/assembly.h
+++ b/compiler-rt/lib/builtins/assembly.h
@@ -189,6 +189,14 @@
JMP(ip)
#endif
+#if __ARM_ARCH >= 7
+#define DMB dmb
+#elif __ARM_ARCH >= 6
+#define DMB mcr p15, #0, r0, c7, c10, #5
+#else
+#error only supported on ARMv6+
+#endif
+
#if defined(USE_THUMB_2)
#define WIDE(op) op.w
#else
More information about the llvm-commits
mailing list