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] PR middle-end/19774


Ian Lance Taylor wrote:
> Josh Conner <jconner@apple.com> writes:
> 
>> SJLJ exception handling is incompatible with alloca (and hence,
>> variable-length arrays).  A function which calls alloca and then catches
>> an exception may discover upon catching that the alloca'd memory has
>> been corrupted.
>>
>> ...
> 
> As Steven says, insn notes are considered to be declasse.  And I'm not
> crazy about new register notes either.

OK.

> And I don't understand how
> your solution will work for C99 dynamically sized arrays.

It works because variable-length arrays are created using
builtin_alloca.  It solved my original test case, which was a VLA in C++
code -- am I missing something obvious?

> Look at the code for SETJMP_VIA_SAVE_AREA in
> allocate_dynamic_stack_space.  That shows how you can adjust the
> alloca request to avoid space on the stack frame.  I think you can add
> something like that in the USING_SJLJ_EXCEPTIONS case, for cases where
> you will need to catch an exception.  If you do that it should work
> for all cases which can call allocate_dynamic_stack_space.

I can look into this some more -- I'm not sure that I have enough
information in allocate_dynamic_stack_space to make this decision.

> This is a more complex solution.  But I'm pretty sure your solution
> will not work reliably over time, because there is really nothing to
> tie the insn note to the stack allocation.  It only works today
> because exception handling is done shortly after expansion.

That makes sense.  I'll see what other alternatives I can come up with.

Thanks for the quick review -

Josh


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