<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - X86CallFrameOptimization wrongly assumes '= COPY %esp' is right after ADJCALLSTACKDOWN"
   href="https://bugs.llvm.org/show_bug.cgi?id=34903">34903</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>X86CallFrameOptimization wrongly assumes '= COPY %esp' is right after ADJCALLSTACKDOWN
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>zvi.rackover@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>SelectionDAG inserts a copy of ESP into a virtual register.
X86CallFrameOptimization assumes that the COPY, if present, is always
right after the call-frame setup instruction (ADJCALLSTACKDOWN). This is a
wrong assumption as the COPY can be located anywhere between the call-frame
setup instruction and its first use. If the COPY happened to be located in a
different location than what X86CallFrameOptimization assumed, visiting it
while processing the call chain would lead to a conservative bail-out.

Here's an example of .mir captured from movtopush.ll, function 'test9'. You can
see that the instruction '%3 = copy %esp' is *not* located immediately after
the adjcallstackdown32 instruction:

     callstackdown32 16, 0, 0, implicit-def dead %esp, implicit-def dead
%eflags, implicit %esp
     %0 = copy %esp
     mov32mi %0, 1, _, 12, _, 4 :: (store 4 into stack + 12)
     mov32mi %0, 1, _, 8, _, 3 :: (store 4 into stack + 8)
     mov32mi %0, 1, _, 4, _, 2 :: (store 4 into stack + 4)
     mov32mi %0, 1, _, 0, _, 1 :: (store 4 into stack)
     callpcrel32 @good, csr_32, implicit %esp, implicit-def %esp
     adjcallstackup32 16, 0, implicit-def dead %esp, implicit-def dead %eflags,
implicit %esp
     adjcallstackdown32 20, 0, 0, implicit-def dead %esp, implicit-def dead
%eflags, implicit %esp
     %1 = mov32rm %stack.2.s, 1, _, 0, _ :: (load 4 from %stack.2.s, align 8)
     %2 = mov32rm %stack.2.s, 1, _, 4, _ :: (load 4 from %stack.2.s + 4)
     %3 = copy %esp
     mov32mr %3, 1, _, 4, _, killed %2 :: (store 4)
     mov32mr %3, 1, _, 0, _, killed %1 :: (store 4)
     %4 = lea32r %stack.0.p, 1, _, 0, _
     mov32mr %3, 1, _, 16, _, killed %4 :: (store 4 into stack + 16)
     %5 = lea32r %stack.1.q, 1, _, 0, _
     mov32mr %3, 1, _, 12, _, killed %5 :: (store 4 into stack + 12)
     mov32mi %3, 1, _, 8, _, 6 :: (store 4 into stack + 8)
     callpcrel32 @struct, csr_32, implicit %esp, implicit-def %esp
     adjcallstackup32 20, 0, implicit-def dead %esp, implicit-def dead %eflags,
implicit %esp
     ret 0</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>