Re: CFR: a new __unreachable() builtin
2015-05-13 18:09 GMT+02:00 David Chisnall : > LLVM uses this quite heavily, in a macro that expands to something equivalent > to assert(0 && "unreachable reached!”) in debug mode and > __builtin_unreachable() in release mode. When you’re debugging, you get > errors if you reach unreachable code and in deployment the compiler gets a > useful hint for optimisation. Too bad we can't use this trick in our own assert(). You'd need to define assert() like this: #define assert(expr) do { \ if (!(expr)) \ __builtin_unreachable(); \ } while (0) Unfortunately, this would cause the expression to be evaluated, which is not allowed. -- Ed Schouten ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: CFR: a new __unreachable() builtin
On 13 May 2015, at 17:05, Pedro Giffuni wrote: > > Hello; > > I am looking at the cdefs in other BSDs hoping to avoid adopting the > same definitions with incompatible names and I noticed NetBSD is using > a new __builtin_unreachable (void) function from gcc 4.6: > > https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html > > Apparently it was interesting enough that clang implemented it too so > I created a code review differential for it. > > https://reviews.freebsd.org/D2536 > > I don't want to add new C definitions unless they are going to be used > so feel free to comment on the convenience or not of having it. LLVM uses this quite heavily, in a macro that expands to something equivalent to assert(0 && "unreachable reached!”) in debug mode and __builtin_unreachable() in release mode. When you’re debugging, you get errors if you reach unreachable code and in deployment the compiler gets a useful hint for optimisation. David ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
CFR: a new __unreachable() builtin
Hello; I am looking at the cdefs in other BSDs hoping to avoid adopting the same definitions with incompatible names and I noticed NetBSD is using a new __builtin_unreachable (void) function from gcc 4.6: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html Apparently it was interesting enough that clang implemented it too so I created a code review differential for it. https://reviews.freebsd.org/D2536 I don't want to add new C definitions unless they are going to be used so feel free to comment on the convenience or not of having it. Pedro. ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"