<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/125626>125626</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
crash when compiling with emit-cir and fsanitize=undefined
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
midnightveil
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/azdrjn3Wf
```
clang version 20.0.0git (https://github.com/llvm/clangir.git c4e58420474090601b9419159ad3343ffb530c34)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-clangir-trunk-20250201/bin
Build config: +assertions
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
(in-process)
"/opt/compiler-explorer/clang-clangir-trunk-20250201/bin/clang-20" -cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -clear-ast-before-backend -main-file-name example.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/app -v -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-clangir-trunk-20250201/lib/clang/20 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward -internal-isystem /opt/compiler-explorer/clang-clangir-trunk-20250201/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -fclangir -emit-cir -mllvm --x86-asm-syntax=intel -fsanitize=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr -fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr -fsanitize-merge=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr -fno-sanitize-memory-param-retval -fno-sanitize-address-use-odr-indicator -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /app/output.s -x c++ <source>
clang -cc1 version 20.0.0git based upon LLVM 20.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward
/opt/compiler-explorer/clang-clangir-trunk-20250201/lib/clang/20/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
NYI
UNREACHABLE executed at /root/llvm-project/clang/lib/CIR/CodeGen/CIRGenFunction.cpp:1170!
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-clangir-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S -Xclang -fclangir -fcolor-diagnostics -fno-crash-diagnostics -Xclang -emit-cir -v -fsanitize=undefined <source>
1. <eof> parser at end of file
2. <source>:2:5: LLVM IR generation of declaration 'main'
#0 0x0000000002e67b9b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x2e67b9b)
#1 0x0000000002e65104 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x2e65104)
#2 0x0000000002dac710 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000077f9a3242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000077f9a32969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000077f9a3242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000077f9a32287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000000002db857a (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x2db857a)
#8 0x000000000474e500 clang::CIRGen::CIRGenFunction::StartFunction(clang::GlobalDecl, clang::QualType, cir::FuncOp, clang::CIRGen::CIRGenFunctionInfo const&, clang::CIRGen::FunctionArgList const&, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x474e500)
#9 0x0000000004751618 clang::CIRGen::CIRGenFunction::generateCode(clang::GlobalDecl, cir::FuncOp, clang::CIRGen::CIRGenFunctionInfo const&) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x4751618)
#10 0x0000000004683d18 clang::CIRGen::CIRGenModule::emitGlobalFunctionDefinition(clang::GlobalDecl, mlir::Operation*) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x4683d18)
#11 0x0000000004688027 clang::CIRGen::CIRGenModule::emitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x4688027)
#12 0x0000000004688547 clang::CIRGen::CIRGenModule::emitTopLevelDecl(clang::Decl*) (.part.0) CIRGenModule.cpp:0:0
#13 0x0000000004668083 cir::CIRGenerator::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x4668083)
#14 0x00000000045017ac cir::CIRGenConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x45017ac)
#15 0x0000000006955694 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x6955694)
#16 0x0000000003b2e9d3 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x3b2e9d3)
#17 0x0000000003aab326 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x3aab326)
#18 0x0000000003c15c4e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x3c15c4e)
#19 0x0000000001116d64 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x1116d64)
#20 0x000000000110dbe0 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#21 0x0000000003860799 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
#22 0x0000000002dacb72 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x2dacb72)
#23 0x0000000003862b4e 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
#24 0x000000000381d47b clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x381d47b)
#25 0x000000000381e4ef clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x381e4ef)
#26 0x000000000382a914 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x382a914)
#27 0x0000000001112ea2 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x1112ea2)
#28 0x00000000010026b3 main (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x10026b3)
#29 0x000077f9a3229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#30 0x000077f9a3229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#31 0x000000000110d205 _start (/opt/compiler-explorer/clang-clangir-trunk/bin/clang+++0x110d205)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzseltz27iS_6eBX1BQkSB1e_ADI1mZTGXOzD_Of87ukwoEmxSOQYAFgLI8n34LIGWSiu2MZ5RTu7WbcmwKbDR-fUFfADFrRaUAbtH8A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