76 lines
3.6 KiB
Diff
76 lines
3.6 KiB
Diff
From a11d1cc41c725ec6dee58f75e4a852a658dd7543 Mon Sep 17 00:00:00 2001
|
|
From: Khem Raj <raj.khem@gmail.com>
|
|
Date: Thu, 10 Mar 2022 19:30:00 -0800
|
|
Subject: [PATCH] [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
|
|
---
|
|
compiler-rt/lib/builtins/arm/sync-ops.h | 8 ++++----
|
|
compiler-rt/lib/builtins/assembly.h | 8 ++++++++
|
|
2 files changed, 12 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/lib/builtins/arm/sync-ops.h b/lib/builtins/arm/sync-ops.h
|
|
index c9623249e5d20..7a26170741ad2 100644
|
|
--- a/lib/builtins/arm/sync-ops.h
|
|
+++ b/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/lib/builtins/assembly.h b/lib/builtins/assembly.h
|
|
index 69a3d8620f924..06aa18162e3b4 100644
|
|
--- a/lib/builtins/assembly.h
|
|
+++ b/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
|
|
|