[llvm-bugs] [Bug 27886] New: clang crashes at -O2 and above on x86_64-linux-gnu running pass 'Unroll loops'

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 25 22:19:08 PDT 2016


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

            Bug ID: 27886
           Summary: clang crashes at -O2 and above on x86_64-linux-gnu
                    running pass 'Unroll loops'
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: helloqirun at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk crashes at -O2 and above when compiling the following
test case on x86_64-linux-gnu in both 32-bit and 64-bit modes.

It triggers a different assertion failure from Bug 27838. Moreover, the current
trunk (r270678) seems to be fine with Bug 27838.


$ clang-trunk -v
clang version 3.9.0 (trunk 270678) (llvm/trunk 270677)
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.3.0
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.3.0
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 -O2 abc.c
clang-3.9: /home/absozero/trunk/llvm/include/llvm/Support/Casting.h:237:
typename cast_retty<X, Y *>::ret_type llvm::cast(Y *) [X = llvm::ConstantInt, Y
= llvm::Constant]: Assertion `isa<X>(Val) && "cast<Ty>() argument of
incompatible type!"' failed.
#0 0x00000000019bae38 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19bae38)
#1 0x00000000019b9046 llvm::sys::RunSignalHandlers()
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19b9046)
#2 0x00000000019bb50e SignalHandler(int)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19bb50e)
#3 0x00007fcaf8637340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007fcaf77e9cc9 gsignal
/build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fcaf77ed0d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007fcaf77e2b86 __assert_fail_base
/build/buildd/eglibc-2.19/assert/assert.c:92:0
#7 0x00007fcaf77e2c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x00000000018a3a40 tryToUnrollLoop(llvm::Loop*, llvm::DominatorTree&,
llvm::LoopInfo*, llvm::ScalarEvolution*, llvm::TargetTransformInfo const&,
llvm::AssumptionCache&, bool, llvm::Optional<unsigned int>,
llvm::Optional<unsigned int>, llvm::Optional<bool>, llvm::Optional<bool>)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x18a3a40)
#9 0x000000000189feef (anonymous namespace)::LoopUnroll::runOnLoop(llvm::Loop*,
llvm::LPPassManager&) (/home/absozero/trunk/root-clang/bin/clang-3.9+0x189feef)
#10 0x000000000237f7fe llvm::LPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x237f7fe)
#11 0x00000000015b6a2f llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x15b6a2f)
#12 0x000000000235e657 (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x235e657)
#13 0x00000000015b7165 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x15b7165)
#14 0x0000000001b17007 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction,
llvm::raw_pwrite_stream*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1b17007)
#15 0x0000000002234853
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x2234853)
#16 0x00000000025f9166 clang::ParseAST(clang::Sema&, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x25f9166)
#17 0x0000000001ee6b25 clang::FrontendAction::Execute()
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1ee6b25)
#18 0x0000000001eae731
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1eae731)
#19 0x0000000001f80211
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1f80211)
#20 0x00000000007593ce cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/absozero/trunk/root-clang/bin/clang-3.9+0x7593ce)
#21 0x000000000075788f main
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x75788f)
#22 0x00007fcaf77d4ec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#23 0x0000000000754e42 _start
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x754e42)
Stack dump:
0.    Program arguments: /home/absozero/trunk/root-clang/bin/clang-3.9 -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/3.9.0 -internal-isystem
/usr/local/include -internal-isystem
/home/absozero/trunk/root-clang/bin/../lib/clang/3.9.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-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 -o /tmp/abc-cef107.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 'Loop Pass Manager' on function '@fn3'
5.    Running pass 'Unroll loops' on basic block '%for.body'
clang-3.9: error: unable to execute command: Aborted (core dumped)
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (trunk 270678) (llvm/trunk 270677)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-3.9: 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-3.9: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.9: note: diagnostic msg: /tmp/abc-4f9654.c
clang-3.9: note: diagnostic msg: /tmp/abc-4f9654.sh
clang-3.9: note: diagnostic msg:

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


$ cat abc.c
int i;
int f[1];
short k;
int fn1();
int *fn2();
void fn3() {
  short l;
  int *m = &i;
  l = 3;
  for (; l >= 0; l--)
    if (*f) {
      fn2(i);
      m = fn2(f, i);
      fn1(m == 0, i);
      fn1(i);
      i = fn1(k, i) % i;
    } else
      m >= f ? 0 : fn1(4, __PRETTY_FUNCTION__);
}

-- 
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/20160526/5a0fa443/attachment-0001.html>


More information about the llvm-bugs mailing list