<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 --- - aarch64 backend uses x18 on ios"
   href="https://llvm.org/bugs/show_bug.cgi?id=24588">24588</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>aarch64 backend uses x18 on ios
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>other
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>andrew.b.adams@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14780" name="attach_14780" title="A chunk of ll large enough to demonstrate the issue">attachment 14780</a> <a href="attachment.cgi?id=14780&action=edit" title="A chunk of ll large enough to demonstrate the issue">[details]</a></span>
A chunk of ll large enough to demonstrate the issue

This is a minor complaint, but it produces a very hard-to-debug error.

If you compile some .ll with a target triple aarch64-ios, then the aarch64
backend will happily use x18, even though that's reserved by the system on this
platform.

This causes crashes due to register-stomping. Clang avoids this by setting the
additional flag -mattr=+reserve-x18, but having IOS in the target triple seems
like it should be enough.

To reproduce, compile the attached .ll like so:

llc -mtriple aarch64-ios initmod.opengl_64.ll -filetype=asm -o - | grep x18
    orr    w0, wzr, #0x18
    orr    w0, wzr, #0x18
    ldrsw    x18, [x22, #40]
    lsl    x18, x18, #1
    add     x5, x5, x18
    ldrsw    x18, [x22, #40]
    lsl    x18, x18, #2
    add     x5, x5, x18
    ldrsw    x18, [x21, #40]
    lsl    x18, x18, #1
    add     x3, x3, x18
    ldrsw    x18, [x21, #40]
    lsl    x18, x18, #2
    add     x3, x3, x18
    sxtw    x18, w18
    str    w3, [x1, x18, lsl #2]

If you add -mattr=+reserve-x18, it does the right thing.

There's nothing very special about the attached ll - any sufficiently large
piece of ll should reproduce this.</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>