llvm / llvm-project

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

llvm assert in lib/VMCore/Instructions.cpp:1825 #13622

Closed 5d21713e-153b-4ee3-b86b-e7e1f9a492f9 closed 2 years ago

5d21713e-153b-4ee3-b86b-e7e1f9a492f9 commented 12 years ago
Bugzilla Link 13250
Resolution FIXED
Resolved on Nov 01, 2012 10:29
Version trunk
OS Linux
Blocks llvm/llvm-bugzilla-archive#13893
Attachments preprocessed sources for the bug
CC @d0k,@nlewycky,@pageexec

Extended Description

while compiling linux with clang r159506 i get the following assert for a week or two now:

CC fs/ext4/super.o clang: /llvm.svn/lib/VMCore/Instructions.cpp:1825: static llvm::BinaryOperator llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value , llvm::Value , const llvm::Twine &, llvm::Instruction ): Assertion `S1->getType() == S2->getType() && "Cannot create binary operator with two operands of differing type!"' failed. 0 libLLVM-3.2svn.so 0x00000389fc39d0ef 1 libLLVM-3.2svn.so 0x00000389fc39d5b4 2 libpthread.so.0 0x00000389fbdb81c0 3 libc.so.6 0x00000389fae22ad5 gsignal + 53 4 libc.so.6 0x00000389fae23f4b abort + 379 5 libc.so.6 0x00000389fae1bbbe 6 libc.so.6 0x00000389fae1bc62 7 libLLVM-3.2svn.so 0x00000389fc5ae532 8 libLLVM-3.2svn.so 0x00000389fc6e6824 9 libLLVM-3.2svn.so 0x00000389fc715fc7 10 libLLVM-3.2svn.so 0x00000389fc73a0d7 11 libLLVM-3.2svn.so 0x00000389fc73aa2f 12 libLLVM-3.2svn.so 0x00000389fc5cabfb llvm::FPPassManager::runOnFunction(llvm::Function&) + 443 13 libLLVM-3.2svn.so 0x00000389fc5cae5b llvm::FPPassManager::runOnModule(llvm::Module&) + 155 14 libLLVM-3.2svn.so 0x00000389fc5cb0d3 llvm::MPPassManager::runOnModule(llvm::Module&) + 419 15 libLLVM-3.2svn.so 0x00000389fc5cb658 llvm::PassManagerImpl::run(llvm::Module&) + 408 16 libLLVM-3.2svn.so 0x00000389fc5cb7ba llvm::PassManager::run(llvm::Module&) + 10 17 clang 0x000000000067adc0 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::Module, clang::BackendAction, llvm::raw_ostream) + 5008 18 clang 0x0000000000678c6a 19 clang 0x00000000007a15a4 clang::ParseAST(clang::Sema&, bool, bool) + 516 20 clang 0x0000000000677cf8 clang::CodeGenAction::ExecuteAction() + 184 21 clang 0x000000000055afd5 clang::FrontendAction::Execute() + 101 22 clang 0x000000000053e36d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 973 23 clang 0x0000000000526794 clang::ExecuteCompilerInvocation(clang::CompilerInstance) + 3316 24 clang 0x000000000051ba2b cc1_main(char const, char const, char const, void*) + 731 25 clang 0x0000000000522e3a main + 3482 26 libc.so.6 0x00000389fae0f5cd __libc_start_main + 237 27 clang 0x000000000051b68d Stack dump:

  1. Program arguments: /image/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name super.c -mrelocation-model static -mdisable-fp-elim -relaxed-aliasing -mdisable-tail-calls -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -mcode-model kernel -disable-red-zone -target-cpu core2 -target-feature -sse -target-feature -mmx -target-feature -sse2 -target-feature -3dnow -target-feature -avx -target-linker-version 2.22 -momit-leaf-frame-pointer -g -coverage-file fs/ext4/super.o -nostdsysteminc -nobuiltininc -resource-dir /image/bin/../lib/clang/3.2 -dependency-file fs/ext4/.super.o.d -MT fs/ext4/super.o -sys-header-deps -isystem /image/bin/../lib/clang/3.2/include -include /usr/src/linux/linux-3.4.4-pax-clang/include/linux/kconfig.h -D KERNEL -D CONFIG_X86_X32_ABI -D CONFIG_AS_CFI_SIGNAL_FRAME=1 -D CONFIG_AS_CFI_SECTIONS=1 -D CONFIG_AS_FXSAVEQ=1 -D KBUILD_STR(s)=#s -D KBUILD_BASENAME=KBUILD_STR(super) -D KBUILD_MODNAME=KBUILD_STR(ext4) -I /usr/src/linux/linux-3.4.4-pax-clang/arch/x86/include -I arch/x86/include/generated -I include -fmodule-cache-path /var/tmp/clang-module-cache -O2 -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -Werror-implicit-function-declaration -Wno-format-security -Wno-sign-compare -Wno-unused-but-set-variable -Wdeclaration-after-statement -Wno-pointer-sign -Wextra -Wunused -Wno-unused-parameter -Wno-missing-field-initializers -Wmissing-declarations -Wno-initializer-overrides -Wmissing-format-attribute -Wold-style-definition -Wmissing-include-dirs -Wno-missing-field-initializers -Wno-unused-value -Wno-format -Wno-unknown-warning-option -Wno-self-assign -Wno-sign-compare -Wno-format-zero-length -Wno-uninitialized -Wextra -Wunused -Wno-unused-parameter -Wno-missing-field-initializers -Wmissing-declarations -Wno-initializer-overrides -Wmissing-format-attribute -Wold-style-definition -Wmissing-include-dirs -Wno-missing-field-initializers -Wno-unused-value -Wno-format -Wno-unknown-warning-option -Wno-self-assign -Wno-sign-compare -Wno-format-zero-length -Wno-uninitialized -fdebug-compilation-dir /usr/src/linux/linux-3.4.4-pax-clang -ferror-limit 19 -fmessage-length 277 -fcatch-undefined-behavior -fwrapv -mstackrealign -fobjc-runtime=gnu-fragile -fno-common -fdiagnostics-show-option -fcolor-diagnostics -o fs/ext4/super.o -x c fs/ext4/super.c
  2. parser at end of file
  3. Per-module optimization passes
  4. Running pass 'Function Pass Manager' on module 'fs/ext4/super.c'.
  5. Running pass 'Combine redundant instructions' on function '@ext4_fill_super' clang: error: unable to execute command: Aborted clang: error: clang frontend command failed due to signal (use -v to see invocation) clang version 3.2 (trunk 159506) Target: x86_64-unknown-linux-gnu Thread model: posix clang: 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: note: diagnostic msg:

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

llvmbot commented 2 years ago

mentioned in issue llvm/llvm-bugzilla-archive#13893

5d21713e-153b-4ee3-b86b-e7e1f9a492f9 commented 12 years ago

confirmed, fs/ext4/super.c compiles fine now, thank you!

d0k commented 12 years ago

Fixed the assertion failure in r164377.

5d21713e-153b-4ee3-b86b-e7e1f9a492f9 commented 12 years ago

Reduced testcase :

int a; unsigned long b;

void func(void) { unsigned c = 2 << a; b /= c; }

yes, this does fail for me the same way as well:

clang: /llvm.svn/lib/VMCore/Instructions.cpp:1825: static llvm::BinaryOperator llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value , llvm::Value , const llvm::Twine &, llvm::Instruction ): Assertion `S1->getType() == S2->getType() && "Cannot create binary operator with two operands of differing type!"' failed. 0 libLLVM-3.2svn.so 0x0000033749f0799f 1 libLLVM-3.2svn.so 0x0000033749f07e64 2 libpthread.so.0 0x00000337499221c0 3 libc.so.6 0x000003374898cad5 gsignal + 53 4 libc.so.6 0x000003374898df4b abort + 379 5 libc.so.6 0x0000033748985bbe 6 libc.so.6 0x0000033748985c62 7 libLLVM-3.2svn.so 0x000003374a118de2 8 libLLVM-3.2svn.so 0x000003374a2510d4 9 libLLVM-3.2svn.so 0x000003374a280877 10 libLLVM-3.2svn.so 0x000003374a2a4987 11 libLLVM-3.2svn.so 0x000003374a2a52df 12 libLLVM-3.2svn.so 0x000003374a1354ab llvm::FPPassManager::runOnFunction(llvm::Function&) + 443 13 libLLVM-3.2svn.so 0x000003374a13570b llvm::FPPassManager::runOnModule(llvm::Module&) + 155 14 libLLVM-3.2svn.so 0x000003374a135983 llvm::MPPassManager::runOnModule(llvm::Module&) + 419 15 libLLVM-3.2svn.so 0x000003374a135f08 llvm::PassManagerImpl::run(llvm::Module&) + 408 16 libLLVM-3.2svn.so 0x000003374a13606a llvm::PassManager::run(llvm::Module&) + 10 17 clang 0x000000000067ae50 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::Module, clang::BackendAction, llvm::raw_ostream) + 5008 18 clang 0x0000000000678cfa 19 clang 0x00000000007a1634 clang::ParseAST(clang::Sema&, bool, bool) + 516 20 clang 0x0000000000677d88 clang::CodeGenAction::ExecuteAction() + 184 21 clang 0x000000000055b015 clang::FrontendAction::Execute() + 101 22 clang 0x000000000053e3ad clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 973 23 clang 0x00000000005267d4 clang::ExecuteCompilerInvocation(clang::CompilerInstance) + 3316 24 clang 0x000000000051ba6b cc1_main(char const, char const, char const, void*) + 731 25 clang 0x0000000000522e7a main + 3482 26 libc.so.6 0x00000337489795cd __libc_start_main + 237 27 clang 0x000000000051b6cd Stack dump:

  1. Program arguments: /image/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name a.c -mrelocation-model static -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.22 -momit-leaf-frame-pointer -coverage-file a.o -resource-dir /image/bin/../lib/clang/3.2 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /image/bin/../lib/clang/3.2/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 277 -mstackrealign -fobjc-runtime=gnu-fragile -fdiagnostics-show-option -fcolor-diagnostics -o a.o -x c a.c
  2. parser at end of file
  3. Per-module optimization passes
  4. Running pass 'Function Pass Manager' on module 'a.c'.
  5. Running pass 'Combine redundant instructions' on function '@func' clang: error: unable to execute command: Aborted clang: error: clang frontend command failed due to signal (use -v to see invocation) clang version 3.2 (trunk 159515) Target: x86_64-unknown-linux-gnu Thread model: posix
5d21713e-153b-4ee3-b86b-e7e1f9a492f9 commented 12 years ago

updated testcase sorry for the non-working testcase, i just blindly submitted what clang asked me to without verifying that it'd actually compile ;). the new testcase does properly demonstrate the problem with clang r159515:

clang: /llvm.svn/lib/VMCore/Instructions.cpp:1825: static llvm::BinaryOperator llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value , llvm::Value , const llvm::Twine &, llvm::Instruction ): Assertion `S1->getType() == S2->getType() && "Cannot create binary operator with two operands of differing type!"' failed. 0 libLLVM-3.2svn.so 0x000002e78dacd99f 1 libLLVM-3.2svn.so 0x000002e78dacde64 2 libpthread.so.0 0x000002e78d4e81c0 3 libc.so.6 0x000002e78c552ad5 gsignal + 53 4 libc.so.6 0x000002e78c553f4b abort + 379 5 libc.so.6 0x000002e78c54bbbe 6 libc.so.6 0x000002e78c54bc62 7 libLLVM-3.2svn.so 0x000002e78dcdede2 8 libLLVM-3.2svn.so 0x000002e78de170d4 9 libLLVM-3.2svn.so 0x000002e78de46877 10 libLLVM-3.2svn.so 0x000002e78de6a987 11 libLLVM-3.2svn.so 0x000002e78de6b2df 12 libLLVM-3.2svn.so 0x000002e78dcfb4ab llvm::FPPassManager::runOnFunction(llvm::Function&) + 443 13 libLLVM-3.2svn.so 0x000002e78dcfb70b llvm::FPPassManager::runOnModule(llvm::Module&) + 155 14 libLLVM-3.2svn.so 0x000002e78dcfb983 llvm::MPPassManager::runOnModule(llvm::Module&) + 419 15 libLLVM-3.2svn.so 0x000002e78dcfbf08 llvm::PassManagerImpl::run(llvm::Module&) + 408 16 libLLVM-3.2svn.so 0x000002e78dcfc06a llvm::PassManager::run(llvm::Module&) + 10 17 clang 0x000000000067ae50 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::Module, clang::BackendAction, llvm::raw_ostream) + 5008 18 clang 0x0000000000678cfa 19 clang 0x00000000007a1634 clang::ParseAST(clang::Sema&, bool, bool) + 516 20 clang 0x0000000000677d88 clang::CodeGenAction::ExecuteAction() + 184 21 clang 0x000000000055b015 clang::FrontendAction::Execute() + 101 22 clang 0x000000000053e3ad clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 973 23 clang 0x00000000005267d4 clang::ExecuteCompilerInvocation(clang::CompilerInstance) + 3316 24 clang 0x000000000051ba6b cc1_main(char const, char const, char const, void*) + 731 25 clang 0x0000000000522e7a main + 3482 26 libc.so.6 0x000002e78c53f5cd __libc_start_main + 237 27 clang 0x000000000051b6cd Stack dump:

  1. Program arguments: /image/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mcode-model kernel -disable-red-zone -O2 -fcolor-diagnostics -x c fs/ext4/super.i
  2. parser at end of file
  3. Per-module optimization passes
  4. Running pass 'Function Pass Manager' on module 'fs/ext4/super.i'.
  5. Running pass 'Combine redundant instructions' on function '@ext4_fill_super' Aborted
nlewycky commented 12 years ago

I can't seem to reproduce this, either with the original attached tarball nor with the reduced testcase. The preprocessed sources issue lots of errors like this:

include/linux/list.h:24:42: warning: declaration of 'struct list_head' will not be visible outside of this function [-Wvisibility] static inline void INIT_LIST_HEAD(struct list_head *list) ^ include/linux/list.h:26:6: error: incomplete definition of type 'struct list_head' list->next = list;



The reduced testcase simply doesn't error, even if I remember to pass -fwrap -fcatch-undefined-behavior.

Can you please reconfirm that this occurs? I'm testing with an unpatched r159509.
llvmbot commented 12 years ago

Reduced testcase :

int a; unsigned long b;

void func(void) { unsigned c = 2 << a; b /= c; }