<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 --- - AArch64 cannot self-host on ELF targets (ABI for bool is dodgy)"
   href="http://llvm.org/bugs/show_bug.cgi?id=19850">19850</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>AArch64 cannot self-host on ELF targets (ABI for bool is dodgy)
          </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>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>Backend: AArch64
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>t.p.northover@gmail.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>The AArch64 (née ARM64) backend fails many tests when self-hosting at -O0. The
issue appears to be over who takes responsibility for extending bool types and
by how much.

The AAPCS could really do with a clarification note here, but my interpretation
is that (unlike all other types), the *caller* should extend it to 1 byte (i.e.
ensure that the low byte is either 0 or 1). The callee is responsible for any
junk in the higher bits (as with i8, i16 and small structs).

On Darwin, of course, the caller needs to extend to the full 32-bits, as with
other types.

Looking at the LangRef, I think this means two things need to happen:

1. Preferably Clang should mark i1 arguments as "zeroext", so that LLVM makes
sure the caller does so "to the extent required by the target’s ABI"
(tautological as that is). Both ABIs do require extension of some kind for this
type.

2. LLVM needs to mark i1 arguments as extended to i8 on Linux, to i32 on
Darwin.

There's some highly suspect code in LowerFormalArguments that looks like it may
have been intended to deal with something like this but *never* triggers
because of a miscommunication with AArch64CallingConv.h. The actual extension
on Darwin platforms is taken care of by SelectionDAGBuilder.cpp.

I'll need to come up with a way to repurpose that code as neatly as possible.
Currently it wants to produce a "CopyFromReg -> AssertZExt(i1) -> Trunc(i1)",
but that wouldn't represent the AAPCS situation even if it did trigger (the
AssertZExt node would extend to the full i32). We might want "CopyFromReg ->
Trunc(i8) -> AssertZExt(i1)" instead, but I need to think.</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>