llvm / llvm-project

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

Assertion `(EltVT.getSizeInBits() >= 64 || (uint64_t)((int64_t)Val >> EltVT.getSizeInBits()) + 1 < 2) && "getConstant with a uint64_t value that doesn't fit in the type!"' failed. #35779

Open llvmbot opened 6 years ago

llvmbot commented 6 years ago
Bugzilla Link 36431
Version trunk
OS All
Reporter LLVM Bugzilla Contributor

Extended Description

$clang-trunk -v
clang version 7.0.0 (trunk 325390)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin

$ clang-trunk -m32 -O3 abc.c
clang-7.0: /home/suhua/compilers/trunk/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1106: llvm::SDValue llvm::SelectionDAG::getConstant(uint64_t, const llvm::SDLoc&, llvm::EVT, bool, bool): Assertion `(EltVT.getSizeInBits() >= 64 || (uint64_t)((int64_t)Val >> EltVT.getSizeInBits()) + 1 < 2) && "getConstant with a uint64_t value that doesn't fit in the type!"' failed.
#0 0x0000000002313b1a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x2313b1a)
#1 0x0000000002311b8e llvm::sys::RunSignalHandlers() (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x2311b8e)
#2 0x0000000002311cf2 SignalHandler(int) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x2311cf2)
#3 0x00007f90af5d6390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x00007f90ae341428 gsignal /build/glibc-Cl5G7W/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#5 0x00007f90ae34302a abort /build/glibc-Cl5G7W/glibc-2.23/stdlib/abort.c:91:0
#6 0x00007f90ae339bd7 __assert_fail_base /build/glibc-Cl5G7W/glibc-2.23/assert/assert.c:92:0
#7 0x00007f90ae339c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#8 0x0000000002c0d668 (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x2c0d668)
#9 0x0000000002bc84ad llvm::SelectionDAGBuilder::visitGetElementPtr(llvm::User const&) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x2bc84ad)
#10 0x0000000002be7c2d llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x2be7c2d)
#11 0x0000000002c3140d llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x2c3140d)
#12 0x0000000002c35049 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x2c35049)
#13 0x0000000002c36b3e llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) [clone .part.1077] (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x2c36b3e)
#14 0x00000000016fd094 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x16fd094)
#15 0x0000000001b5cd85 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x1b5cd85)
#16 0x0000000001e80f03 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x1e80f03)
#17 0x0000000001e80fac llvm::FPPassManager::runOnModule(llvm::Module&) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x1e80fac)
#18 0x0000000001e8184f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x1e8184f)
#19 0x00000000024b7cc6 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x24b7cc6)
#20 0x00000000024b8fdf 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/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x24b8fdf)
#21 0x0000000002cf57bb clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x2cf57bb)
#22 0x0000000002f20022 clang::ParseAST(clang::Sema&, bool, bool) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x2f20022)
#23 0x0000000002cf4dff clang::CodeGenAction::ExecuteAction() (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x2cf4dff)
#24 0x0000000002888b96 clang::FrontendAction::Execute() (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x2888b96)
#25 0x000000000285dede clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x285dede)
#26 0x000000000291d1c2 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0x291d1c2)
#27 0x0000000000c8c108 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0xc8c108)
#28 0x0000000000c103a1 main (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0xc103a1)
#29 0x00007f90ae32c830 __libc_start_main /build/glibc-Cl5G7W/glibc-2.23/csu/../csu/libc-start.c:325:0
#30 0x0000000000c86db9 _start (/home/suhua/compilers/trunk/root-clang/bin/clang-7.0+0xc86db9)
Stack dump:
0.  Program arguments: /home/suhua/compilers/trunk/root-clang/bin/clang-7.0 -cc1 -triple i386-unknown-linux-gnu -emit-obj -disable-free -main-file-name abc.c -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu pentium4 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -coverage-notes-file /home/suhua/Documents/VPT/reduce/bug4/abc.gcno -resource-dir /home/suhua/compilers/trunk/root-clang/lib/clang/7.0.0 -c-isystem . -c-isystem /usr/local/include/csmith-2.3.0/ -c-isystem /home/suhua/media_disk/home/klee/include/klee -internal-isystem /usr/local/include -internal-isystem /home/suhua/compilers/trunk/root-clang/lib/clang/7.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -fdebug-compilation-dir /home/suhua/Documents/VPT/reduce/bug4 -ferror-limit 19 -fmessage-length 204 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o abc.o -x c abc.c
1.  <eof> parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module 'abc.c'.
4.  Running pass 'X86 DAG->DAG Instruction Selection' on function '@fn1'
clang-7.0: error: unable to execute command: Aborted (core dumped)
clang-7.0: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 7.0.0 (trunk 325390)
Target: i386-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-7.0: 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-7.0: note: diagnostic msg:
********************

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

********************

$ cat abc.c

struct A {
  unsigned b;
};
struct {
  char c[2000000000];
  char d[3000000000];
  struct A e;
} * a;
void fn1() { a->e.b = 3; }
Endilll commented 1 year ago

Still crashing as of post-16 trunk: https://godbolt.org/z/rGKxd1c1n

clang++: /root/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1550:
llvm::SDValue llvm::SelectionDAG::getConstant(uint64_t, const llvm::SDLoc&, llvm::EVT, bool, bool):
Assertion `(EltVT.getSizeInBits() >= 64 || (uint64_t)((int64_t)Val >> EltVT.getSizeInBits()) + 1 < 2) && "getConstant with a uint64_t value that doesn't fit in the type!"' failed.

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-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -m32 -O3 -x c <source>
1.  <eof> parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module '<source>'.
4.  Running pass 'X86 DAG->DAG Instruction Selection' on function '@fn1'
 #0 0x00005632cd89ac1a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a9ac1a)
 #1 0x00005632cd89884c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a9884c)
 #2 0x00005632cd7e7020 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f3c8979e420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f3c8926b00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007f3c8924a859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007f3c8924a729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007f3c8925bfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x00005632ce7f1293 llvm::SelectionDAG::getConstant(unsigned long, llvm::SDLoc const&, llvm::EVT, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49f1293)
 #9 0x00005632ce79cfd6 llvm::SelectionDAGBuilder::visitGetElementPtr(llvm::User const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x499cfd6)
#10 0x00005632ce7ac9f1 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49ac9f1)
#11 0x00005632ce824551 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4a24551)
#12 0x00005632ce825abe llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4a25abe)
#13 0x00005632ce8276bc llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.1114) SelectionDAGISel.cpp:0:0
#14 0x00005632cc5a1215 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#15 0x00005632ccd015a0 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.72) MachineFunctionPass.cpp:0:0
#16 0x00005632cd27d7de llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x347d7de)
#17 0x00005632cd27db19 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x347db19)
#18 0x00005632cd27e920 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x347e920)
#19 0x00005632cdadae2b 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-assertions-trunk/bin/clang+++0x3cdae2b)
#20 0x00005632ce968753 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b68753)
#21 0x00005632cfc3a459 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5e3a459)
#22 0x00005632ce967560 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b67560)
#23 0x00005632ce2892e9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44892e9)
#24 0x00005632ce21dc42 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x441dc42)
#25 0x00005632ce360c9f clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4560c9f)
#26 0x00005632cb022cc3 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1222cc3)
#27 0x00005632cb01ade8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x00005632ce0912f9 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
#29 0x00005632cd7e74a5 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39e74a5)
#30 0x00005632ce093eee clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4293eee)
#31 0x00005632ce06060b clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x426060b)
#32 0x00005632ce0611e3 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42611e3)
#33 0x00005632ce069fd6 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4269fd6)
#34 0x00005632cb020a8e clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1220a8e)
#35 0x00005632caf51cb1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1151cb1)
#36 0x00007f3c8924c083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#37 0x00005632cb01a4da _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x121a4da)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
shafik commented 10 months ago

I wonder if this is almost a duplicate of: https://github.com/llvm/llvm-project/issues/72503

Since if we diagnosed this earlier then we would not get to codegen