llvm / llvm-project

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

clang crashes at -O1 and above with polly #33771

Closed llvmbot closed 2 years ago

llvmbot commented 7 years ago
Bugzilla Link 34423
Resolution FIXED
Resolved on May 27, 2018 17:14
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @chengniansun,@Meinersbur,@tobiasgrosser

Extended Description

My clang was installed according to https://polly.llvm.org/get_started.html.

$ ~/trunk/polly/polly-root/bin/clang -v clang version 6.0.0 (http://llvm.org/git/clang.git 48231c128c697271508e83b487d436a071e62f09) (http://llvm.org/git/llvm.git 074e282b60af6fa3954381faba5b121df4f4ea99) Target: x86_64-unknown-linux-gnu Thread model: posix

$ ~/trunk/polly/polly-root/bin/clang -mllvm -enable-newgvn -mllvm -polly -O1 abc.c abc.c:7:5: warning: incompatible pointer types assigning to 'int ' from 'long ' [-Wincompatible-pointer-types] d = &c; ^ ~~ abc.c:10:5: warning: expression result unused [-Wunused-value] (c %= f) ?: a && (d = b); ^~~~~~~~~ clang-6.0: /home/absozero/trunk/polly/llvm_git/tools/polly/lib/CodeGen/BlockGenerators.cpp:208: llvm::Value polly::BlockGenerator::getNewValue(polly::ScopStmt&, llvm::Value, polly::ValueMapT&, llvm::LoopToScevMapT&, llvm::Loop) const: Assertion `New && "Unexpected scalar dependence in region!"' failed.

​0 0x000000000232e6ba llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x232e6ba)

​1 0x000000000232c84e llvm::sys::RunSignalHandlers() (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x232c84e)

​2 0x000000000232c9b0 SignalHandler(int) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x232c9b0)

​3 0x00007f7a2186f340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)

​4 0x00007f7a20660cc9 gsignal /build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0

​5 0x00007f7a206640d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0

​6 0x00007f7a20659b86 __assert_fail_base /build/buildd/eglibc-2.19/assert/assert.c:92:0

​7 0x00007f7a20659c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)

​8 0x00000000029fd96d polly::BlockGenerator::getNewValue(polly::ScopStmt&, llvm::Value, llvm::DenseMap<llvm::AssertingVH, llvm::AssertingVH, llvm::DenseMapInfo<llvm::AssertingVH >, llvm::detail::DenseMapPair<llvm::AssertingVH, llvm::AssertingVH > >&, llvm::DenseMap<llvm::Loop const, llvm::SCEV const, llvm::DenseMapInfo<llvm::Loop const>, llvm::detail::DenseMapPair<llvm::Loop const, llvm::SCEV const> >&, llvm::Loop*) const (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x29fd96d)

​9 0x0000000002a03335 polly::RegionGenerator::addOperandToPHI(polly::ScopStmt&, llvm::PHINode, llvm::PHINode, llvm::BasicBlock, llvm::DenseMap<llvm::Loop const, llvm::SCEV const, llvm::DenseMapInfo<llvm::Loop const>, llvm::detail::DenseMapPair<llvm::Loop const, llvm::SCEV const> >&) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x2a03335)

​10 0x0000000002a0359e polly::RegionGenerator::copyPHIInstruction(polly::ScopStmt&, llvm::PHINode, llvm::DenseMap<llvm::AssertingVH, llvm::AssertingVH, llvm::DenseMapInfo<llvm::AssertingVH >, llvm::detail::DenseMapPair<llvm::AssertingVH, llvm::AssertingVH > >&, llvm::DenseMap<llvm::Loop const, llvm::SCEV const, llvm::DenseMapInfo<llvm::Loop const>, llvm::detail::DenseMapPair<llvm::Loop const, llvm::SCEV const> >&) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x2a0359e)

​11 0x00000000029fec69 polly::BlockGenerator::copyInstruction(polly::ScopStmt&, llvm::Instruction, llvm::DenseMap<llvm::AssertingVH, llvm::AssertingVH, llvm::DenseMapInfo<llvm::AssertingVH >, llvm::detail::DenseMapPair<llvm::AssertingVH, llvm::AssertingVH > >&, llvm::DenseMap<llvm::Loop const, llvm::SCEV const, llvm::DenseMapInfo<llvm::Loop const>, llvm::detail::DenseMapPair<llvm::Loop const, llvm::SCEV const> >&, isl_id_to_ast_expr*) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x29fec69)

​12 0x00000000029fed1b polly::BlockGenerator::copyBB(polly::ScopStmt&, llvm::BasicBlock, llvm::BasicBlock, llvm::DenseMap<llvm::AssertingVH, llvm::AssertingVH, llvm::DenseMapInfo<llvm::AssertingVH >, llvm::detail::DenseMapPair<llvm::AssertingVH, llvm::AssertingVH > >&, llvm::DenseMap<llvm::Loop const, llvm::SCEV const, llvm::DenseMapInfo<llvm::Loop const>, llvm::detail::DenseMapPair<llvm::Loop const, llvm::SCEV const> >&, isl_id_to_ast_expr) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x29fed1b)

​13 0x0000000002a044d0 polly::RegionGenerator::copyStmt(polly::ScopStmt&, llvm::DenseMap<llvm::Loop const, llvm::SCEV const, llvm::DenseMapInfo<llvm::Loop const>, llvm::detail::DenseMapPair<llvm::Loop const, llvm::SCEV const> >&, isl_id_to_ast_expr) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x2a044d0)

​14 0x0000000002a107d8 IslNodeBuilder::createUser(isl_ast_node*) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x2a107d8)

​15 0x0000000002a0cfe8 IslNodeBuilder::createBlock(isl_ast_node*) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x2a0cfe8)

​16 0x0000000002a0de33 IslNodeBuilder::createIf(isl_ast_node*) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x2a0de33)

​17 0x00000000029b9c54 CodeGen(polly::Scop&, polly::IslAstInfo&, llvm::LoopInfo&, llvm::DominatorTree&, llvm::ScalarEvolution&, llvm::RegionInfo&) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x29b9c54)

​18 0x00000000019f9c3d llvm::RGPassManager::runOnFunction(llvm::Function&) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x19f9c3d)

​19 0x0000000001eab8e3 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x1eab8e3)

​20 0x0000000001eab98c llvm::FPPassManager::runOnModule(llvm::Module&) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x1eab98c)

​21 0x0000000001eac1fa llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x1eac1fa)

​22 0x00000000024cdf95 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete >) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x24cdf95)

​23 0x00000000024cf373 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 >) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x24cf373)

​24 0x0000000002cf17bf clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x2cf17bf)

​25 0x0000000002f14d9c clang::ParseAST(clang::Sema&, bool, bool) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x2f14d9c)

​26 0x0000000002cf0c60 clang::CodeGenAction::ExecuteAction() (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x2cf0c60)

​27 0x0000000002883796 clang::FrontendAction::Execute() (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x2883796)

​28 0x00000000028563f6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x28563f6)

​29 0x000000000291f352 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0x291f352)

​30 0x0000000000d47dc8 cc1_main(llvm::ArrayRef<char const>, char const, void*) (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0xd47dc8)

​31 0x0000000000cd513c main (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0xcd513c)

​32 0x00007f7a2064bec5 __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:321:0

​33 0x0000000000d436e9 _start (/home/absozero/trunk/polly/polly-root/bin/clang-6.0+0xd436e9)

Stack dump:

  1. Program arguments: /home/absozero/trunk/polly/polly-root/bin/clang-6.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/polly/polly-root/lib/clang/6.0.0 -c-isystem /usr/local/include/csmith-2.3.0 -c-isystem . -cxx-isystem /usr/local/include/csmith-2.3.0 -cxx-isystem . -internal-isystem /usr/local/include -internal-isystem /home/absozero/trunk/polly/polly-root/lib/clang/6.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/reduction1 -ferror-limit 19 -fmessage-length 172 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -mllvm -enable-newgvn -mllvm -polly -o /tmp/abc-3bdd0f.o -x c abc.c
  2. parser at end of file
  3. Per-module optimization passes
  4. Running pass 'Function Pass Manager' on module 'abc.c'.
  5. Running pass 'Region Pass Manager' on function '@fn1'
  6. Running pass 'Polly - Create LLVM-IR from SCoPs' on basic block '%for.cond' clang-6.0: error: unable to execute command: Aborted (core dumped) clang-6.0: error: clang frontend command failed due to signal (use -v to see invocation) clang version 6.0.0 (http://llvm.org/git/clang.git 48231c128c697271508e83b487d436a071e62f09) (http://llvm.org/git/llvm.git 074e282b60af6fa3954381faba5b121df4f4ea99) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/absozero/trunk/polly/polly-root/bin clang-6.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-6.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-6.0: note: diagnostic msg: /tmp/abc-69c97d.c clang-6.0: note: diagnostic msg: /tmp/abc-69c97d.sh clang-6.0: note: diagnostic msg:


$ cat abc.c int a, b; long c; int d; short e, f; char g; void fn1() { d = &c; for (;;) { c = d ? e ?: 1 | (g |= f) : 1; (c %= f) ?: a && (*d = b); for (; e <= 8;) ; } }

chengniansun commented 2 years ago

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

Meinersbur commented 6 years ago

Thanks Sanjay!

llvmbot commented 6 years ago

Code compiles (with a dummy main()) at llvm-trunk, clang-trunk and polly-trunk at the following commits. Closing the bug report.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333339 1177308-0d34-0410-b5e6-96231b3b80d8 git-svn-id: https://llvm.org/svn/llvm-project/polly/trunk@333168 91177308-0d34-0410-b5e6-96231b3b80d8 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333333 91177308-0d34-0410-b5e6-96231b3b80d8

llvmbot commented 7 years ago

Not a newgvn problem, changing the title so that it doesn't show up in searches :)

chengniansun commented 7 years ago

Bug llvm/llvm-bugzilla-archive#34429 has been marked as a duplicate of this bug.