John Regehr on Nostr: here's a silly C function that LLVM can (correctly) optimize into just a return ...
here's a silly C function that LLVM can (correctly) optimize into just a return instruction: https://gcc.godbolt.org/z/93c9nnsjb
but, on my Mac, the assert gets expanded to include a builtin_expect:
(__builtin_expect(!(a), 0) ? __assert_rtn(__func__, "test.c", 7, "a") : (void)0);
clang turns that into an LLVM assume(), which ends up getting in the way of the optimization that makes the function go away. so, precisely the opposite of the intended effect!! ugh.
but, on my Mac, the assert gets expanded to include a builtin_expect:
(__builtin_expect(!(a), 0) ? __assert_rtn(__func__, "test.c", 7, "a") : (void)0);
clang turns that into an LLVM assume(), which ends up getting in the way of the optimization that makes the function go away. so, precisely the opposite of the intended effect!! ugh.