<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 - ARM crash when using `__sync_bool_compare_and_swap`"
   href="https://bugs.llvm.org/show_bug.cgi?id=51313">51313</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ARM crash when using `__sync_bool_compare_and_swap`
          </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>All
          </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>Backend: ARM
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nathan@lanza.io
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, smithp352@googlemail.com, Ties.Stuij@arm.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>With the input file `input.c`

```
struct {
  int h;
  int i;
  int j;
} g;

k() {
  __sync_bool_compare_and_swap(&g.i, 0, 1);
  if (g.j)
    ;
}
```

and compilation:

```
$ clang -cc1 -triple thumbv7-none-linux-android16 -emit-obj input.c
```

Here is the crash:

```
clang:
/home/lanza/Projects/llvm-project/llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp:1651:
bool (anonymous
namespace)::ARMExpandPseudo::ExpandCMP_SWAP(llvm::MachineBasicBlock &,
MachineBasicBlock::iterator, unsigned int, unsigned int, unsigned int,
MachineBasicBlock::iterator &): Assertion
`ARM::tGPRRegClass.contains(DesiredReg) && "DesiredReg used for UXT op must be
tGPR"' failed.
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang -cc1 -triple thumbv7-none-linux-android16
-emit-obj test.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'test.c'.
4.      Running pass 'ARM pseudo instruction expansion pass' on function '@k'
 #0 0x00007fdf5c19c4ea llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/home/lanza/Projects/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:11
 #1 0x00007fdf5c19c69b PrintStackTraceSignalHandler(void*)
/home/lanza/Projects/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
 #2 0x00007fdf5c19aeb3 llvm::sys::RunSignalHandlers()
/home/lanza/Projects/llvm-project/llvm/lib/Support/Signals.cpp:97:5
 #3 0x00007fdf5c19ccd5 SignalHandler(int)
/home/lanza/Projects/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007fdf639bca20 __restore_rt (/lib64/libpthread.so.0+0x13a20)
 #5 0x00007fdf5ba062a2 raise (/lib64/libc.so.6+0x3d2a2)
 #6 0x00007fdf5b9ef8a4 abort (/lib64/libc.so.6+0x268a4)
 #7 0x00007fdf5b9ef789 _nl_load_domain.cold (/lib64/libc.so.6+0x26789)
 #8 0x00007fdf5b9fea16 (/lib64/libc.so.6+0x35a16)
 #9 0x00007fdf63f0456e (anonymous
namespace)::ARMExpandPseudo::ExpandCMP_SWAP(llvm::MachineBasicBlock&,
llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, unsigned int,
unsigned int, unsigned int,
llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>&)
/home/lanza/Projects/llvm-project/llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp:1652:3
#10 0x00007fdf63effe2b (anonymous
namespace)::ARMExpandPseudo::ExpandMI(llvm::MachineBasicBlock&,
llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>,
llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>&)
/home/lanza/Projects/llvm-project/llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp:2938:9
#11 0x00007fdf63efa167 (anonymous
namespace)::ARMExpandPseudo::ExpandMBB(llvm::MachineBasicBlock&)
/home/lanza/Projects/llvm-project/llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp:3003:17
#12 0x00007fdf63ef9fad (anonymous
namespace)::ARMExpandPseudo::runOnMachineFunction(llvm::MachineFunction&)
/home/lanza/Projects/llvm-project/llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp:3021:17
#13 0x00007fdf62008f47
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
/home/lanza/Projects/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:72:8
#14 0x00007fdf5d5cb98e llvm::FPPassManager::runOnFunction(llvm::Function&)
/home/lanza/Projects/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1439:23
#15 0x00007fdf5d5d0752 llvm::FPPassManager::runOnModule(llvm::Module&)
/home/lanza/Projects/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1485:16
#16 0x00007fdf5d5cc279 (anonymous
namespace)::MPPassManager::runOnModule(llvm::Module&)
/home/lanza/Projects/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1554:23
#17 0x00007fdf5d5cbded llvm::legacy::PassManagerImpl::run(llvm::Module&)
/home/lanza/Projects/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:542:16
#18 0x00007fdf5d5d0a31 llvm::legacy::PassManager::run(llvm::Module&)
/home/lanza/Projects/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1681:3
#19 0x00007fdf62a8a872 (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::__1::unique_ptr<llvm::raw_pwrite_stream,
std::__1::default_delete<llvm::raw_pwrite_stream> >)
/home/lanza/Projects/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1501:3
#20 0x00007fdf62a883d7 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef,
llvm::Module*, clang::BackendAction,
std::__1::unique_ptr<llvm::raw_pwrite_stream,
std::__1::default_delete<llvm::raw_pwrite_stream> >)
/home/lanza/Projects/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1660:5
#21 0x00007fdf630c86a7
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
/home/lanza/Projects/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:334:7
#22 0x00007fdf5702b671 clang::ParseAST(clang::Sema&, bool, bool)
/home/lanza/Projects/llvm-project/clang/lib/Parse/ParseAST.cpp:178:12
#23 0x00007fdf5f9c7bec clang::ASTFrontendAction::ExecuteAction()
/home/lanza/Projects/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1060:1
#24 0x00007fdf630c29b0 clang::CodeGenAction::ExecuteAction()
/home/lanza/Projects/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1045:5
#25 0x00007fdf5f9c75ec clang::FrontendAction::Execute()
/home/lanza/Projects/llvm-project/clang/lib/Frontend/FrontendAction.cpp:955:7
#26 0x00007fdf5f8e7d61
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/lanza/Projects/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:974:23
#27 0x00007fdf63994c1e
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/lanza/Projects/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:8
#28 0x0000000000237713 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /home/lanza/Projects/llvm-project/clang/tools/driver/cc1_main.cpp:246:13
#29 0x000000000022a56b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/home/lanza/Projects/llvm-project/clang/tools/driver/driver.cpp:338:5
#30 0x00000000002297a5 main
/home/lanza/Projects/llvm-project/clang/tools/driver/driver.cpp:409:5
#31 0x00007fdf5b9f0b75 __libc_start_main (/lib64/libc.so.6+0x27b75)
#32 0x0000000000228ffe _start
(/home/lanza/Projects/llvm-project/build/Debug/bin/clang-14+0x228ffe)
fish: Job 1, 'clang -cc1 -triple thumbv7-noneā€¦' terminated by signal SIGABRT
(Abort)
```

The offending patch is <a href="https://reviews.llvm.org/D101898">https://reviews.llvm.org/D101898</a>. Reverting it has my
company's toolchain working properly so far.</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>