On 02/06/2018 02:38 AM, Aldy Hernandez wrote:
> The -Walloca pass can receive a malformed alloca, courtesy of someone
> providing a faulty prototype.  This was causing an ICE because we
> assumed alloca calls had at least one argument, which the testcase does
> not:
> 
> +void *alloca ();
> +__typeof__(alloca ()) a () { return alloca (); }
> 
> I don't believe it should be the responsibility of the
> -Walloca-larger-than=* pass to warn against such things, so I propose we
> just ignore this.
> 
> I also think we should handle this testcase, regardless of the target
> having an alloca builtin, since the testcase includes its own
> prototype.  Thus, the missing "{dg-require-effect-target alloca}".
Wouldn't it make more sense to put the argument check into
gimple_alloca_call_p that way all callers are insulated?

After all if the alloca doesn't have an argument it probably doesn't
have the semantics of alloca that we expect -- like returning nonzero.

And if we look at vr-values.c:gimple_stmt_nonzero_p we see that it calls
gimple_alloca_call_p and if it returns true, then we assume the call
always returns a nonzero value.   Fixing gimple_alloca_call_p would take
care of both problems at once.

OK with that change.

jeff

Reply via email to