Commit graph

3 commits

Author SHA1 Message Date
Craig Barnes
cb9c13800e Fix performance regression caused by xassert() macro
Before this commit, the xassert() macro still expanded to e.g.:

    if (unlikely(!(cond)))
        __builtin_unreachable();

...even when NDEBUG was set.

If `cond` happened to contain a function call that the compiler couldn't
prove to be side-effect free, this call would still have to be emitted
in the generated code, even when everything else could be optimized out.

This commit changes xassert() to be more in-keeping with the standard
assert() macro when NDEBUG is set; specifically, it causes the entire
statement to expand to nothing, which thus guarantees that any function
calls in the condition will be dropped, regardless of whether or not
they have side-effects.
2021-02-06 00:53:29 +00:00
Craig Barnes
e56136ce11 debug: rename assert() to xassert(), to avoid clashing with <assert.h> 2021-01-16 20:16:00 +00:00
Craig Barnes
22f25a9e4f Print stack trace on assert() failure or when calling fatal_error()
Note: this uses the __sanitizer_print_stack_trace() function from the
AddressSanitizer runtime, so it only works when AddressSanitizer is
in use.
2021-01-16 19:56:33 +00:00