https://llvm.org/bugs/show_bug.cgi?id=28882
Bug ID: 28882 Summary: clang crashes on valid code at -O1 and above on x86_64-linux-gnu Running pass 'Early GVN Hoisting of Expressions' Product: clang Version: trunk Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: LLVM Codegen Assignee: unassignedclangb...@nondot.org Reporter: helloqi...@gmail.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified The current clang trunk crashes at -O1 and above when compiling the following test case on x86_64-linux-gnu in both 32-bit and 64-bit modes. $ clang-trunk -v clang version 4.0.0 (trunk 277804) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/local/bin Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.1.1 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/3.4.6 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.1.1 Found candidate GCC installation: /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/6.1.0 Found candidate GCC installation: /usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.3.0 Selected GCC installation: /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/6.1.0 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Selected multilib: .;@m64 $ clang-trunk -O1 abc.c abc.c:8:13: warning: incompatible pointer types initializing 'char *' with an expression of type 'int *' [-Wincompatible-pointer-types] char *k = &i; ^ ~~ abc.c:17:21: warning: expression result unused [-Wunused-value] for (; l; *m) ^~ abc.c:28:5: warning: expression result unused [-Wunused-value] f; ^ abc.c:29:11: warning: unsequenced modification and access to 'i' [-Wunsequenced] i |= (i = c) & f; ~~ ^ abc.c:30:3: warning: expression result unused [-Wunused-value] f ?: 0; ^~~~~~ abc.c:31:9: warning: division by zero is undefined [-Wdivision-by-zero] if (0 / 0) ^ ~ abc.c:35:1: warning: control may reach end of non-void function [-Wreturn-type] } ^ clang-4.0: /home/absozero/trunk/llvm/lib/Transforms/Scalar/GVNHoist.cpp:472: bool (anonymous namespace)::GVNHoist::safeToHoistLdSt(const llvm::Instruction *, const llvm::Instruction *, llvm::MemoryUseOrDef *, (anonymous namespace)::GVNHoist::InsKind, int &): Assertion `MSSA->locallyDominates(D, U)' failed. #0 0x0000000001923ad5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/absozero/trunk/root-clang/bin/clang-4.0+0x1923ad5) #1 0x00000000019241a6 SignalHandler(int) (/home/absozero/trunk/root-clang/bin/clang-4.0+0x19241a6) #2 0x00007f90978d5330 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10330) #3 0x00007f9096452c37 gsignal /build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0 #4 0x00007f9096456028 abort /build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0 #5 0x00007f909644bbf6 __assert_fail_base /build/eglibc-oGUzwX/eglibc-2.19/assert/assert.c:92:0 #6 0x00007f909644bca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2) #7 0x00000000017b4a36 (/home/absozero/trunk/root-clang/bin/clang-4.0+0x17b4a36) #8 0x00000000017b2ba3 (anonymous namespace)::GVNHoist::computeInsertionPoints(llvm::DenseMap<std::pair<unsigned int, unsigned int>, llvm::SmallVector<llvm::Instruction*, 4u>, llvm::DenseMapInfo<std::pair<unsigned int, unsigned int> >, llvm::detail::DenseMapPair<std::pair<unsigned int, unsigned int>, llvm::SmallVector<llvm::Instruction*, 4u> > > const&, llvm::SmallVector<std::pair<llvm::BasicBlock*, llvm::SmallVector<llvm::Instruction*, 4u> >, 4u>&, (anonymous namespace)::GVNHoist::InsKind) (/home/absozero/trunk/root-clang/bin/clang-4.0+0x17b2ba3) #9 0x00000000017b0fa6 (anonymous namespace)::GVNHoist::run(llvm::Function&) (/home/absozero/trunk/root-clang/bin/clang-4.0+0x17b0fa6) #10 0x00000000017b6233 (anonymous namespace)::GVNHoistLegacyPass::runOnFunction(llvm::Function&) (/home/absozero/trunk/root-clang/bin/clang-4.0+0x17b6233) #11 0x00000000015432cf llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/absozero/trunk/root-clang/bin/clang-4.0+0x15432cf) #12 0x0000000001542ab9 llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) (/home/absozero/trunk/root-clang/bin/clang-4.0+0x1542ab9) #13 0x0000000001a9adb7 clang::EmitBackendOutput(clang::DiagnosticsEngine&, 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/absozero/trunk/root-clang/bin/clang-4.0+0x1a9adb7) #14 0x000000000216086c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/absozero/trunk/root-clang/bin/clang-4.0+0x216086c) #15 0x00000000025288c6 clang::ParseAST(clang::Sema&, bool, bool) (/home/absozero/trunk/root-clang/bin/clang-4.0+0x25288c6) #16 0x0000000001e4a9e5 clang::FrontendAction::Execute() (/home/absozero/trunk/root-clang/bin/clang-4.0+0x1e4a9e5) #17 0x0000000001e14011 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/absozero/trunk/root-clang/bin/clang-4.0+0x1e14011) #18 0x0000000001edd024 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/absozero/trunk/root-clang/bin/clang-4.0+0x1edd024) #19 0x000000000078a62c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/absozero/trunk/root-clang/bin/clang-4.0+0x78a62c) #20 0x0000000000788abd main (/home/absozero/trunk/root-clang/bin/clang-4.0+0x788abd) #21 0x00007f909643df45 __libc_start_main /build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0 #22 0x0000000000786042 _start (/home/absozero/trunk/root-clang/bin/clang-4.0+0x786042) Stack dump: 0. Program arguments: /home/absozero/trunk/root-clang/bin/clang-4.0 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name abc.c -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -momit-leaf-frame-pointer -dwarf-column-info -debugger-tuning=gdb -resource-dir /home/absozero/trunk/root-clang/bin/../lib/clang/4.0.0 -internal-isystem /usr/local/include -internal-isystem /home/absozero/trunk/root-clang/bin/../lib/clang/4.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O1 -fdebug-compilation-dir /home/absozero/projects/reduction/crash -ferror-limit 19 -fmessage-length 130 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/abc-22795c.o -x c abc.c 1. <eof> parser at end of file 2. Per-function optimization 3. Running pass 'Early GVN Hoisting of Expressions' on function '@fn1' clang-4.0: error: unable to execute command: Aborted (core dumped) clang-4.0: error: clang frontend command failed due to signal (use -v to see invocation) clang version 4.0.0 (trunk 277804) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/local/bin clang-4.0: 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-4.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-4.0: note: diagnostic msg: /tmp/abc-e81761.c clang-4.0: note: diagnostic msg: /tmp/abc-e81761.sh clang-4.0: note: diagnostic msg: ******************** $ cat abc.c typedef short int16_t; int16_t a, b, c, d, e, f, g; int h; int16_t fn1() { int i = 0, j = a = d = e = c; if (fn1()) for (;;) { char *k = &i; { short l; if (b) { for (; k;) return 0; int *m = &j; if (a) lblCDAE7005: for (; l; *m) ; } } lbl5BA3649E:; } j = e = g = b; j = (j ? b : i) ? h : 0; e = a = f = b = 0; f = 0; if (f) f; i |= (i = c) & f; f ?: 0; if (0 / 0) goto lblCDAE7005; if (c) goto lbl5BA3649E; } -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs