<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Thu, Sep 10, 2015 at 7:27 PM John McCall <<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div>On Sep 10, 2015, at 16:09, Chandler Carruth <<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>> wrote:</div><div><br></div><blockquote type="cite"><div><div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">On Thu, Sep 10, 2015 at 3:26 PM John McCall <<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>> wrote:<br></div><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><blockquote type="cite"><div>On Sep 10, 2015, at 3:22 PM, Chandler Carruth <<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>> wrote:</div><br><div><div dir="ltr">I've reproduced this with the same technique.<div><br></div><div>John, let me know if you need help debugging this, but this is blocking a ton of stuff for us so I'm going to revert for now.</div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div>Please just give me a chance to fix; it is probably straightforward, and the change is invasive enough that you’ll have to revert the last three days of changes to IRGen.</div></div></blockquote><div><br></div><div>I mean, I'd love to avoid the revert, but were totally hosed at the moment by this change (perhaps our fault for so much code managing to use a silly jpeg library). I'm going to at least start working on teasing this stuff apart in parallel, and hopefully you'll have a fix soon. While we're going to need to revert to green before too long, I'll update here before doing anything. Also happy to chat on IRC if there is anything I can do to help.</div></div></div></div></blockquote><div><br></div></div><div dir="auto">For those following along at home, we tracked this down to some assembly that's not following the x86-64 ABI correctly.<div><br></div><div>Clang is emitting a pair of adjacent 32-bit loads. With my patch, the first is now marked with alignment 8; LLVM deduces that the loads can be combined. Later, the first value is passed as an argument to a function, and LLVM places the combined load in the argument register without clearing the high bits; this is legal as those bits have no guaranteed value under the ABI. The callee, which is written in assembly, then uses the full register as an index into an array without zero-extending it first.</div></div></blockquote><div><br></div><div>Another note is that I'm going to keep an eye out for any other assembly we run into making similar assumptions, but after digging into the project, it appears that most of this is likely a historical error for a single type.</div><div><br></div><div>And I just want to say *many* thanks for the assistance understanding this error John (and David, Art, Richard, and everyone else)... It was not at all easy to really pinpoint the nature of this problem, and made more confusing by the fact that the ABI seems silent about this (despite the clear behavior of multiple implementations).</div><div><br></div><div>-Chandler</div></div></div>