[llvm] r219899 - TRE: make TRE a bit more aggressive

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Oct 17 13:57:28 PDT 2014


>> Maybe I'm misunderstanding, but I really think this is fine. Specifically
>> I claim your error is on the clause "allocated on the current stack frame".
>> It's not allocated on the current stack frame, it's allocated on the stack
>> frame one above us.
>
>
> This is just the classic ambiguity of "who's frame are the arguments in?"
> 'byval' lets you capture the address of your arguments, sometimes. That
> argument stack space is reused to set up the arguments to the next call.
> Suppose that TCE did occur in the example you give, you would see this code
> for foo on regular x86, which has no register parameters:
>
> foo:
>   pushl ebp
>   leal 8(%esp), %eax ; take address of x
>   movl %eax, 8(%esp) ; store address of x into argument slot for tail call
>   popl ebp
>   jmp bar
>
> And now we've overwritten the contents of x.

But this is a case the backend can (and does) avoid, no? The issue
with this patch is that it violates IR level guarantees. We can change
the IR, but to do that we need to update other passes too.

Cheers,
Rafael



More information about the llvm-commits mailing list