[llvm-bugs] [Bug 28570] New: Unsupported memory instruction in sinking pass

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 15 01:35:41 PDT 2016


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

            Bug ID: 28570
           Summary: Unsupported memory instruction in sinking pass
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: yyc1992 at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following reduced IR triggers a "unsupported memory instruction" assertion
when running with `opt -sink bug.ll` (backtrace below, segfault soon after with
assertion off).

```
; ModuleID = 'bug.ll'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define void @f(i32* ()*) {
top:
  %1 = call i32* %0() #0
  fence singlethread seq_cst
  %2 = load i32, i32* %1, align 4
  fence singlethread seq_cst
  %3 = icmp eq i32 %2, 0
  br i1 %3, label %fail, label %pass

fail:                                             ; preds = %top
  br label %pass

pass:                                             ; preds = %fail, %top
  ret void
}

attributes #0 = { nounwind readnone }
```

This was introduced fairly recently. The "unsupported memory operation" was the
`fence singlethread seq_cst`. Bisected to

```
commit bd10da16fd5320ca47b0cf7edcd88d3eabd6d0fe
Author: Nicolai Haehnle <nhaehnle at gmail.com>
Date:   Mon Jul 11 14:11:51 2016 +0000

    [Sink] Don't move calls to readonly functions across stores

    Summary:  

    Reviewers: hfinkel, majnemer, tstellarAMD, sunfish

    Subscribers: llvm-commits

    Differential Revision: http://reviews.llvm.org/D17279  

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275066
91177308-0d34-0410-b5e6-96231b3b80d8  
```

which looks related (the `readnone` attribute on the function call is
important) but the real bug might be somewhere else....

```
#6 0x000000000106b6a0 LLVMInstallFatalErrorHandler
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/lib/Support/ErrorHandling.cpp:133:0 
#7 0x000000000078c8d3 llvm::PointerIntPairInfo<llvm::Instruction const*, 1u,
llvm::PointerLikeTypeTraits<llvm::Instruction const*> >::updatePointer(long,
llvm::Instruction const*)
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/include/llvm/ADT/PointerIntPair.h:159:0 
#8 0x000000000078c8d3 llvm::PointerIntPair<llvm::Instruction const*, 1u, bool,
llvm::PointerLikeTypeTraits<llvm::Instruction const*>,
llvm::PointerIntPairInfo<llvm::Instruction const*, 1u,
llvm::PointerLikeTypeTraits<llvm::Instruction const*> >
>::setPointerAndInt(llvm::Instruction const*, bool)
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/include/llvm/ADT/PointerIntPair.h:75:0 
#9 0x000000000078c8d3 llvm::PointerIntPair<llvm::Instruction const*, 1u, bool,
llvm::PointerLikeTypeTraits<llvm::Instruction const*>,
llvm::PointerIntPairInfo<llvm::Instruction const*, 1u,
llvm::PointerLikeTypeTraits<llvm::Instruction const*> >
>::PointerIntPair(llvm::Instruction const*, bool)
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/include/llvm/ADT/PointerIntPair.h:52:0 
#10 0x000000000078c8d3 llvm::CallSiteBase<llvm::Function const,
llvm::BasicBlock const, llvm::Value const, llvm::User const, llvm::Use const,
llvm::Instruction const, llvm::CallInst const, llvm::InvokeInst const,
llvm::Use const*>::CallSiteBase(llvm::CallInst const*)
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/include/llvm/IR/CallSite.h:54:0 
#11 0x000000000078c8d3 llvm::CallSiteBase<llvm::Function const,
llvm::BasicBlock const, llvm::Value const, llvm::User const, llvm::Use const,
llvm::Instruction const, llvm::CallInst const, llvm::InvokeInst const,
llvm::Use const*>::get(llvm::Value const*)
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/include/llvm/IR/CallSite.h:67:0 
#12 0x000000000078c8d3 llvm::CallSiteBase<llvm::Function const,
llvm::BasicBlock const, llvm::Value const, llvm::User const, llvm::Use const,
llvm::Instruction const, llvm::CallInst const, llvm::InvokeInst const,
llvm::Use const*>::CallSiteBase(llvm::Value const*)
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/include/llvm/IR/CallSite.h:56:0 
#13 0x000000000078c8d3
llvm::ImmutableCallSite::ImmutableCallSite(llvm::Instruction const*)
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/include/llvm/IR/CallSite.h:628:0
#14 0x000000000078c8d3 llvm::AAResults::getModRefInfo(llvm::Instruction*,
llvm::ImmutableCallSite)
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/lib/Analysis/AliasAnalysis.cpp:111:0
#15 0x000000000100aa19 isSafeToMove
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/lib/Transforms/Scalar/Sink.cpp:86:0 
#16 0x000000000100aa19 SinkInstruction
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/lib/Transforms/Scalar/Sink.cpp:150:0 
#17 0x000000000100aa19 ProcessBlock
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/lib/Transforms/Scalar/Sink.cpp:229:0 
#18 0x000000000100aa19 iterativelySinkInstructions(llvm::Function&,
llvm::DominatorTree&, llvm::LoopInfo&, llvm::AAResults&)
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/lib/Transforms/Scalar/Sink.cpp:249:0 
#19 0x0000000000ca6683 llvm::FPPassManager::runOnFunction(llvm::Function&)
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/lib/IR/LegacyPassManager.cpp:1526:0
#20 0x0000000000ca6a3b llvm::FPPassManager::runOnModule(llvm::Module&)
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/lib/IR/LegacyPassManager.cpp:1547:0 
#21 0x0000000000ca6d71 runOnModule
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/lib/IR/LegacyPassManager.cpp:1603:0
#22 0x0000000000ca6d71 llvm::legacy::PassManagerImpl::run(llvm::Module&)
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/lib/IR/LegacyPassManager.cpp:1706:0
#23 0x00000000005c3ca2 main
/home/yuyichao/projects/julia/tests/llvm/deps/srccache/llvm-svn/tools/opt/opt.cpp:674:0
#24 0x00007f9dbf60a741 __libc_start_main (/usr/lib/libc.so.6+0x20741)
#25 0x00000000005f5819 _start (usr/tools/opt+0x5f5819)
Stack dump:
0.      Program arguments: usr/tools/opt -sink bug.ll -o /dev/null 
1.      Running pass 'Function Pass Manager' on module 'bug.ll'.
2.      Running pass 'Code sinking' on function '@f'
```

x-ref https://github.com/JuliaLang/julia/issues/17427

-- 
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/20160715/07f70ea8/attachment.html>


More information about the llvm-bugs mailing list