Closed dyung closed 1 year ago
Recently one of our internal tests started failing with a crash in the compiler which I bisected back to commit c80b503. Consider the following code:
void alpha(); float bravo, charlie, delta; void echo() { float foxtrot, gulf; hotel: gulf = foxtrot; india: foxtrot = gulf; gulf = charlie = delta / foxtrot; bravo = foxtrot / bravo * charlie; alpha(); if (delta) goto hotel; goto india; }
If that code is compiled with optimizations and AVX enabled using a compiler that contains the change in c80b503, it results in a crash in the compiler: https://godbolt.org/z/3fP9cedd6
Instruction does not dominate all uses! %11 = insertelement <2 x float> %2, float %9, i64 0, !dbg !27 %10 = shufflevector <2 x float> %11, <2 x float> %6, <2 x i32> <i32 0, i32 2>, !dbg !27 in function _Z4echov fatal error: error in backend: Broken function found, compilation aborted! 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-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O2 -c -mavx <source> 1. <eof> parser at end of file 2. Code generation 3. Running pass 'Function Pass Manager' on module '<source>'. 4. Running pass 'Module Verifier' on function '@_Z4echov' #0 0x0000000003738928 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3738928) #1 0x00000000037365ec llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x37365ec) #2 0x000000000367f506 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x367f506) #3 0x000000000372d93e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x372d93e) #4 0x0000000000beee0a LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0 #5 0x0000000003689ea3 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3689ea3) #6 0x000000000368a008 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x368a008) #7 0x0000000003156c12 (anonymous namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&) Verifier.cpp:0:0 #8 0x00000000030babf9 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x30babf9) #9 0x00000000030bae31 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x30bae31) #10 0x00000000030bb652 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x30bb652) #11 0x00000000039ad592 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) BackendUtil.cpp:0:0 #12 0x00000000039ada39 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-assertions-trunk/bin/clang+++0x39ada39) #13 0x00000000049a785f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49a785f) #14 0x0000000005eadc99 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5eadc99) #15 0x00000000049a6a48 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49a6a48) #16 0x00000000042093e9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42093e9) #17 0x000000000418a88e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x418a88e) #18 0x00000000042e856e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42e856e) #19 0x0000000000bf1086 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbf1086) #20 0x0000000000be894a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0 #21 0x0000000003fe67a9 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 0x000000000367f444 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x367f444) #23 0x0000000003fe6d9f 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 0x0000000003faef65 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3faef65) #25 0x0000000003faf9cd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3faf9cd) #26 0x0000000003fb78f5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fb78f5) #27 0x0000000000bee52c clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbee52c) #28 0x0000000000ae8281 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xae8281) #29 0x00007f1f3428d083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083) #30 0x0000000000be842e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbe842e) clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation) Compiler returned: 70
@valerydmit this was your change that seems to have caused the issue, can you take a look?
I think it is fixed already.
I had reverted the original change, so unless someone recomitted the original change with a fix, it would not be fixed.
Fixed with #70111
Recently one of our internal tests started failing with a crash in the compiler which I bisected back to commit c80b503. Consider the following code:
If that code is compiled with optimizations and AVX enabled using a compiler that contains the change in c80b503, it results in a crash in the compiler: https://godbolt.org/z/3fP9cedd6
@valerydmit this was your change that seems to have caused the issue, can you take a look?