[llvm-dev] Redundant load in llvm's codegen compares to gcc when accessing escaped pointer?

Chuang-Yu Cheng via llvm-dev llvm-dev at lists.llvm.org
Tue Mar 22 08:41:35 PDT 2016


Reply from Michael:

&x points to the start of object x, and &x - something (something != 0)
points outside object x.  'c' was a complete object, so &c-8 points
outside any object, hence the formation of that pointer is already
invalid (as is its dereference).

https://gcc.gnu.org/ml/gcc/2016-03/msg00185.html

>>On Fri, Mar 18, 2016 at 8:46 AM, Daniel Berlin <dberlin at dberlin.org> wrote:
>>
>>    I *think the argument* goes that this is a 20 or 24 byte object, so if you *could* put something of type PB at c-8, you'd illegally overlap with the object at c.
>>
>>    Thus, there can't be an object of type PB at c-8.
>>
>>    (IE any valid object must be sizeof(PB) away in either direction, which means it's not possible for c->f1_ to clobber c no matter what bar does)

>>> We discussed this issue briefly on the #gcc IRC channel.
>>> Richard Biener pointed out that bar cannot make c point to &c - 8,
>>> because computing that pointer would be invalid. So c->f1_ cannot
>>> clobber c itself.
>>>
>>> --
>>> Markus


More information about the llvm-dev mailing list