<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/60740>60740</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Attempt to define a global register variable on AArch64 results in a ICE
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          AntonBikineev
      </td>
    </tr>
</table>

<pre>
    GCC [supports](https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/Global-Register-Variables.html) defining (i.e. reserving) `register` variables in namespace scope. An attempt to do this in clang:
```
register long bar asm("x28");

long foo() {
    return bar;
}
```
results in:
```
fatal error: error in backend: Invalid register name "x28".
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -S -target aarch64-linux-gnu --gcc-toolchain=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu --sysroot=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot -fcolor-diagnostics -fno-crash-diagnostics <source>
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '<source>'.
4.      Running pass 'AArch64 Instruction Selection' on function '@_Z3foov'
 #0 0x0000557fbac7099f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bc099f)
 #1 0x0000557fbac6e9cc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bbe9cc)
 #2 0x0000557fbabc2147 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b12147)
 #3 0x0000557fbac66632 llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bb6632)
 #4 0x0000557fb843c09f (/opt/compiler-explorer/clang-trunk/bin/clang+++0x138c09f)
 #5 0x0000557fbabcafca llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b1afca)
 #6 0x0000557fb853a835 llvm::AArch64TargetLowering::getRegisterByName(char const*, llvm::LLT, llvm::MachineFunction const&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x148a835)
 #7 0x0000557fbbdf851c llvm::SelectionDAGISel::Select_READ_REGISTER(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4d4851c)
 #8 0x0000557fbbdfca8a llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4d4ca8a)
 #9 0x0000557fb851d9fd (anonymous namespace)::AArch64DAGToDAGISel::Select(llvm::SDNode*) AArch64ISelDAGToDAG.cpp:0:0
#10 0x0000557fbbdf7ba7 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4d47ba7)
#11 0x0000557fbbe03899 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4d53899)
#12 0x0000557fbbe0661f llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4d5661f)
#13 0x0000557fbbe08d0f llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#14 0x0000557fb9fe5780 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x0000557fba4f8bf0 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3448bf0)
#16 0x0000557fba4f8d69 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3448d69)
#17 0x0000557fba4f9950 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3449950)
#18 0x0000557fbb041a52 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f91a52)
#19 0x0000557fbbf55169 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4ea5169)
#20 0x0000557fbd1b6079 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6106079)
#21 0x0000557fbbf54725 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4ea4725)
#22 0x0000557fbb82c481 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x477c481)
#23 0x0000557fbb7ae7d3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x46fe7d3)
#24 0x0000557fbb90ff2b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x485ff2b)
#25 0x0000557fb843d4cc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x138d4cc)
#26 0x0000557fb8438acf ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x0000557fbb60d44d void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#28 0x0000557fbabc2037 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b12037)
#29 0x0000557fbb60d68c clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#30 0x0000557fbb5d561c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x452561c)
#31 0x0000557fbb5d600d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x452600d)
#32 0x0000557fbb5e045c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x453045c)
#33 0x0000557fb843b5a2 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x138b5a2)
#34 0x0000557fb833dba5 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0x128dba5)
#35 0x00007f4b968aa083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#36 0x0000557fb8434c0e _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0x1384c0e)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWktzqzgW_jVko7ILxHuRBbGTdLpu903FmV7MxnUQgmgCEiOJPP79lADHiNg3t3vo2UzVvYmNpKPvfOfoPBRAKVZxSi-d8MoJtxfQ6SchLzOuBb9iz4xT-nKRi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