"Zack Weinberg" <[EMAIL PROTECTED]> writes:

> Back in 2000 I wrote a really simple patch that caused gcc to treat an
> ASM_OPERANDS that clobbered "pc" as a control flow barrier, exactly
> for this problem.
> 
> http://gcc.gnu.org/ml/gcc-patches/2000-01/msg00190.html
> 
> I still think it was a good idea, but at the time it was received
> unenthusiastically.  I especially think "just use __builtin_trap()"
> misses the mark - at least some variants of the Linux kernel's BUG()
> macro, for instance, want to stick annotations in the assembly stream,
> which you cannot do with __builtin_trap...

I think we should just introduce __builtin_unreachable(), as others
have suggested.  I think that is more consonant with our usual
approach to these issues.

I also think it would be good to have one option affecting it: turn
__builtin_unreachable() into an abort(), or turn it into a "cannot be
reached" marker.  I think the former should be the default at -O0, the
latter at -O1 and above.

Note that a "cannot be reached" marker permits further optimization to
delete code which leads up to it.  Actually implementing that further
optimization may call for adding appropriate warnings, probably
controlled by -Wunreachable-code.

Ian

Reply via email to