<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><html>On Mar 30, 2008, at 10:21 AM, Chris Lattner wrote:</html><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Mar 28, 2008, at 5:17 PM, Chuck Rose III wrote:</div><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div lang="EN-US" link="blue" vlink="purple"><div class="Section1"><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 12pt; font-family: 'Times New Roman'; "><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; ">I was curious about the state of stack alignment on x86. I noticed there are a few bugs outstanding on the issue. I recently added some code which had the effect of throwing an extra function parameter on our stack at runtime, a 4 byte pointer. <o:p></o:p></span></font></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 12pt; font-family: 'Times New Roman'; "><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; "><o:p> </o:p></span></font></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 12pt; font-family: 'Times New Roman'; "><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; ">Esp is now not 16-byte aligned, so instructions like unpcklps xmm1, dword ptr [eps] cause grief. My AllocaInstr instructions are told to be 16 byte aligned, so the addition of a 4-byte parameter shouldn’t have changed alignment on the objects.<o:p></o:p></span></font></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 12pt; font-family: 'Times New Roman'; "><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; "><o:p></o:p></span></font></div></div></div></span></blockquote><div><br class="webkit-block-placeholder"></div><div>Hi Chuck,</div><div><br class="webkit-block-placeholder"></div><div>I think the basic problem is that the stack pointer on windows/linux is not guaranteed to be 16 byte aligned. This means that any use of an instruction which requires 16-byte alignment (e.g. sse stuff) and accesses a frameindex can cause a problem. The issue is that the frameindex will be marked as needing 16+ byte alignment, but the code generator just won't respect this.</div><div><br class="webkit-block-placeholder"></div><div>The fix for this is somewhat simple: in Prolog/Epilog Insertion, the PEI pass should notice when frame indices have alignment greater than the guaranteed stack alignment. When this happens, it should emit code into the prolog to dynamically align the stack (e.g. by emitting 'and esp, -16').</div></div></div></blockquote><div><br></div>This only works if frame pointer is not being omitted. Otherwise, you can't restore to the old stack pointer in the epilogue. So X86RegisterInfo::hasFP() must return true for Windows when any of the frame slots have alignment greater than the default alignment.</div><div><br></div><div>Evan</div><div><br></div><div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><br class="webkit-block-placeholder"></div><div>This doesn't occur on the mac, because the stack is always guaranteed to be 16-byte aligned.</div><div><br class="webkit-block-placeholder"></div><div>-Chris</div></div></div>_______________________________________________<br>LLVM Developers mailing list<br>LLVMdev@cs.uiuc.edu <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></body></html>