llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.1k stars 12.01k forks source link

"Invalid address displacement operand" while compiling ruby #27876

Closed llvmbot closed 8 years ago

llvmbot commented 8 years ago
Bugzilla Link 27502
Resolution FIXED
Resolved on Apr 26, 2016 09:50
Version trunk
OS Linux
Attachments Files mentioned in the backtrace
Reporter LLVM Bugzilla Contributor
CC @DimitryAndric

Extended Description

Trying to build ruby-2.3.0 with clang 3.9.0 (trunk 267338). So far, I've been unsucessful:

​0 0x00007fe0594a8fb5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/tools/bin/../lib/libLLVM-3.9svn.so+0x40bfb5)

​1 0x00007fe0594a6ccd llvm::sys::RunSignalHandlers() (/tools/bin/../lib/libLLVM-3.9svn.so+0x409ccd)

​2 0x00007fe0594a6e96 SignalHandler(int) (/tools/bin/../lib/libLLVM-3.9svn.so+0x409e96)

​3 0x00007fe0584942d0 __restore_rt (/tools/bin/../lib/libc.so.6+0x332d0)

​4 0x00007fe05a339554 (anonymous namespace)::OptimizeLEAPass::runOnMachineFunction(llvm::MachineFunction&) [clone .part.104] (/tools/bin/../lib/libLLVM-3.9svn.so+0x129c554)

​5 0x00007fe0596bf2b7 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/tools/bin/../lib/libLLVM-3.9svn.so+0x6222b7)

​6 0x00007fe059562568 llvm::FPPassManager::runOnFunction(llvm::Function&) (/tools/bin/../lib/libLLVM-3.9svn.so+0x4c5568)

​7 0x00007fe0595628cb llvm::FPPassManager::runOnModule(llvm::Module&) (/tools/bin/../lib/libLLVM-3.9svn.so+0x4c58cb)

​8 0x00007fe059562bea llvm::legacy::PassManagerImpl::run(llvm::Module&) (/tools/bin/../lib/libLLVM-3.9svn.so+0x4c5bea)

​9 0x000000000060b38b clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module, clang::BackendAction, llvm::raw_pwrite_stream) (/tools/bin/clang-3.9+0x60b38b)

​10 0x0000000000974f07 (/tools/bin/clang-3.9+0x974f07)

​11 0x00000000009876ba clang::ParseAST(clang::Sema&, bool, bool) (/tools/bin/clang-3.9+0x9876ba)

​12 0x00000000008f3739 clang::FrontendAction::Execute() (/tools/bin/clang-3.9+0x8f3739)

​13 0x00000000008c7da6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/tools/bin/clang-3.9+0x8c7da6)

​14 0x0000000000973e6a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/tools/bin/clang-3.9+0x973e6a)

​15 0x00000000005cb038 cc1_main(llvm::ArrayRef<char const>, char const, void*) (/tools/bin/clang-3.9+0x5cb038)

​16 0x00000000005c74d7 main (/tools/bin/clang-3.9+0x5c74d7)

​17 0x00007fe058481771 __libc_start_main (/tools/bin/../lib/libc.so.6+0x20771)

​18 0x00000000005c9179 _start (/tools/bin/clang-3.9+0x5c9179)

Stack dump:

  1. Program arguments: /tools/bin/clang-3.9 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eval.c -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu skylake -momit-leaf-frame-pointer -dwarf-column-info -debugger-tuning=gdb -coverage-file /sources/ruby-2.3.0/eval.o -resource-dir /tools/bin/../lib/clang/3.9.0 -D _FORTIFY_SOURCE=2 -D RUBY_EXPORT -I . -I .ext/include/x86_64-linux -I ./include -I . -internal-isystem /usr/local/include -internal-isystem /tools/bin/../lib/clang/3.9.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -fdebug-compilation-dir /sources/ruby-2.3.0 -ferror-limit 19 -fmessage-length 176 -fvisibility hidden -fwrapv -stack-protector 1 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o eval.o -x c eval.c
  2. parser at end of file
  3. Code generation
  4. Running pass 'Function Pass Manager' on module 'eval.c'.
  5. Running pass 'X86 LEA Optimize' on function '@ruby_setup' clang-3.9: error: unable to execute command: Segmentation fault (core dumped) clang-3.9: error: clang frontend command failed due to signal (use -v to see invocation) clang version 3.9.0 (trunk 267338) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /tools/bin clang-3.9: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script. clang-3.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-3.9: note: diagnostic msg: /tmp/eval-bb65b5.c clang-3.9: note: diagnostic msg: /tmp/eval-bb65b5.sh

Clang was compiled with cmake options which can be found at:

https://github.com/elkrejzi/system-management/blob/master/bootstrap/039-llvm#L13

It was compiled with GNU GCC version 6.0.1 20160421 (prerelease).

Ruby was compiled with ./configure --prefix=/usr --disable-static --enable-shared --disable-install-capi, while also using CFLAGS="-march=skylake -fomit-frame-pointer -Os -pipe" and clang as a compiler.

clang 3.8.0 works fine (with addition of -mno-avx512f to CFLAGS because 3.8 has -march=skylake which targets AVX-512 systems which this CPU doesn't have).

Mentioned files are attached. Let me know if you need more info

llvmbot commented 8 years ago

Fixed in r267551.

llvmbot commented 8 years ago

Hi,

I bumped into exact same issue with setjmp a couple of days ago. The fix has already been submitted to the Phabricator (http://reviews.llvm.org/D19409), so I'm just waiting for it to be reviewed.

DimitryAndric commented 8 years ago

Andrey, in r261429 you enabled the LEA optimization pass by default, can you please have a look?

DimitryAndric commented 8 years ago

Minimized test case is just one line:

x0() { __builtin_setjmp(1); }

To reproduce the bug, compile with:

clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -Os -w testcase.c

The -Os option is relevant, -O1 or -O2 do not trigger the bug.

DimitryAndric commented 8 years ago

Reproduces with trunk r266775. The emitted error is:

Invalid address displacement operand UNREACHABLE executed at /share/dim/src/llvm/trunk/lib/Target/X86/X86OptimizeLEAs.cpp:150!

Backtrace:

​0 0x2b950a03 in thr_kill () from /lib/libc.so.7

​1 0x2b9509e8 in __raise (s=0) at /share/dim/src/freebsd/base/head/lib/libc/gen/raise.c:52

​2 0x2b950923 in abort () at /share/dim/src/freebsd/base/head/lib/libc/stdlib/abort.c:65

​3 0x09414175 in llvm::llvm_unreachable_internal(char const, char const, unsigned int) ()

​4 0x0894dfda in llvm::DenseMapInfo::getHashValue(MemOpKey const&) ()

​5 0x0894dadf in bool llvm::DenseMapBase<llvm::DenseMap<MemOpKey, llvm::SmallVector<llvm::MachineInstr, 16u>, llvm::DenseMapInfo, llvm::detail::DenseMapPair<MemOpKey, llvm::SmallVector<llvm::MachineInstr, 16u> > >, MemOpKey, llvm::SmallVector<llvm::MachineInstr, 16u>, llvm::DenseMapInfo, llvm::detail::DenseMapPair<MemOpKey, llvm::SmallVector<llvm::MachineInstr, 16u> > >::LookupBucketFor(MemOpKey const&, llvm::detail::DenseMapPair<MemOpKey, llvm::SmallVector<llvm::MachineInstr, 16u> > const&) const ()

​6 0x0894e76b in llvm::detail::DenseMapPair<MemOpKey, llvm::SmallVector<llvm::MachineInstr, 16u> > llvm::DenseMapBase<llvm::DenseMap<MemOpKey, llvm::SmallVector<llvm::MachineInstr, 16u>, llvm::DenseMapInfo, llvm::detail::DenseMapPair<MemOpKey, llvm::SmallVector<llvm::MachineInstr, 16u> > >, MemOpKey, llvm::SmallVector<llvm::MachineInstr, 16u>, llvm::DenseMapInfo, llvm::detail::DenseMapPair<MemOpKey, llvm::SmallVector<llvm::MachineInstr, 16u> > >::InsertIntoBucketImpl(MemOpKey const&, MemOpKey const&, llvm::detail::DenseMapPair<MemOpKey, llvm::SmallVector<llvm::MachineInstr, 16u> >) ()

​7 0x0894b68e in (anonymous namespace)::OptimizeLEAPass::runOnMachineFunction(llvm::MachineFunction&) ()

​8 0x08d82214 in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) ()

​9 0x0902c1fb in llvm::FPPassManager::runOnFunction(llvm::Function&) ()

​10 0x0902c4a2 in llvm::FPPassManager::runOnModule(llvm::Module&) ()

​11 0x0902ca27 in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()

​12 0x0902d0c8 in llvm::legacy::PassManager::run(llvm::Module&) ()

​13 0x095e1266 in (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, llvm::raw_pwrite_stream*) ()

​14 0x095de152 in clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module, clang::BackendAction, llvm::raw_pwrite_stream) ()

​15 0x09e2a82c in clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) ()

​16 0x0a23f875 in clang::ParseAST(clang::Sema&, bool, bool) ()

​17 0x09a2c156 in clang::ASTFrontendAction::ExecuteAction() ()

​18 0x09e2918e in clang::CodeGenAction::ExecuteAction() ()

​19 0x09a2ba33 in clang::FrontendAction::Execute() ()

​20 0x099f07da in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) ()

​21 0x09ac765b in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) ()

​22 0x08315ce7 in cc1_main(llvm::ArrayRef<char const>, char const, void*) ()

​23 0x08314606 in main ()