[llvm-bugs] [Bug 28351] New: clang crashes on valid code at -O2 and -O3 on x86_64-linux-gnu with Assertion `Elt < getNumElements() && "Invalid Elt"' failedAssertion `(i == InductionOperand || PSE.getSE()->isLoopInvariant(PSE.getSCEV(GepOperandInst), OrigLoop)) && "Must be last inde

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 28 22:52:15 PDT 2016


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

            Bug ID: 28351
           Summary: clang crashes on valid code at -O2 and -O3 on
                    x86_64-linux-gnu with Assertion `Elt <
                    getNumElements() && "Invalid Elt"' failedAssertion `(i
                    == InductionOperand ||
                    PSE.getSE()->isLoopInvariant(PSE.getSCEV(GepOperandIns
                    t), OrigLoop)) && "Must be last inde
           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 -O3 when compiling the following
test case on x86_64-linux-gnu in both 32-bit and 64-bit modes.

$ clang-trunk -v
clang version 3.9.0 (trunk 274002)
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
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
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 -O3 abc.c
abc.c:5:5: warning: array index 1 is past the end of the array (which contains
1 element) [-Warray-bounds]
    a[b][1] = 1;
    ^    ~
abc.c:1:1: note: array 'a' declared here
short a[2][1];
^
clang-3.9:
/home/absozero/trunk/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2619:
virtual void (anonymous
namespace)::InnerLoopVectorizer::vectorizeMemoryInstruction(llvm::Instruction
*): Assertion `(i == InductionOperand ||
PSE.getSE()->isLoopInvariant(PSE.getSCEV(GepOperandInst), OrigLoop)) && "Must
be last index or loop invariant"' failed.
#0 0x00000000018cb698 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x18cb698)
#1 0x00000000018c9746 llvm::sys::RunSignalHandlers()
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x18c9746)
#2 0x00000000018cbd8e SignalHandler(int)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x18cbd8e)
#3 0x00007fd9fd899340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007fd9fc416cc9 gsignal
/build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fd9fc41a0d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007fd9fc40fb86 __assert_fail_base
/build/buildd/eglibc-2.19/assert/assert.c:92:0
#7 0x00007fd9fc40fc32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x00000000019bfa99 (anonymous
namespace)::InnerLoopVectorizer::vectorizeMemoryInstruction(llvm::Instruction*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19bfa99)
#9 0x00000000019c3f30 (anonymous
namespace)::InnerLoopVectorizer::vectorizeBlockInLoop(llvm::BasicBlock*,
llvm::SmallVector<llvm::PHINode*, 4u>*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19c3f30)
#10 0x00000000019b4613 (anonymous
namespace)::InnerLoopVectorizer::vectorizeLoop()
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19b4613)
#11 0x00000000019ac89f (anonymous
namespace)::InnerLoopVectorizer::vectorize((anonymous
namespace)::LoopVectorizationLegality*, llvm::MapVector<llvm::Instruction*,
unsigned long, llvm::DenseMap<llvm::Instruction*, unsigned int,
llvm::DenseMapInfo<llvm::Instruction*>,
llvm::detail::DenseMapPair<llvm::Instruction*, unsigned int> >,
std::vector<std::pair<llvm::Instruction*, unsigned long>,
std::allocator<std::pair<llvm::Instruction*, unsigned long> > > > const&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19ac89f)
#12 0x00000000019a298d (anonymous
namespace)::LoopVectorize::processLoop(llvm::Loop*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x19a298d)
#13 0x000000000199d925 (anonymous
namespace)::LoopVectorize::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x199d925)
#14 0x00000000014e7ccf llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x14e7ccf)
#15 0x00000000014e7f1b llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x14e7f1b)
#16 0x00000000014e8405 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x14e8405)
#17 0x0000000001a272c7 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+0x1a272c7)
#18 0x00000000020fe243
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x20fe243)
#19 0x00000000024d06d6 clang::ParseAST(clang::Sema&, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x24d06d6)
#20 0x0000000001de9a85 clang::FrontendAction::Execute()
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1de9a85)
#21 0x0000000001db2341
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1db2341)
#22 0x0000000001e7f65f
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1e7f65f)
#23 0x0000000000770458 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/absozero/trunk/root-clang/bin/clang-3.9+0x770458)
#24 0x000000000076e7b7 main
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x76e7b7)
#25 0x00007fd9fc401ec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#26 0x000000000076bd92 _start
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x76bd92)
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 -O3
-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-b58820.o -x c
abc.c
1.    <eof> parser at end of file
2.    Per-module optimization passes
3.    Running pass 'Function Pass Manager' on module 'abc.c'.
4.    Running pass 'Loop Vectorization' on function '@fn1'
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 274002)
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-96eb9b.c
clang-3.9: note: diagnostic msg: /tmp/abc-96eb9b.sh
clang-3.9: note: diagnostic msg:

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



$ cat abc.c
short a[2][1];
int b;
void fn1() {
  for (; b; b++)
    a[b][1] = 1;
}

-- 
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/20160629/cc19bcef/attachment.html>


More information about the llvm-bugs mailing list