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

    <tr>
        <th>Summary</th>
        <td>
            __builtin_thread_pointer() on x86-64 clang 12.0.1 fatal error
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    [See this godbolt link.](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:48,endLineNumber:7,positionColumn:48,positionLineNumber:7,selectionStartColumn:48,selectionStartLineNumber:7,startColumn:48,startLineNumber:7),source:'%23include+%3Ccstdint%3E%0A%23include+%3Ccstddef%3E%0A%23include+%3Ciostream%3E%0A%0Aint+main(int+argc,+char+*+argv%5B%5D)+%7B%0A++++size_t+x+%3D+(size_t)__builtin_thread_pointer()%3B%0A++++std::cout+%3C%3C+std::hex+%3C%3C+%220x%22+%3C%3C+x+%3C%3C+%22%5Cn%22%3B%0A%7D%0A'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:37.91887125220458,l:'4',m:100,n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:clang1201,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'0',trim:'1'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'-O1',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+12.0.1+(Editor+%231)',t:'0')),header:(),k:35.90637067712829,l:'4',m:19.578942936241432,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'armv8-a+clang+(trunk,+all+architectural+features)',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+12.0.1+(Compiler+%231)',t:'0')),header:(),l:'4',m:80.42105706375857,n:'0',o:'',s:0,t:'0')),k:62.08112874779541,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)

```
fatal error: error in backend: Cannot select: intrinsic %llvm.thread.pointer
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-12.0.1/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-11.1.0 -fcolor-diagnostics -fno-crash-diagnostics -O1 <source>
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '<source>'.
4.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@_ZL18_mi_prim_thread_idv'
 #0 0x000055814816f991 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x319e991)
 #1 0x000055814816d754 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x319c754)
 #2 0x000055814816d9f1 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x319c9f1)
 #3 0x00005581480d66c8 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x31056c8)
 #4 0x00005581481663c2 llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x31953c2)
 #5 0x0000558145f58ac4 LLVMErrorHandler(void*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0xf87ac4)
 #6 0x00005581480dc5cc llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x310b5cc)
 #7 0x00005581480dc744 (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x310b744)
 #8 0x0000558149032be7 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x4061be7)
 #9 0x000055814903603a llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x406503a)
#10 0x0000558146e83218 (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x1eb2218)
#11 0x0000558149031820 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x4060820)
#12 0x000055814903c359 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x406b359)
#13 0x000055814903ef62 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x406df62)
#14 0x00005581490419be llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x40709be)
#15 0x0000558146e8ce0d (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x1ebbe0d)
#16 0x0000558147513e6c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x2542e6c)
#17 0x000055814792c880 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x295b880)
#18 0x000055814792deb9 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x295ceb9)
#19 0x000055814792bad0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x295aad0)
#20 0x0000558148453be5 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x3482be5)
#21 0x0000558149158cd9 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x4187cd9)
#22 0x000055814a0a29e9 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x50d19e9)
#23 0x00005581491579b6 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x41869b6)
#24 0x0000558148ab1ad1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x3ae0ad1)
#25 0x0000558148a4eedb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x3a7dedb)
#26 0x0000558148b83970 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x3bb2970)
#27 0x0000558145f59601 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0xf88601)
#28 0x0000558145f56bcb ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0xf85bcb)
#29 0x00005581488f52b9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::'lambda'()>(long) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x39242b9)
#30 0x00005581480d6547 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x3105547)
#31 0x00005581488f5db6 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (.part.0) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x3924db6)
#32 0x00005581488ca24c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x38f924c)
#33 0x00005581488cac69 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x38f9c69)
#34 0x00005581488d63a1 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0x39053a1)
#35 0x0000558145e9942a main (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0xec842a)
#36 0x00007fe193629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#37 0x00007fe193629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#38 0x0000558145f5675e _start (/opt/compiler-explorer/clang-12.0.1/bin/clang+++0xf8575e)
clang-12: error: clang frontend command failed with exit code 70 (use -v to see invocation)
ASM generation compiler returned: 70
fatal error: error in backend: Cannot select: intrinsic %llvm.thread.pointer
clang-12: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Execution build compiler returned: 70
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzk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