[llvm-bugs] [Bug 37267] New: SROA.cpp:2567: bool llvm::sroa::AllocaSliceRewriter::rewriteIntegerStore(llvm::Value *, llvm::StoreInst &, llvm::AAMDNodes): Assertion `BeginOffset >= NewAllocaBeginOffset && "Out of bounds offset"' failed.

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 27 05:31:35 PDT 2018


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

            Bug ID: 37267
           Summary: SROA.cpp:2567: bool
                    llvm::sroa::AllocaSliceRewriter::rewriteIntegerStore(l
                    lvm::Value *, llvm::StoreInst &, llvm::AAMDNodes):
                    Assertion `BeginOffset >= NewAllocaBeginOffset && "Out
                    of bounds offset"' failed.
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: mikael.holmen at ericsson.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20235
  --> https://bugs.llvm.org/attachment.cgi?id=20235&action=edit
reproducer

Running

 opt -S -o - tr15934_sparc.ll -sroa

yields

opt: ../lib/Transforms/Scalar/SROA.cpp:2567: bool
llvm::sroa::AllocaSliceRewriter::rewriteIntegerStore(llvm::Value *,
llvm::StoreInst &, llvm::AAMDNodes): Assertion `BeginOffset >=
NewAllocaBeginOffset && "Out of bounds offset"' failed.
Stack dump:
0.      Program arguments: ../llvm-patch/build-all/bin/opt -S -o -
tr15934_sparc.ll -sroa 
1.      Running pass 'Function Pass Manager' on module 'tr15934_sparc.ll'.
2.      Running pass 'SROA' on function '@f2'
#0 0x0000000001f3f5d4 PrintStackTraceSignalHandler(void*)
(../llvm-patch/build-all/bin/opt+0x1f3f5d4)
#1 0x0000000001f3fd46 SignalHandler(int)
(../llvm-patch/build-all/bin/opt+0x1f3fd46)
#2 0x00007fc25d381330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#3 0x00007fc25bf70c37 gsignal
/build/eglibc-ripdx6/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#4 0x00007fc25bf74028 abort
/build/eglibc-ripdx6/eglibc-2.19/stdlib/abort.c:91:0
#5 0x00007fc25bf69bf6 __assert_fail_base
/build/eglibc-ripdx6/eglibc-2.19/assert/assert.c:92:0
#6 0x00007fc25bf69ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#7 0x0000000001e67547 (../llvm-patch/build-all/bin/opt+0x1e67547)
#8 0x0000000001e669b1
llvm::sroa::AllocaSliceRewriter::visitStoreInst(llvm::StoreInst&)
(../llvm-patch/build-all/bin/opt+0x1e669b1)
#9 0x0000000001e5e169 llvm::InstVisitor<llvm::sroa::AllocaSliceRewriter,
bool>::visit(llvm::Instruction&) (../llvm-patch/build-all/bin/opt+0x1e5e169)
#10 0x0000000001e4f1ba llvm::sroa::AllocaSliceRewriter::visit((anonymous
namespace)::Slice const*) (../llvm-patch/build-all/bin/opt+0x1e4f1ba)
#11 0x0000000001e4da3f llvm::SROA::rewritePartition(llvm::AllocaInst&,
llvm::sroa::AllocaSlices&, llvm::sroa::Partition&)
(../llvm-patch/build-all/bin/opt+0x1e4da3f)
#12 0x0000000001e4f991 llvm::SROA::splitAlloca(llvm::AllocaInst&,
llvm::sroa::AllocaSlices&) (../llvm-patch/build-all/bin/opt+0x1e4f991)
#13 0x0000000001e51588 llvm::SROA::runOnAlloca(llvm::AllocaInst&)
(../llvm-patch/build-all/bin/opt+0x1e51588)
#14 0x0000000001e5324b llvm::SROA::runImpl(llvm::Function&,
llvm::DominatorTree&, llvm::AssumptionCache&)
(../llvm-patch/build-all/bin/opt+0x1e5324b)
#15 0x0000000001e5bb2e
llvm::sroa::SROALegacyPass::runOnFunction(llvm::Function&)
(../llvm-patch/build-all/bin/opt+0x1e5bb2e)
#16 0x00000000019ea708 llvm::FPPassManager::runOnFunction(llvm::Function&)
(../llvm-patch/build-all/bin/opt+0x19ea708)
#17 0x00000000019ea948 llvm::FPPassManager::runOnModule(llvm::Module&)
(../llvm-patch/build-all/bin/opt+0x19ea948)
#18 0x00000000019eae25 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(../llvm-patch/build-all/bin/opt+0x19eae25)
#19 0x0000000000735055 main (../llvm-patch/build-all/bin/opt+0x735055)
#20 0x00007fc25bf5bf45 __libc_start_main
/build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:321:0
#21 0x000000000071eb1d _start (../llvm-patch/build-all/bin/opt+0x71eb1d)
Abort


This started happening with commit r322533:

    [SROA] fix assetion failure

    This patch fixes the assertion failure in SROA reported in PR35657.
    PR35657 reports the assertion failure due to r319522 (splitting for
non-whole-alloca slices), but this problem can happen even without r319522.

    The problem exists in a check for reusing an existing alloca when rewriting
partitions. As the original comment said, we can reuse the existing alloca if
the new alloca has the same type and offset with the existing one. But the code
checks only type of the alloca and then check the offset using an assert.
    In a corner case with out-of-bounds access (e.g. @PR35657 function added in
unit test), it is possible that the two allocas have the same type but
different offsets.

    This patch makes the check of the offset in the if condition, and
re-enables the splitting for non-whole-alloca slices.

    Differential Revision: https://reviews.llvm.org/D41981

-- 
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/20180427/4333f2ff/attachment.html>


More information about the llvm-bugs mailing list