[llvm-bugs] [Bug 27570] New: clang crashes on valid code at -Os and above on x86_64-linux-gnu: Assertion `isLoopInvariant(Operands[i], L) && "SCEVAddRecExpr operand is not loop-invariant!"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 28 22:21:20 PDT 2016


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

            Bug ID: 27570
           Summary: clang crashes on valid code at -Os and above on
                    x86_64-linux-gnu: Assertion
                    `isLoopInvariant(Operands[i], L) && "SCEVAddRecExpr
                    operand is not loop-invariant!"' failed
           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.5.x and later) crashes when compiling the
following code on x86_64-linux-gnu at -Os and above in both 32-bit and 64-bit
modes. 

This is a regression from 3.4.x.


$ clang-trunk -v
clang version 3.9.0 (trunk 267855)
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.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/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.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
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-3.4 -Os -c small.c
$ 
$ clang-trunk -Os -c small.c
clang-3.9:
/tmp/llvm-builder/llvm-source-trunk/lib/Analysis/ScalarEvolution.cpp:2868:
const llvm::SCEV*
llvm::ScalarEvolution::getAddRecExpr(llvm::SmallVectorImpl<const llvm::SCEV*>&,
const llvm::Loop*, llvm::SCEV::NoWrapFlags): Assertion
`isLoopInvariant(Operands[i], L) && "SCEVAddRecExpr operand is not
loop-invariant!"' failed.
#0 0x0000000001dbb855 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1dbb855)
#1 0x0000000001db97e6 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-3.9+0x1db97e6)
#2 0x0000000001db9a04 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-3.9+0x1db9a04)
#3 0x00007f804a0df340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f80492fdcc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f80493010d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f80492f6b86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f80492f6c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x000000000168ca67
llvm::ScalarEvolution::getAddRecExpr(llvm::SmallVectorImpl<llvm::SCEV const*>&,
llvm::Loop const*, llvm::SCEV::NoWrapFlags)
(/usr/local/clang-trunk/bin/clang-3.9+0x168ca67)
#9 0x0000000001693df0 llvm::ScalarEvolution::getTruncateExpr(llvm::SCEV const*,
llvm::Type*) (/usr/local/clang-trunk/bin/clang-3.9+0x1693df0)
#10 0x000000000168f1d8 llvm::ScalarEvolution::createSCEV(llvm::Value*) [clone
.part.1475] (/usr/local/clang-trunk/bin/clang-3.9+0x168f1d8)
#11 0x000000000169000a llvm::ScalarEvolution::getSCEV(llvm::Value*)
(/usr/local/clang-trunk/bin/clang-3.9+0x169000a)
#12 0x0000000001e5b86b (anonymous
namespace)::SimplifyIndvar::eliminateIVComparison(llvm::ICmpInst*,
llvm::Value*) (/usr/local/clang-trunk/bin/clang-3.9+0x1e5b86b)
#13 0x0000000001e5c3b1 llvm::simplifyUsersOfIV(llvm::PHINode*,
llvm::ScalarEvolution*, llvm::DominatorTree*, llvm::LoopInfo*,
llvm::SmallVectorImpl<llvm::WeakVH>&, llvm::IVVisitor*)
(/usr/local/clang-trunk/bin/clang-3.9+0x1e5c3b1)
#14 0x0000000001c6eafc (anonymous
namespace)::IndVarSimplify::runOnLoop(llvm::Loop*, llvm::LPPassManager&) [clone
.part.478] (/usr/local/clang-trunk/bin/clang-3.9+0x1c6eafc)
#15 0x000000000265e44b llvm::LPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-3.9+0x265e44b)
#16 0x0000000001a39373 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1a39373)
#17 0x000000000263c067 (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-3.9+0x263c067)
#18 0x0000000001a39ab8 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1a39ab8)
#19 0x0000000001f05a18 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction,
llvm::raw_pwrite_stream*) (/usr/local/clang-trunk/bin/clang-3.9+0x1f05a18)
#20 0x000000000252edaa
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/clang-trunk/bin/clang-3.9+0x252edaa)
#21 0x000000000287927d clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x287927d)
#22 0x000000000252f10e clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-3.9+0x252f10e)
#23 0x00000000022136de clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-3.9+0x22136de)
#24 0x00000000021ebe66
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-3.9+0x21ebe66)
#25 0x000000000229e602
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-3.9+0x229e602)
#26 0x0000000000ad1da8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-3.9+0xad1da8)
#27 0x0000000000a8c13e main (/usr/local/clang-trunk/bin/clang-3.9+0xa8c13e)
#28 0x00007f80492e8ec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#29 0x0000000000acddf4 _start (/usr/local/clang-trunk/bin/clang-3.9+0xacddf4)
Stack dump:
0.    Program arguments: /usr/local/clang-trunk/bin/clang-3.9 -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
-momit-leaf-frame-pointer -dwarf-column-info -debugger-tuning=gdb
-coverage-file /data2/small.c -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.9.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/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 -Os -fdebug-compilation-dir /data2
-ferror-limit 19 -fmessage-length 159 -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 'CallGraph Pass Manager' on module 'small.c'.
4.    Running pass 'Loop Pass Manager' on function '@fn2'
5.    Running pass 'Induction Variable Simplification' on basic block
'%for.cond'
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 267855)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/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/small-db075e.c
clang-3.9: note: diagnostic msg: /tmp/small-db075e.sh
clang-3.9: note: diagnostic msg: 

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


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


int a, b, c;
char d;

char
fn1 (int p1, int p2)
{
  return p1 + p2;
}

char
fn2 ()
{
  unsigned e = 4294967295;
  int f = 20;
  for (;;)
    {
      int g = c = -20;
      for (; c; ++c)
    {
      unsigned h = 1;
      d = a;
      if (!a)
        return b;
      for (; h; h++)
        g &= fn1 (e == c, h) == f;
    }
      for (; f; f--)
    ;
    }
}

-- 
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/20160429/c92b0aaf/attachment.html>


More information about the llvm-bugs mailing list