diff --git a/compiler-rt/lib/builtins/arm/sync-ops.h b/compiler-rt/lib/builtins/arm/sync-ops.h --- 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 --- 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