<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_CONFIRMED "
title="CONFIRMED - Broken tail call generation for X32 ABI"
href="https://bugs.llvm.org/show_bug.cgi?id=52357">52357</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Broken tail call generation for X32 ABI
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>CONFIRMED
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>harald@gigawatt.nl
</td>
</tr>
<tr>
<th>Reporter</th>
<td>harald@gigawatt.nl
</td>
</tr>
<tr>
<th>CC</th>
<td>craig.topper@gmail.com, glaubitz@physik.fu-berlin.de, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>$ 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 <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> 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>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
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>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
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 <a href="mailto:__libc_start_main@GLIBC_2.16">__libc_start_main@GLIBC_2.16</a>
(/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 (<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a>
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>