<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 - [MIPS][microMIPS] Clang fatal error with __atomic_store_n() and microMIPS"
   href="https://bugs.llvm.org/show_bug.cgi?id=52129">52129</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[MIPS][microMIPS] Clang fatal error with __atomic_store_n() and microMIPS
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jesse.a.deguire@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=25346" name="attach_25346" title="Full crash message and files it request I submit.">attachment 25346</a> <a href="attachment.cgi?id=25346&action=edit" title="Full crash message and files it request I submit.">[details]</a></span>
Full crash message and files it request I submit.

int main()
{
    volatile int flag = 1;
    __atomic_store_n(&flag, 0, __ATOMIC_RELAXED);
//    __atomic_store_n(&flag, 0, __ATOMIC_RELEASE);
//    __atomic_store_n(&flag, 0, __ATOMIC_SEQ_CST);

//    __atomic_load_n(&flag, __ATOMIC_RELAXED);
//    __atomic_load_n(&flag, __ATOMIC_ACQUIRE);
//    __atomic_load_n(&flag, __ATOMIC_SEQ_CST);
}

Building a file with only the above causes a fatal error when using microMIPS
mode. Here is the command I was using:

  clang -target mipsel-gnu-linux-musl -march=mips32r2 -mmicromips -c ./file.c

Here is the error given when the crash occurs:

  fatal error: error in backend: Cannot select: 0x721ec10: ch =
AtomicStore<(volatile store monotonic (s32) into %ir.1)> 0x721eba8:1,
FrameIndex:i32<0>, 0x721eba8
    0x721e938: i32 = FrameIndex<0>
    0x721eba8: i32,ch = load<(dereferenceable load (s32) from %ir.2)>
0x721eb40, FrameIndex:i32<1>, undef:i32
      0x721ead8: i32 = FrameIndex<1>
      0x721ea08: i32 = undef

I'll attach a ZIP file containing the full stack trace and a couple of other
files the error said to attach.

I originally ran across this when trying to build libc++ for microMIPS mode and
managed to simplify the error case down to the above code. Any of the three
__atomic_store_n() calls above will cause the crash. Removing the "-mmicromips"
option builds without error. Using one of the __atomic_load_n() functions
instead of the __atominc_store_n() seems to not crash and produce reasonable
output using the "sync" instruction.

Playing with the above code on Compiler Explorer using the Clang installs
provided there (the x86 versions seemed to have been build with all targets
supported) suggests that the above code started crashing as of Clang 7.0. Clang
6.0.1 appears to work and generate reasonable assembly.</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>