<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [ARM Backend]Rewinding to first LDR/VLDRD should use reverse_iterator when emitting epiloge"
   href="http://llvm.org/bugs/show_bug.cgi?id=18136">18136</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[ARM Backend]Rewinding to first LDR/VLDRD should use reverse_iterator when emitting epiloge
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>zhaoshiz@codeaurora.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, t.p.northover@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Given an MBB like this, currently LLVM stops at t2LDMIA_RET.

(gdb) call MBB.dump()
BB#52: derived from LLVM BB %return
    Predecessors according to CFG: BB#0 BB#51
    %SP<def,tied1> = VLDMDIA_UPD %SP<tied0>, pred:14, pred:%noreg, %D8<def>,
%D9<def>, %D10<def>, %D11<def>, %D12<def>
    %SP<def,tied1> = t2LDMIA_RET %SP<tied0>, pred:14, pred:%noreg, %R4<def>,
%R5<def>, %R6<def>, %R7<def>, %R8<def>, %R9<def>, %R10<def>, %R11<def>,
%PC<def>

lib/Target/ARM/ARMFrameLowering.cpp:385
    // Unwind MBBI to point to first LDR / VLDRD.
    const uint16_t *CSRegs = RegInfo->getCalleeSavedRegs(&MF);
    if (MBBI != MBB.begin()) {
      do {
        if (isPopOpcode(MBBI->getOpcode()))
          FirstPop = MBBI;

        --MBBI;
      } while (MBBI != MBB.begin() && isCSRestore(MBBI, TII, CSRegs));
      if (!isCSRestore(MBBI, TII, CSRegs))
        ++MBBI;
    }

With MinSize attribute (-Oz), folding SP update into pop results in misaligned
register values stored in stack.

<span class="quote">>     aa6:       b001            add     sp, #4
>     aa8:   ecbd 8b0a       vpop    {d8-d12}
>     aac:   e8bd 8ff0       ldmia.w sp!, {r4, r5, r6, r7, r8, r9, sl, fp, pc}</span >

becomes:

<span class="quote">>     a9e:       ecbd 8b0a       vpop    {d8-d12}
>     aa2:   e8bd 8ff8       ldmia.w sp!, {r3, r4, r5, r6, r7, r8, r9, sl, fp, pc}</span >

Related bug: <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - [ARM Backend] Flag -Oz corrupted by folding SP update into push/pop"
   href="show_bug.cgi?id=18081">http://llvm.org/bugs/show_bug.cgi?id=18081</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>