diff --git a/mfbt/Assertions.h b/mfbt/Assertions.h index 45e1b830cf58..d12096977c05 100644 --- a/mfbt/Assertions.h +++ b/mfbt/Assertions.h @@ -210,13 +210,13 @@ MOZ_NoReturn(int aLine) { # define MOZ_REALLY_CRASH(line) \ do { \ *((volatile int*)MOZ_CRASH_WRITE_ADDR) = line; /* NOLINT */ \ - ::abort(); \ + MOZ_NOMERGE ::abort(); \ } while (false) # else # define MOZ_REALLY_CRASH(line) \ do { \ *((volatile int*)MOZ_CRASH_WRITE_ADDR) = line; /* NOLINT */ \ - abort(); \ + MOZ_NOMERGE abort(); \ } while (false) # endif #endif diff --git a/mfbt/Attributes.h b/mfbt/Attributes.h index d6e6293066ef..4d6768cf37fa 100644 --- a/mfbt/Attributes.h +++ b/mfbt/Attributes.h @@ -88,6 +88,22 @@ # endif #endif +/** + * Per clang's documentation: + * + * If a statement is marked nomerge and contains call expressions, those call + * expressions inside the statement will not be merged during optimization. This + * attribute can be used to prevent the optimizer from obscuring the source + * location of certain calls. + * + * This is useful to have clearer information on assertion failures. + */ +#if defined(__clang__) && __has_attribute(nomerge) +# define MOZ_NOMERGE __attribute__((nomerge)) +#else +# define MOZ_NOMERGE +#endif + /* * MOZ_NEVER_INLINE is a macro which expands to tell the compiler that the * method decorated with it must never be inlined, even if the compiler would