diff --git a/mfbt/Assertions.h b/mfbt/Assertions.h index b9e9b4fc8cac..611c2b4eb6fe 100644 --- a/mfbt/Assertions.h +++ b/mfbt/Assertions.h @@ -53,9 +53,13 @@ MOZ_END_EXTERN_C #if defined(MOZ_HAS_MOZGLUE) || defined(MOZILLA_INTERNAL_API) static inline void AnnotateMozCrashReason(const char* reason) { gMozCrashReason = reason; - // See bug 1681846, on 32-bit Android ARM the compiler removes the store to - // gMozCrashReason if this barrier is not present. - asm volatile("" ::: "memory"); + // The following assembly fakes a memory read/write to the compiler, which + // prevents the removal of gMozCrashReason store. See bug 1681846 and 1945507. +# if defined(__clang__) + asm volatile("" : "+r,m"(gMozCrashReason) : : "memory"); +# else + asm volatile("" : "+m,r"(gMozCrashReason) : : "memory"); +# endif } # define MOZ_CRASH_ANNOTATE(...) AnnotateMozCrashReason(__VA_ARGS__) #else