Open wierton opened 1 year ago
When compiling below code with clangtk -O0, clangtk crashes:
clangtk -O0
clangtk
void f(int x) { if (x) { register int a1 asm("18") = x; register int a2 asm("19") = x; asm("" : : "r"(a1)); asm("" : : "r"(a2)); } }
The output of clangtk, (can be verified at the link https://gcc.godbolt.org/z/EzG9zeM4P):
<source>:5:9: error: couldn't allocate input reg for constraint '{fpcr}' asm("" : : "r"(a1)); ^ fatal error: error in backend: Cannot emit physreg copy instruction 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 --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 -xc <source> 1. <eof> parser at end of file 2. Code generation 3. Running pass 'Function Pass Manager' on module '<source>'. 4. Running pass 'Post-RA pseudo instruction expansion pass' on function '@f' #0 0x00005620fa4d3b9f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3616b9f) #1 0x00005620fa4d1bcc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3614bcc) #2 0x00005620fa421597 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3564597) #3 0x00005620fa4c97c2 llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x360c7c2) #4 0x00005620f7d56d86 (/opt/compiler-explorer/clang-trunk/bin/clang+0xe99d86) #5 0x00005620fa42a58a llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x356d58a) #6 0x00005620fa42a71e (/opt/compiler-explorer/clang-trunk/bin/clang+0x356d71e) #7 0x00005620f9328e5c llvm::X86InstrInfo::copyPhysReg(llvm::MachineBasicBlock&, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::DebugLoc const&, llvm::MCRegister, llvm::MCRegister, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x246be5c) #8 0x00005620f9c56fd9 (anonymous namespace)::ExpandPostRA::runOnMachineFunction(llvm::MachineFunction&) ExpandPostRAPseudos.cpp:0:0 #9 0x00005620f9946f10 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0 #10 0x00005620f9e65c7a llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2fa8c7a) #11 0x00005620f9e65e09 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2fa8e09) #12 0x00005620f9e669f0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2fa99f0) #13 0x00005620fa7444b0 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+0x38874b0) #14 0x00005620fb65268c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x479568c) #15 0x00005620fca22139 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b65139) #16 0x00005620fb651745 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4794745) #17 0x00005620faf35bb1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4078bb1) #18 0x00005620faeb98b3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3ffc8b3) #19 0x00005620fb014ae3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4157ae3) #20 0x00005620f7d5830c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xe9b30c) #21 0x00005620f7d53a0f ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0 #22 0x00005620fad162dd 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 #23 0x00005620fa421487 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3564487) #24 0x00005620fad1651c 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 #25 0x00005620facddf5e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e20f5e) #26 0x00005620facde92d 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+0x3e2192d) #27 0x00005620face8ffc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e2bffc) #28 0x00005620f7d55f0f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xe98f0f) #29 0x00005620f7c53255 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xd96255) #30 0x00007f13160b9083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083) #31 0x00005620f7d4fcee _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xe92cee) clang: error: clang frontend command failed with exit code 70 (use -v to see invocation) Compiler returned: 70
@llvm/issue-subscribers-backend-x86
When compiling below code with
clangtk -O0
,clangtk
crashes:The output of
clangtk
, (can be verified at the link https://gcc.godbolt.org/z/EzG9zeM4P):