[llvm] r177055 - PR14972: SROA vs. GVN exposed a really bad bug in SROA.

Duncan Sands baldrick at free.fr
Mon May 13 09:23:46 PDT 2013


Hi Chandler,

On 14/03/13 12:32, Chandler Carruth wrote:
> Author: chandlerc
> Date: Thu Mar 14 06:32:24 2013
> New Revision: 177055
>
> URL: http://llvm.org/viewvc/llvm-project?rev=177055&view=rev
> Log:
> PR14972: SROA vs. GVN exposed a really bad bug in SROA.
>
> The fundamental problem is that SROA didn't allow for overly wide loads
> where the bits past the end of the alloca were masked away and the load
> was sufficiently aligned to ensure there is no risk of page fault, or
> other trapping behavior. With such widened loads, SROA would delete the
> load entirely rather than clamping it to the size of the alloca in order
> to allow mem2reg to fire. This was exposed by a test case that neatly
> arranged for GVN to run first, widening certain loads, followed by an
> inline step, and then SROA which miscompiles the code. However, I see no
> reason why this hasn't been plaguing us in other contexts. It seems
> deeply broken.

I think I recall you arguing on IRC that, on the contrary, loading off the
end of an alloca is undefined behaviour, whether it is aligned or not.  Did
you change your mind or did I misunderstand?  As an alternative, how about
having GVN widen allocas when it does this.  Or is it a general transform
that doesn't know if there is an alloca underneath or not?

Ciao, Duncan.



More information about the llvm-commits mailing list