<html>
    <head>
      <base href="https://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 --- - MISched does not handle function arguments in tail calling functions correctly"
   href="https://llvm.org/bugs/show_bug.cgi?id=23459">23459</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>MISched does not handle function arguments in tail calling functions correctly
          </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>All
          </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>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>aschwaighofer@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ cat test_tail_call_rol.c 

void callee2(void *a0, void *a1, void *a2, void *a3, void *a4, void *a5, void
*a6, void *a7, void *a8, void *a9, void *a10, void *a11, void *a12,
             void *a13, void *a14, void *a15, void *a16, void *a17, void *a18,
void *a19, void *a20, void *a21, void *a22, void *a23, void *a24, void *a25,
             void *a26, void *a27, void *a28, void *a29, void *a30, void *a31,
void *a32, void *a33);



void caller2(void *a0, void *a1, void *a2, void *a3, void *a4, void *a5, void
*a6, void *a7, void *a8, void *a9, void *a10, void *a11, void *a12,
            void *a13, void *a14, void *a15, void *a16, void *a17, void *a18,
void *a19, void *a20, void *a21, void *a22, void *a23, void *a24, void *a25,
            void *a26, void *a27, void *a28, void *a29, void *a30, void *a31,
void *a32, void *a33) {
  callee2(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12,
          a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25,
          a26, a27, a28, a29, a30, a31, a32, a33, a0);
}

$ bin/clang -target arm64-apple-ios -O test_tail_call_rol.c -S -o - -mllvm
--aarch64-load-store-opt=false

_caller2:                               ; @caller2
; BB#0:                                 ; %entry
        str     x0, [sp, #200] <== Upsy daisy we trashed the old value.
        ldr      x8, [sp]
        ldr     x9, [sp, #200]
...

The problem is two fold:
1.) MI->isInvariantLoad returns true for stack argument locations. This is not
true when we are tail calling. A tail call clobbers its incoming argument area.
2.) The code in ScheduleDAGInstrs::buildSchedGraph assumes that two distinct
PseudoSourceValues can't alias. For tail calls this assumption is again not
correct. Two FixedStackPseudoSourceValues can refer to the same location.</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>