This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Lowering of VLA's, part 2
Hello,
> > > The stack save should also go inside the BIND_EXPR, but before the
> > > TRY_FINALLY_EXPR.
> > >
> > > Also, you need to make sure that you don't add these again if the BIND_EXPR
> > > gets gimplified again.
> >
> > done. Just retesting it, ok if it passes?
>
> If you're going to get rid of VLAs, perhaps a subsequent patch could get
> rid of the code that deals with VLAs in find_hidden_use_vars_r.
I hoped so, but it turned out to be a bit problematic. Consider
void zzz ()
{
int z = 5;
struct { char a[z]; } x;
foo (x);
},
translated into
zzz ()
{
int z.1;
unsigned int z.2;
void * saved_stack.3;
int z;
struct
{
char a[(unsigned int)SAVE_EXPR <z.1>];
} x;
extern foo;
saved_stack.3 = __builtin_stack_save ();
try
{
z = 5;
z.1 = z;
z.2 = (unsigned int)z.1;
__builtin_stack_alloc (&x, z.2);
foo (x);
}
finally
{
__builtin_stack_restore (saved_stack.3)
};
}
Without hidden use of z.1 that protects it from being optimized out, it
becomes
zzz ()
{
void * saved_stack.3;
struct
{
char a[(unsigned int)SAVE_EXPR <z.1>];
} x;
extern foo;
saved_stack.3 = __builtin_stack_save ();
try
{
__builtin_stack_alloc (&x, 5);
foo (x);
}
finally
{
__builtin_stack_restore (saved_stack.3)
};
}
size of x now depends on non-existent variable z.1, which causes a crash
when an attempt to copy it before passing to foo is made.
Zdenek
- References:
- Re: [tree-ssa] Lowering of VLA's, second attempt
- Re: [tree-ssa] Lowering of VLA's, second attempt
- Re: [tree-ssa] Lowering of VLA's, second attempt
- Re: [tree-ssa] Lowering of VLA's, second attempt
- [tree-ssa] Lowering of VLA's, part 2
- Re: [tree-ssa] Lowering of VLA's, part 2
- Re: [tree-ssa] Lowering of VLA's, part 2
- Re: [tree-ssa] Lowering of VLA's, part 2
- Re: [tree-ssa] Lowering of VLA's, part 2
- Re: [tree-ssa] Lowering of VLA's, part 2