[llvm-bugs] [Bug 52129] New: [MIPS][microMIPS] Clang fatal error with __atomic_store_n() and microMIPS

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Oct 10 12:16:33 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52129

            Bug ID: 52129
           Summary: [MIPS][microMIPS] Clang fatal error with
                    __atomic_store_n() and microMIPS
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: jesse.a.deguire at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 25346
  --> https://bugs.llvm.org/attachment.cgi?id=25346&action=edit
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211010/01479aea/attachment.html>


More information about the llvm-bugs mailing list