[PATCH] Fix unsafe function attributes for special functions (PR 71876)

Bernd Edlinger bernd.edlinger@hotmail.de
Wed Jul 20 16:30:00 GMT 2016


On 07/20/16 18:15, Jeff Law wrote:
> On 07/20/2016 05:53 AM, Richard Biener wrote:
>>> Is it OK after boot-strap and regression-testing?
>>
>> I think the __builtin_setjmp change is wrong - __builtin_setjmp is
>> _not_ 'setjmp' it is part of the GCC internal machinery (using setjmp
>> and longjmp in the end) for SJLJ exception handing.
>>
>> Am I correct Eric?
> That is correct.  __builtin_setjmp (and friends) are part of the SJLJ
> exception handling code.   They use a fixed sized buffer (5 words) to
> store the key items (as opposed to the OS defined jmp_buf structure
> which is usually considerably larger).
>
> jeff

Yes. __builtin_setjmp is declared in builtins.def:

DEF_GCC_BUILTIN        (BUILT_IN_SETJMP, "setjmp", BT_FN_INT_PTR, 
ATTR_NOTHROW_LEAF_LIST)

It is visible in C as __builtin_setjmp, and it special_function_p
adds the ECF_RETURNS_TWICE | ECF_LEAF.

So it becomes equivalent to this:

int __builtin_setjmp(void*) __attribute__((returns_twice, nothrow,
leaf))

after special_function_p does it's magic.

If I remove the recognition of "__builtin_" from special_function_p
I have to add the returns_twice attribute in the DEF_GCC_BUILTIN.
Otherwise, I would get wrong code on all platforms, because
__builtin_setjmp saves only IP, SP, and FP registers.

Everything in the normal test suite keeps on going with the patch,
but is there anything that I have to do to make sure that the
SJLJ eh is still working? It is not the default on x86_64, right?



Bernd.



More information about the Gcc-patches mailing list