On Fri, Dec 16, 2011 at 6:08 PM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com">kcc@google.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><blockquote type="cite"><div class="gmail_quote">
<div>In this case, we have an array of 22 bytes which is 16-aligned. </div><div>
I suspect that load widening changed the alignment of alloca instruction to make the transformation legal. Right? </div><div>Can we change the load widening algorithm to also change the size of alloca instruction to be dividable by 16? </div>
<div>This will solve the problem, at least the variant I observe now. </div></div></blockquote><br></div></div><div>I believe it is 16-byte aligned based on ABI requirements for x86-64, though you're right that the optimizer will increase alignment in other cases. In any case, we don't want to increase the size of the object, because that would prevent packing some other data in after it. For example, a 2-byte aligned 10 byte object can be placed after it in memory if we keep it 22-bytes in size.</div>
</div></blockquote><div><br></div></div><div>ok.</div><div><br></div><div>I wonder if the load widening can attach some metadata to the stack objects, accesses to which it has modified? </div><div>Then asan will increase the alloca size as appropriate (it does it anyway).</div>
<div><br></div></div></blockquote><div><br></div><div>This doesn't seem like a general solution. What if there is some heap allocated buffer proven to be 16 byte aligned, but 22 bytes long? Load widening may occur, but you won't be able to fudge the size.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div></div><div>Why you don't like the idea to disable or restrict the widening when asan is on?</div>
</div></blockquote><div><br></div><div>I agree this seems reasonable.</div><div><br></div><div>Reid</div></div>