[llvm-bugs] [Bug 33720] New: clang crashes with "-mllvm -enable-newgvn": Assertion `(!InstMA || !OldClass->getMemoryLeader() || OldClass->getLeader() != I || OldClass->getMemoryLeader() == InstMA) && "Representative MemoryAccess mismatch"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jul 8 13:34:55 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33720

            Bug ID: 33720
           Summary: clang crashes with "-mllvm -enable-newgvn": Assertion
                    `(!InstMA || !OldClass->getMemoryLeader() ||
                    OldClass->getLeader() != I ||
                    OldClass->getMemoryLeader() == InstMA) &&
                    "Representative MemoryAccess mismatch"' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: helloqirun at gmail.com
                CC: llvm-bugs at lists.llvm.org

The following code crashes the current trunk version at "-Os" only "-mllvm
-enable-newgvn". Level "-O3" works fine.


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


$ clang-trunk -Os -mllvm -enable-newgvn abc.c
abc.c:23:15: warning: expression result unused [-Wunused-value]
    for (; a; a) {
              ^
clang-5.0: /home/absozero/trunk/llvm/lib/Transforms/Scalar/NewGVN.cpp:2078:
void (anonymous
namespace)::NewGVN::moveMemoryToNewCongruenceClass(llvm::Instruction *,
llvm::MemoryAccess *, CongruenceClass *, CongruenceClass *): Assertion
`(!InstMA || !OldClass->getMemoryLeader() || OldClass->getLeader() != I ||
OldClass->getMemoryLeader() == InstMA) && "Representative MemoryAccess
mismatch"' failed.
#0 0x0000000001d57864 PrintStackTraceSignalHandler(void*)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x1d57864)
#1 0x0000000001d57b86 SignalHandler(int)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x1d57b86)
#2 0x00007fa4c7497330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#3 0x00007fa4c6014c37 gsignal
/build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#4 0x00007fa4c6018028 abort
/build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0
#5 0x00007fa4c600dbf6 __assert_fail_base
/build/eglibc-oGUzwX/eglibc-2.19/assert/assert.c:92:0
#6 0x00007fa4c600dca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#7 0x0000000001c5a797 (anonymous
namespace)::NewGVN::performCongruenceFinding(llvm::Instruction*,
llvm::GVNExpression::Expression const*)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x1c5a797)
#8 0x0000000001c48e03 (anonymous
namespace)::NewGVN::iterateTouchedInstructions()
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x1c48e03)
#9 0x0000000001c40493 (anonymous namespace)::NewGVN::runGVN()
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x1c40493)
#10 0x0000000001c45b56 (anonymous
namespace)::NewGVNLegacyPass::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x1c45b56)
#11 0x00000000018d9e1f llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x18d9e1f)
#12 0x000000000276deb6 (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x276deb6)
#13 0x00000000018da566 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x18da566)
#14 0x0000000001ed136b 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/absozero/trunk/root-clang/bin/clang-5.0+0x1ed136b)
#15 0x00000000025fb1b2
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x25fb1b2)
#16 0x0000000002a64726 clang::ParseAST(clang::Sema&, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x2a64726)
#17 0x00000000022baf08 clang::FrontendAction::Execute()
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x22baf08)
#18 0x000000000226b881
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x226b881)
#19 0x00000000023433aa
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x23433aa)
#20 0x0000000000846594 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/absozero/trunk/root-clang/bin/clang-5.0+0x846594)
#21 0x000000000084415e main
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x84415e)
#22 0x00007fa4c5ffff45 __libc_start_main
/build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0
#23 0x00000000008413b9 _start
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x8413b9)
Stack dump:
0.      Program arguments: /home/absozero/trunk/root-clang/bin/clang-5.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/lib/clang/5.0.0 -internal-isystem
/usr/local/include -internal-isystem
/home/absozero/trunk/root-clang/lib/clang/5.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -Os
-fdebug-compilation-dir /home/absozero/projects/reduction/crash -ferror-limit
19 -fmessage-length 172 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -vectorize-loops -vectorize-slp -mllvm -enable-newgvn -o
/tmp/abc-cad991.o -x c abc.c
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'CallGraph Pass Manager' on module 'abc.c'.
4.      Running pass 'Global Value Numbering' on function '@fn1'
clang-5.0: error: unable to execute command: Aborted (core dumped)
clang-5.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 5.0.0 (trunk 307468)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-5.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-5.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-5.0: note: diagnostic msg: /tmp/abc-8e89bb.c
clang-5.0: note: diagnostic msg: /tmp/abc-8e89bb.sh
clang-5.0: note: diagnostic msg:

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



$ cat abc.c
short a, c;
long b, e, f, g, h, i;
char d;
void fn1() {
  if (d) {
    long *j = &f;
    if (0) {
      long k;
      for (;;) {
        *j = 7;
        for (; *j <= 8;) {
          (f |= 3 != k) + c || k || (b = 1);
          k = 15;
        }
        for (; h;) {
          k = 5;
          for (; i;)
            ;
        }
      l1:;
      }
    }
    for (; a; a) {
      j = &e;
    l2:;
    }
    for (; e;) {
      goto l2;
    l3:;
    }
  }
  if (g)
    goto l1;
  goto l3;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170708/c9c37fad/attachment.html>


More information about the llvm-bugs mailing list