<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 - Assertion on zero-byte type in -O0 AArch64 compile"
   href="https://bugs.llvm.org/show_bug.cgi?id=33191">33191</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion on zero-byte type in -O0 AArch64 compile
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>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>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>srhines@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>kristof.beyls@arm.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18523" name="attach_18523" title="Reduced test case for failed AArch64 compile">attachment 18523</a> <a href="attachment.cgi?id=18523&action=edit" title="Reduced test case for failed AArch64 compile">[details]</a></span>
Reduced test case for failed AArch64 compile

Running the following command on this source file results in an assertion
because each type is actually zero bytes, but the AArch64 backend doesn't seem
to handle all zero-byte types appropriately (at least not those that don't also
count as zero bytes for isEmptyRecord() in TargetInfo.cpp).

$ clang++ -std=c++14 --target=arm64-v8a -O0 -c t.cpp
...
clang++: external/llvm/lib/IR/Type.cpp:229: static llvm::IntegerType
*llvm::IntegerType::get(llvm::LLVMContext &, unsigned int): Assertion `NumBits
<span class="quote">>= MIN_INT_BITS && "bitwidth too small"' failed.</span >

The size (as reported) for the struct is indeed 0, yet isEmptyRecord() doesn't
flag it as being empty. This is because this is a record containing another
record, and according to comments in TargetInfo.cpp, C++ record fields are
never empty in the Itanium ABI.

I think the correct fix is to update the AArch64 functions (both for return
type and regular parameters) to handle a zero-byte aggregate, but I wanted to
make sure that there isn't a better reason to make
isEmptyRecord()/isEmptyField() do something better in this case (i.e. claim
that it is indeed empty, and force all the callers to handle the Itanium ABI
requirements themselves).</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>