[llvm-bugs] [Bug 52357] New: Broken tail call generation for X32 ABI
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 29 12:32:49 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=52357
Bug ID: 52357
Summary: Broken tail call generation for X32 ABI
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: CONFIRMED
Severity: normal
Priority: P
Component: Backend: X86
Assignee: harald at gigawatt.nl
Reporter: harald at gigawatt.nl
CC: craig.topper at gmail.com, glaubitz at physik.fu-berlin.de,
llvm-bugs at lists.llvm.org, llvm-dev at redking.me.uk,
pengfei.wang at intel.com, spatel+llvm at rotateright.com
$ cat bug.c
typedef struct {
char a;
int b;
void (*c)(void);
} d;
d e(void);
void g(int f) {
if (f) {
d h = e();
h.c();
}
}
$ clang -c -O2 -mx32 bug.c
fatal error: error in backend: Cannot emit physreg copy instruction
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: clang -c -O2 -mx32 bug.c
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'bug.c'.
4. Running pass 'Post-RA pseudo instruction expansion pass' on function
'@g'
#0 0xfffffffff3fa4c02 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/home/harald/llvm-project/llvm/lib/Support/Unix/Signals.inc:569:3
#1 0xfffffffff3fa2fe0 llvm::sys::RunSignalHandlers()
/home/harald/llvm-project/llvm/lib/Support/Signals.cpp:97:20
#2 0xfffffffff3ec7b6b HandleCrash
/home/harald/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:74:27
#3 0xfffffffff3ec7b6b llvm::CrashRecoveryContext::HandleExit(int)
/home/harald/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:440:20
#4 0xfffffffff3f9db6c llvm::sys::Process::ExitNoCleanup(int)
/home/harald/llvm-project/llvm/lib/Support/Unix/Process.inc:464:62
#5 0xfffffffff3f9db6c llvm::sys::Process::Exit(int, bool)
/home/harald/llvm-project/llvm/lib/Support/Process.cpp:100:18
#6 0x00410e80 clang::DiagnosticsEngine::Report(clang::SourceLocation, unsigned
int) /home/harald/llvm-project/clang/include/clang/Basic/Diagnostic.h:1525:3
#7 0x00410e80 clang::DiagnosticsEngine::Report(clang::SourceLocation, unsigned
int) /home/harald/llvm-project/clang/include/clang/Basic/Diagnostic.h:1523:26
#8 0x00410e80 clang::DiagnosticsEngine::Report(unsigned int)
/home/harald/llvm-project/clang/include/clang/Basic/Diagnostic.h:1537:41
#9 0x00410e80 LLVMErrorHandler(void*, char const*, bool)
/home/harald/llvm-project/clang/tools/driver/cc1_main.cpp:64:15
#10 0xfffffffff3edb75e std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >::~basic_string()
/usr/lib/gcc/x86_64-linux-gnux32/11.2.0/include/c++/bits/basic_string.h:671:19
#11 0xfffffffff3edb75e llvm::report_fatal_error(llvm::Twine const&, bool)
/home/harald/llvm-project/llvm/lib/Support/ErrorHandling.cpp:104:36
#12 0xfffffffff3edb87f
(/home/harald/llvm-project/build/bin/../lib/libLLVMSupport.so.14git+0xae87f)
#13 0xfffffffff7cb74af
llvm::X86InstrInfo::copyPhysReg(llvm::MachineBasicBlock&,
llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::DebugLoc
const&, llvm::MCRegister, llvm::MCRegister, bool) const
/home/harald/llvm-project/llvm/lib/Target/X86/X86InstrInfo.cpp:3605:21
#14 0xfffffffff6747070 llvm::MachineInstr::getNumOperands() const
/home/harald/llvm-project/llvm/include/llvm/CodeGen/MachineInstr.h:492:44
#15 0xfffffffff6747070 LowerCopy
/home/harald/llvm-project/llvm/lib/CodeGen/ExpandPostRAPseudos.cpp:169:25
#16 0xfffffffff6747070 (anonymous
namespace)::ExpandPostRA::runOnMachineFunction(llvm::MachineFunction&)
/home/harald/llvm-project/llvm/lib/CodeGen/ExpandPostRAPseudos.cpp:214:32
#17 0xfffffffff686d80a
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0)
/home/harald/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:72:33
#18 0xfffffffff46c2585 llvm::FPPassManager::runOnFunction(llvm::Function&)
/home/harald/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1449:7
#19 0xfffffffff46c2771 llvm::ilist_node_base<true>::getNext() const
/home/harald/llvm-project/llvm/include/llvm/ADT/ilist_node_base.h:43:45
#20 0xfffffffff46c2771
llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Function, true,
false, void> >::getNext()
/home/harald/llvm-project/llvm/include/llvm/ADT/ilist_node.h:66:66
#21 0xfffffffff46c2771
llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, true,
false, void>, false, false>::operator++()
/home/harald/llvm-project/llvm/include/llvm/ADT/ilist_iterator.h:157:25
#22 0xfffffffff46c2771 llvm::FPPassManager::runOnModule(llvm::Module&)
/home/harald/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1484:22
#23 0xfffffffff46c2f14 runOnModule
/home/harald/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1561:7
#24 0xfffffffff46c2f14 llvm::legacy::PassManagerImpl::run(llvm::Module&)
/home/harald/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:542:55
#25 0xfffffffff6e3da99 llvm::PrettyStackTraceString::~PrettyStackTraceString()
/home/harald/llvm-project/llvm/include/llvm/Support/PrettyStackTrace.h:72:9
#26 0xfffffffff6e3da99 RunCodegenPipeline
/home/harald/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1505:53
#27 0xfffffffff6e3da99 EmitAssembly
/home/harald/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1536:21
#28 0xfffffffff6e3da99 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef,
llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
/home/harald/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1698:27
#29 0xfffffffff71a955f std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >::~unique_ptr()
/usr/lib/gcc/x86_64-linux-gnux32/11.2.0/include/c++/bits/unique_ptr.h:360:12
#30 0xfffffffff71a955f
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
/home/harald/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:370:24
#31 0xfffffffff1cc7030 clang::ParseAST(clang::Sema&, bool, bool)
/home/harald/llvm-project/clang/lib/Parse/ParseAST.cpp:171:34
#32 0xfffffffff5e6c96c clang::FrontendAction::Execute()
/home/harald/llvm-project/clang/lib/Frontend/FrontendAction.cpp:967:21
#33 0xfffffffff5e08334 llvm::Error::setChecked(bool)
/home/harald/llvm-project/llvm/include/llvm/Support/Error.h:304:22
#34 0xfffffffff5e08334 llvm::Error::operator bool()
/home/harald/llvm-project/llvm/include/llvm/Support/Error.h:236:15
#35 0xfffffffff5e08334
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/harald/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1030:42
#36 0xfffffffff74cdae1
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/harald/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:262:32
#37 0x00411d43 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
/home/harald/llvm-project/clang/tools/driver/cc1_main.cpp:246:40
#38 0x0040f214 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/home/harald/llvm-project/clang/tools/driver/driver.cpp:317:20
#39 0xfffffffff5bdb139 operator()
/home/harald/llvm-project/clang/lib/Driver/Job.cpp:405:32
#40 0xfffffffff5bdb139 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'()>(int)
/home/harald/llvm-project/llvm/include/llvm/ADT/STLExtras.h:177:52
#41 0xfffffffff3ec7a40
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
/home/harald/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:426:10
#42 0xfffffffff5bdba44
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)
/home/harald/llvm-project/clang/lib/Driver/Job.cpp:409:10
#43 0xfffffffff5baf1bb
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
/home/harald/llvm-project/clang/lib/Driver/Compilation.cpp:197:3
#44 0xfffffffff5baf95b
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
/home/harald/llvm-project/clang/lib/Driver/Compilation.cpp:249:5
#45 0xfffffffff5bbb464 llvm::SmallVectorBase<unsigned int>::empty() const
/home/harald/llvm-project/llvm/include/llvm/ADT/SmallVector.h:73:47
#46 0xfffffffff5bbb464
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
/home/harald/llvm-project/clang/lib/Driver/Driver.cpp:1554:28
#47 0x0040d15a main
/home/harald/llvm-project/clang/tools/driver/driver.cpp:492:5
#48 0xfffffffff39641be __libc_start_call_main libc-start.c:0:0
#49 0xfffffffff396426a __libc_start_main at GLIBC_2.16
(/lib/x86_64-linux-gnux32/libc.so.6+0x1f26a)
#50 0x0040e772 _start (/home/harald/llvm-project/build/bin/clang-14+0x40e772)
clang-14: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
clang version 14.0.0 (https://github.com/llvm/llvm-project
6c2f26a159ec0a68d16424cc8aadd8801c7ef31d)
Target: x86_64-unknown-linux-gnux32
Thread model: posix
InstalledDir: /home/harald/llvm-project/build/bin
clang-14: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-14: note: diagnostic msg: /tmp/bug-2fa77e.c
clang-14: note: diagnostic msg: /tmp/bug-2fa77e.sh
clang-14: note: diagnostic msg:
********************
CC @glaubitz, although this is not a regression, this was never handled
correctly on X32 before, the exact tail call opportunities picked up by various
versions of LLVM is different, so this can cause (meaning: I did notice)
problems after upgrading to LLVM 13.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211029/2265d0fb/attachment-0001.html>
More information about the llvm-bugs
mailing list