[llvm-bugs] [Bug 25267] New: clang crashes on valid code at -O3 on x86_64-linux-gnu

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 20 14:30:46 PDT 2015


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

            Bug ID: 25267
           Summary: clang crashes on valid code at -O3 on x86_64-linux-gnu
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk (as well as 3.7.x) crashes when compiling the following
test case at -O3 on x86_64-linux-gnu in both 32-bit and 64-bit modes. 

This is a regression from 3.6.x. 


$ clang-trunk -v
clang version 3.8.0 (trunk 250844)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/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.2
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.1.0
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.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
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.4
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.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.1.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ 
$ clang-trunk -O2 -c small.c
$ clang-3.6.1 -O3 -c small.c
$ 
$ clang-trunk -O3 -c small.c
clang: /tmp/llvm/lib/Analysis/ValueTracking.cpp:1492: void
computeKnownBits(llvm::Value*, llvm::APInt&, llvm::APInt&, const
llvm::DataLayout&, unsigned int, const {anonymous}::Query&): Assertion `V &&
"No Value?"' failed.
#0 0x300b728 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang+0x300b728)
#1 0x300a4c6 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang+0x300a4c6)
#2 0x300a6d6 (/usr/local/clang-trunk/bin/clang+0x300a6d6)
#3 0x7f41be47f340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x7f41bd41acc9 gsignal
/build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x7f41bd41e0d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#6 0x7f41bd413b86 __assert_fail_base
/build/buildd/eglibc-2.19/assert/assert.c:92:0
#7 0x7f41bd413c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x2d38e4f (/usr/local/clang-trunk/bin/clang+0x2d38e4f)
#9 0x8f14c8 _init (/usr/local/clang-trunk/bin/clang+0x8f14c8)
#10 0x2d38d6d (/usr/local/clang-trunk/bin/clang+0x2d38d6d)
#11 0x2d3bd9c llvm::computeKnownBits(llvm::Value*, llvm::APInt&, llvm::APInt&,
llvm::DataLayout const&, unsigned int, llvm::AssumptionCache*,
llvm::Instruction const*, llvm::DominatorTree const*)
(/usr/local/clang-trunk/bin/clang+0x2d3bd9c)
#12 0x2accf06 (/usr/local/clang-trunk/bin/clang+0x2accf06)
#13 0x2ad227a (/usr/local/clang-trunk/bin/clang+0x2ad227a)
#14 0x2ad0326 (/usr/local/clang-trunk/bin/clang+0x2ad0326)
#15 0x2ad4173 (/usr/local/clang-trunk/bin/clang+0x2ad4173)
#16 0x2a8b05a (/usr/local/clang-trunk/bin/clang+0x2a8b05a)
#17 0x2a780df (/usr/local/clang-trunk/bin/clang+0x2a780df)
#18 0x2a79041 (/usr/local/clang-trunk/bin/clang+0x2a79041)
#19 0x2a79f97 (/usr/local/clang-trunk/bin/clang+0x2a79f97)
#20 0x2f7887f llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang+0x2f7887f)
#21 0x2f788bb llvm::FPPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x2f788bb)
#22 0x2f7a557 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x2f7a557)
#23 0xb9be02 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::raw_pwrite_stream*) (/usr/local/clang-trunk/bin/clang+0xb9be02)
#24 0xb783fa (/usr/local/clang-trunk/bin/clang+0xb783fa)
#25 0xddbe92 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang+0xddbe92)
#26 0xb7abe2 clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang+0xb7abe2)
#27 0x96d106 clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang+0x96d106)
#28 0x943a4e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang+0x943a4e)
#29 0x9251cc clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang+0x9251cc)
#30 0x91cff0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/usr/local/clang-trunk/bin/clang+0x91cff0)
#31 0x903178 main (/usr/local/clang-trunk/bin/clang+0x903178)
#32 0x7f41bd405ec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#33 0x91b67d _start (/usr/local/clang-trunk/bin/clang+0x91b67d)
Stack dump:
0.    Program arguments: /usr/local/clang-trunk/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name small.c
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-target-linker-version 2.24 -momit-leaf-frame-pointer -dwarf-column-info
-coverage-file /data2/small.c -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.8.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.8.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -O3 -fdebug-compilation-dir /data2
-ferror-limit 19 -fmessage-length 109 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-o small.o -x c small.c 
1.    <eof> parser at end of file
2.    Per-module optimization passes
3.    Running pass 'Function Pass Manager' on module 'small.c'.
4.    Running pass 'Combine redundant instructions' on function '@fn1'
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.0 (trunk 250844)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
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/small-bf9454.c
clang: note: diagnostic msg: /tmp/small-bf9454.sh
clang: note: diagnostic msg: 

********************
$ 


------------------------------------


int printf (const char *, ...);

int a, b, c, f[1], g, h, i;

int
fn1 ()
{
  for (g = 0; g < 1; g++)
    f[g] = -1;
  for (; 0;)
    ;
  if (f[0])
    {
      for (; 0;)
    ;
    l1:
      b = 0;
    l2:
      {
    int j = 0;
    for (; j < 1; j++)
      {
        int l;
        if (f[j] >= 0)
          {
        if (a)
          break;
          }
        else
          {
        if (c)
          break;
        return i;
          }
      }
    if (h)
      goto l1;
    for (;;)
      ;
      }
    }
  printf ("%d\n", a);
  goto l2;
}

-- 
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/20151020/d66fd10b/attachment-0001.html>


More information about the llvm-bugs mailing list