[llvm-bugs] [Bug 44413] New: no-sse2 assert fail for functions that return `struct { double, double }`

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 30 19:48:40 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=44413

            Bug ID: 44413
           Summary: no-sse2 assert fail for functions that return `struct
                    { double, double }`
           Product: new-bugs
           Version: 8.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: pnkfelix at pnkfx.org
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 22972
  --> https://bugs.llvm.org/attachment.cgi?id=22972&action=edit
C source for reproduction

Spawned off of https://github.com/rust-lang/rust/issues/65844, but this is
reproducible via `clang` or `rustc`, so it seems like an LLVM bug.

Consider the following C source code:

```
struct S { double x; double y; };

int indirect(struct S get_pair()) {
    struct S s = get_pair();
    return 0;
}
```

If you try to compile this via `clang -mno-sse2` with an LLVM build with
assertions enabled, you will get the following assertion failure:

```
llvm/lib/Target/X86/X86FloatingPoint.cpp:317: unsigned int getFPReg(const
llvm::MachineOperand&): Assertion `Reg >= X86::FP0 && Reg <= X86::FP6 &&
"Expected FP register!"' failed.
```

If you do it with a build without assertions enabled, at least in `rustc`, the
compiler may or may not crash. (I have no idea about the correctness of the
generated code; based on the assertion, I am not inclined to trust the
compiler's output here.)

Here is the full transcript of my run, so that you can see the stack backtrace
I get from clang:

% ./build/x86_64-unknown-linux-gnu/llvm/bin/clang -c issue65844.c -mno-sse2
clang-9:
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/Target/X86/X86FloatingPoint.cpp:317:
unsigned int getFPReg(const llvm::MachineOperand&): Assertion `Reg >= X86::FP0
&& Reg <= X86\
::FP6 && "Expected FP register!"' failed.
Stack dump:
0.      Program arguments:
/home/pnkfelix/Dev/Mozilla/rust.git/objdir-dbgopt/build/x86_64-unknown-linux-gnu/llvm/bin/clang-9
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -\
main-file-name issue65844.c -mrelocation-model static -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -targe\
t-feature -sse2 -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file
/home/pnkfelix/Dev/Mozilla/rust.git/objdir-dbgopt/issue65844.gcno -resource-dir
/home/pnkfelix/Dev/Mozilla/rust.git/objdir-\
dbgopt/build/x86_64-unknown-linux-gnu/llvm/lib/clang/9.0.0 -internal-isystem
/usr/local/include -internal-isystem
/home/pnkfelix/Dev/Mozilla/rust.git/objdir-dbgopt/build/x86_64-unknown-linux-gnu/llvm/\
lib/clang/9.0.0/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdebug-compilation-dir
/home/pnkfelix/Dev/Mozilla/rust.git/objdir-dbgopt -ferror-limit 19 -fmessage-l\
ength 200 -fobjc-runtime=gcc -fdiagnostics-show-option -faddrsig -o
issue65844.o -x c issue65844.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'issue65844.c'.
4.      Running pass 'X86 FP Stackifier' on function '@indirect'
 #0 0x00007ff499a5cda0 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:533:22
 #1 0x00007ff499a5ce33 PrintStackTraceSignalHandler(void*)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:594:1
 #2 0x00007ff499a5af61 llvm::sys::RunSignalHandlers()
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/Support/Signals.cpp:68:20
 #3 0x00007ff499a5c81d SignalHandler(int)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:385:1
 #4 0x00007ff4970bfe70 __restore_rt (/lib64/libpthread.so.0+0x12e70)
 #5 0x00007ff48f4a5eb5 raise
/usr/src/debug/glibc-2.29-12-g0941350c20/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #6 0x00007ff48f490895 abort
/usr/src/debug/glibc-2.29-12-g0941350c20/stdlib/abort.c:81:7
 #7 0x00007ff48f490769 _nl_load_domain.cold
/usr/src/debug/glibc-2.29-12-g0941350c20/intl/loadmsgcat.c:1177:9
 #8 0x00007ff48f49e5b6 (/lib64/libc.so.6+0x305b6)
 #9 0x00007ff49c8f7f68 getFPReg(llvm::MachineOperand const&)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/Target/X86/X86FloatingPoint.cpp:318:21
#10 0x00007ff49c8fb6ef (anonymous
namespace)::FPS::handleSpecialFP(llvm::MachineInstrBundleIterator<llvm::MachineInstr,
false>&)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/Target/X8\
6/X86FloatingPoint.cpp:1460:30
#11 0x00007ff49c8f89ba (anonymous
namespace)::FPS::processBasicBlock(llvm::MachineFunction&,
llvm::MachineBasicBlock&)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/Target/X86/X86Float\
ingPoint.cpp:461:49
#12 0x00007ff49c8f8290 (anonymous
namespace)::FPS::runOnMachineFunction(llvm::MachineFunction&)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/Target/X86/X86FloatingPoint.cpp:374:13
#13 0x00007ff499fb50e4
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:73:33
#14 0x00007ff499c540f3 llvm::FPPassManager::runOnFunction(llvm::Function&)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1648:20
#15 0x00007ff499c543a8 llvm::FPPassManager::runOnModule(llvm::Module&)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1685:13
#16 0x00007ff499c547ea (anonymous
namespace)::MPPassManager::runOnModule(llvm::Module&)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1750:20
#17 0x00007ff499c54f4c llvm::legacy::PassManagerImpl::run(llvm::Module&)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1863:13
#18 0x00007ff499c55143 llvm::legacy::PassManager::run(llvm::Module&)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1895:1
#19 0x00007ff492542d1f (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) /home/pnkf\
elix/Dev/Mozilla/rust.git/src/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:897:55
#20 0x00007ff492547d8c clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm\
::DataLayout const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/\
clang/lib/CodeGen/BackendUtil.cpp:1498:27
#21 0x00007ff4928d3998
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:303:24
#22 0x00007ff4910e5488 clang::ParseAST(clang::Sema&, bool, bool)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/clang/lib/Parse/ParseAST.cpp:178:14
#23 0x00007ff4938a818f clang::ASTFrontendAction::ExecuteAction()
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1041:11
#24 0x00007ff4928d7098 clang::CodeGenAction::ExecuteAction()
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1060:1
#25 0x00007ff4938a7afb clang::FrontendAction::Execute()
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/clang/lib/Frontend/FrontendAction.cpp:938:38
#26 0x00007ff493854d7e
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:944:42
#27 0x00007ff493960f4b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:291:38
#28 0x000000000044eb05 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/clang/tools/driver/cc1_main.cpp:249:40
#29 0x0000000000444936 ExecuteCC1Tool(llvm::ArrayRef<char const*>,
llvm::StringRef)
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/clang/tools/driver/driver.cpp:309:64
#30 0x000000000044526b main
/home/pnkfelix/Dev/Mozilla/rust.git/src/llvm-project/clang/tools/driver/driver.cpp:381:26
#31 0x00007ff48f491f33 __libc_start_main
/usr/src/debug/glibc-2.29-12-g0941350c20/csu/../csu/libc-start.c:308:16
#32 0x0000000000441a4e _start
(/home/pnkfelix/Dev/Mozilla/rust.git/objdir-dbgopt/build/x86_64-unknown-linux-gnu/llvm/bin/clang-9+0x441a4e)
clang-9: error: unable to execute command: Aborted (core dumped)
clang-9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 9.0.0 (https://github.com/rust-lang/llvm-project.git
2cb41005ed5c4747b10d2bf01d8779d3bb4ae32d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/pnkfelix/Dev/Mozilla/rust.git/objdir-dbgopt/./build/x86_64-unknown-linux-gnu/llvm/bin
clang-9: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang-9: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-9: note: diagnostic msg: /tmp/issue65844-3b4b26.c
clang-9: note: diagnostic msg: /tmp/issue65844-3b4b26.sh
clang-9: note: diagnostic msg:

********************
[ERROR#1] %

-- 
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/20191231/7d141f95/attachment-0001.html>


More information about the llvm-bugs mailing list