-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Description
Hi,
The following valid code makes clang crash, please check then.
$cat small.c
int a;
int *b;
volatile int c;
extern void h(int);
void d() {
long e = a;
int f = 0;
long g[8];
for (; f < 8; f++)
g[f] = e;
for (;;)
h(g[1] == (c, g[5]) && *b);
}
$clang -c -Os small.c
clang-14: /home/haoxin/haoxin-data/compilers/llvm-project/llvm/lib/IR/Instruction.cpp:113: bool llvm::Instruction::comesBefore(const llvm::Instruction*) const: Assertion `Parent == Other->Parent && "cross-BB instruction order comparison"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/haoxin/haoxin-data/csmith-test/14/creduce -resource-dir /home/haoxin/haoxin-data/compilers/llvm-project/build/lib/clang/15.0.0 -c-isystem /home/haoxin/haoxin-data/github/csmith/runtime -internal-isystem /home/haoxin/haoxin-data/compilers/llvm-project/build/lib/clang/15.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -fdebug-compilation-dir=/home/haoxin/haoxin-data/csmith-test/14/creduce -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-f413d9.o -x c small.c
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'small.c'.
4. Running pass 'Merge contiguous icmps into a memcmp' on function '@d'
#0 0x000055da7c27fd34 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x000055da7c27d45e SignalHandler(int) Signals.cpp:0:0
#2 0x000014d484c1f3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#3 0x000014d48468618b raise /build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#4 0x000014d484665859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
#5 0x000014d484665729 get_sysdep_segment_value /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8
#6 0x000014d484665729 _nl_load_domain /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34
#7 0x000014d484676f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#8 0x000055da7b87cf90 llvm::Instruction::isOnlyUserOfAnyOperand() (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x31e6f90)
#9 0x000055da7c082958 (anonymous namespace)::BCECmpBlock::canSinkBCECmpInst(llvm::Instruction const*, llvm::AAResults&) const MergeICmps.cpp:0:0
#10 0x000055da7c08465a (anonymous namespace)::BCECmpChain::BCECmpChain(std::vector<llvm::BasicBlock*, std::allocator<llvm::BasicBlock*> > const&, llvm::PHINode&, llvm::AAResults&) MergeICmps.cpp:0:0
#11 0x000055da7c0864e0 (anonymous namespace)::runImpl(llvm::Function&, llvm::TargetLibraryInfo const&, llvm::TargetTransformInfo const&, llvm::AAResults&, llvm::DominatorTree*) MergeICmps.cpp:0:0
#12 0x000055da7c0884f4 (anonymous namespace)::MergeICmpsLegacyPass::runOnFunction(llvm::Function&) MergeICmps.cpp:0:0
#13 0x000055da7b8caca5 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3234ca5)
#14 0x000055da7b8caee9 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3234ee9)
#15 0x000055da7b8cb732 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3235732)
#16 0x000055da7c6017c7 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/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3f6b7c7)
#17 0x000055da7d48b123 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4df5123)
#18 0x000055da7e1f2c49 clang::ParseAST(clang::Sema&, bool, bool) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x5b5cc49)
#19 0x000055da7d489a98 clang::CodeGenAction::ExecuteAction() (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4df3a98)
#20 0x000055da7cd65d09 clang::FrontendAction::Execute() (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x46cfd09)
#21 0x000055da7ccf248e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x465c48e)
#22 0x000055da7ce429e3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x47ac9e3)
#23 0x000055da798e0f81 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x124af81)
#24 0x000055da798dd358 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#25 0x000055da7980d809 main (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x1177809)
#26 0x000014d4846670b3 __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#27 0x000055da798dcece _start (/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x1246ece)
clang-14: error: unable to execute command: Aborted (core dumped)
clang-14: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 15.0.0 (https://github.com/llvm/llvm-project fa0f90bc55ed536e1488648255278ce9029cfa59)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/haoxin-data/compilers/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/small-a3ebd6.c
clang-14: note: diagnostic msg: /tmp/small-a3ebd6.sh
clang-14: note: diagnostic msg:
********************
$clang -v
clang version 15.0.0 (https://github.com/llvm/llvm-project fa0f90bc55ed536e1488648255278ce9029cfa59)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/haoxin-data/compilers/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
Thanks,
Haoxin