This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add new built-in: __builtin_unreachable()


On Mon, Jun 8, 2009 at 2:34 PM, David Daney<ddaney@caviumnetworks.com> wrote:
> Ian Lance Taylor wrote:
>>
>> David Daney <ddaney@caviumnetworks.com> writes:
>>
>>> +@deftypefn {Built-in Function} void __builtin_unreachable (void)
>>> +This function is used to indicate to the compiler that control flow
>>> +will never reach the point of the @code{__builtin_unreachable}. ?If
>>> +control flow does reach @code{__builtin_unreachable}, program behavior
>>> +is undefined. ?The only valid use of this builtin is immediately
>>> +following an @code{asm} statement that either never exits or transfers
>>> +control elsewhere never returning.
>>
>> I have wanted __builtin_unreachable for a while, but never got around to
>> doing anything. ?But I only want it if it works in general, not just
>> after an asm statement. ?I think it should mean "if control flow reaches
>> this point, the program is undefined." ?Ideally there should be a
>> command line option to control it, so that it is possible to compile
>> __builtin_unreachable as expanding to abort, or something like that,
>> when debugging.
>>
>
> Ok, then how about this version? ?All my original commentary still applies:
> http://gcc.gnu.org/ml/gcc-patches/2009-06/msg00317.html
>
> I have added a new command line flag (-funreachable-traps) that causes
> __builtin_unreachable() to be expanded exactly as if it were a
> __builtin_trap().

I wouldn't add a new flag to do this.  In fact preprocessor wrapping
around the two builtins can do this.  Or was there a particular reason?

Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]