<div dir="ltr">On my (out-of-tree) target I have 16 128-bit registers.<div>Unaligned load/store are illegal. (must 16-bytes aligned)<br></div><div><br></div><div>8 of those registers are defined as callee-saved and 8 caller-saved.</div>
<div>The default stack size is 4 bytes.</div><div>The target implements dynamic stack realign to make sure the stack will always be aligned correctly when necessary.</div><div><br></div><div>Yet I am still getting unaligned load/store when running this test case:   <a href="http://pastie.org/8490604">http://pastie.org/8490604</a></div>
<div><br></div><div>The problem is in PEI::calculateCalleeSavedRegisters:</div><div><br></div><div><div>      // We may not be able to satisfy the desired alignment specification of</div><div>      // the TargetRegisterClass if the stack alignment is smaller. Use the</div>
<div>      // min.</div><div>      Align = std::min(Align, StackAlign);</div><div>      FrameIdx = MFI->CreateStackObject(RC->getSize(), Align, true);</div></div><div><br></div><div>This will create unaligned load/store for a callee-saved 128-bit register on the frame slot because StackAlign is 4.</div>
<div><br></div><div>Adding a check for stack realignable or putting all the 128-bit registers as caller-save will fix the problem.</div><div><div>    if (!TFI->isStackRealignable())      <--- new line</div><div>      Align = std::min(Align, StackAlign);</div>
</div><div><br></div><div><br></div><div>Is this a bug or am I missing something?</div><div><br></div><div>Thanks,</div><div>Francois Pichet, Octasic.<br></div></div>