> Do you have any test cases?  I'm pretty sure this works, at least in
> the usual cases.

They're going to be hard to construct since they are sensitive to such
things as the number of registers saved.

> A wild guess says that you're doing this in Ada.  It may be something
> specific to the nested case then.

It is in Ada, but I don't think the nested case is the cause of the
particular problem I ran into (it does need to be fixed anyway, though,
since it might bite later).  I suspect the case we're running into is
either the args to push or the registers saved.

Here's a description of the miscompilation we saw:

> Specifically, in Ada.Text_IO.Put_Line, we end up calling memcpy
> with a buffer allocated using "alloca". The alloca result
> is aligned to a multiple of 8, but the corresponding operation
> on the stack pointer is eliminated because combine assumes
> the stack is aligned already.
> 
> Specifically, in the example below, the assignment to
> Buffer (1 .. Ilen) is done through memcpy, but
> memcpy overwrites the return address.
> 
>  From a-textio.adb, around line 1450:
> 
>        --  Now prepare the string with its terminator
> 
>        declare
>           Buffer : String (1 .. Ilen + 2);
>           Plen   : size_t;
> 
>        begin
>           Buffer (1 .. Ilen) := Item (Istart .. Item'Last);
>           Buffer (Ilen + 1) := Character'Val (LM);

When you look at the disassembled code, we saw an update to the stack
pointer in the prologue of a number that wasn't a multiple of 8 (it
was 36, if I remember correctly).

Reply via email to