[prev in list] [next in list] [prev in thread] [next in thread] 

List:       llvm-bugs
Subject:    [llvm-bugs] [Bug 43514] New: AssertingVH error in BypassSlowDivisions on dead srem instruction
From:       via llvm-bugs <llvm-bugs () lists ! llvm ! org>
Date:       2019-09-30 20:38:21
Message-ID: bug-43514-206 () http ! bugs ! llvm ! org/
[Download RAW message or body]

--1569875901.FbC03b0.27963
Date: Mon, 30 Sep 2019 13:38:21 -0700
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://bugs.llvm.org/
Auto-Submitted: auto-generated

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

            Bug ID: 43514
           Summary: AssertingVH error in BypassSlowDivisions on dead srem
                    instruction
           Product: libraries
           Version: 9.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs@nondot.org
          Reporter: andrew@scheidecker.net
                CC: llvm-bugs@lists.llvm.org

Created attachment 22609
  --> https://bugs.llvm.org/attachment.cgi?id=22609&action=edit
crash2.ll

To reproduce (in a debug build, or with assertions enabled):

  llc crash2.ll -O2 -mcpu=sandybridge

crash2.ll:

  target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"

  define fastcc void @functionDef0(i8*, i64) {
  entry:
    %2 = load i8, i8* %0, align 1
    %3 = zext i8 %2 to i64
    %4 = srem i64 %1, %3
    ret void
  }

The essential ingredients seem to be:
  - A 64-bit div/rem that can be optimized to a narrower div/rem
  - The div/rem must be trivially dead. If I change @functionDef0 to return the
result of the srem, then there's no error.
  - Targeting a CPU that has the "slow 64-bit division" feature flag. Whatever
the default target CPU is for X86 doesn't have this problem. I tried
sandybridge, atom, and skylake-avx512, and they all triggered this error.
  - A debug build (or possibly a release build with assertions enabled, but I
haven't tested that)


The error message + call stack:

While deleting: i64 %
An asserting value handle still pointed to this value!
UNREACHABLE executed at C:\Dev\llvm9\llvm\lib\IR\Value.cpp:905!
Stack dump:
0.      Program arguments: llc C:\Build\crash2.ll -O2 -mcpu=sandybridge
1.      Running pass 'Function Pass Manager' on module 'C:\Build\crash2.ll'.
2.      Running pass 'CodeGen Prepare' on function '@functionDef0'
 #0 0x00007ff76959a23c HandleAbort
C:\Dev\llvm9\llvm\lib\Support\Windows\Signals.inc:408:0
 #1 0x00007ffa54b6c3e1 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x6c3e1)
 #2 0x00007ffa54b6e039 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x6e039)
 #3 0x00007ff769487b93 llvm::llvm_unreachable_internal(char const *,char const
*,unsigned int) C:\Dev\llvm9\llvm\lib\Support\ErrorHandling.cpp:215:0
 #4 0x00007ff76862be45 llvm::ValueHandleBase::ValueIsDeleted(class llvm::Value
*) C:\Dev\llvm9\llvm\lib\IR\Value.cpp:908:0
 #5 0x00007ff768627d37 llvm::Value::~Value(void)
C:\Dev\llvm9\llvm\lib\IR\Value.cpp:76:0
 #6 0x00007ff767c071e8 llvm::User::~User(void)
C:\Dev\llvm9\llvm\include\llvm\IR\Constant.h:185:0
 #7 0x00007ff7689091f8 llvm::Instruction::~Instruction(void)
C:\Dev\llvm9\llvm\lib\IR\Instruction.cpp:48:0
 #8 0x00007ff768632908 llvm::UnaryInstruction::~UnaryInstruction(void)
(C:\Build\llvm9\Debug\bin\llc.exe+0x1622908)
 #9 0x00007ff768631978 llvm::CastInst::~CastInst(void)
(C:\Build\llvm9\Debug\bin\llc.exe+0x1621978)
#10 0x00007ff768632a48 llvm::ZExtInst::~ZExtInst(void)
C:\Dev\llvm9\llvm\include\llvm\IR\GlobalVariable.h:78:0
#11 0x00007ff76863571c llvm::ZExtInst::`scalar deleting destructor'(unsigned
int) C:\Dev\llvm9\llvm\include\llvm\ADT\DenseMap.h:1266:0
#12 0x00007ff768629001 llvm::Value::deleteValue(void)
C:\Dev\llvm9\llvm\include\llvm\IR\Instruction.def:185:0
#13 0x00007ff768495878 llvm::ilist_alloc_traits<class
llvm::Instruction>::deleteNode(class llvm::Instruction *)
C:\Dev\llvm9\llvm\include\llvm\IR\Instruction.h:775:0
#14 0x00007ff768495a0f llvm::iplist_impl<class llvm::simple_ilist<class
llvm::Instruction>,class llvm::SymbolTableListTraits<class llvm::Instruction>
> > > erase(class llvm::ilist_iterator<struct
llvm::ilist_detail::node_options<class llvm::Instruction,0,0,void>,0,0>)
C:\Dev\llvm9\llvm\include\llvm\ADT\ilist.h:267:0
#15 0x00007ff768909365 llvm::Instruction::eraseFromParent(void)
C:\Dev\llvm9\llvm\lib\IR\Instruction.cpp:68:0
#16 0x00007ff76962b0b0 llvm::RecursivelyDeleteTriviallyDeadInstructions(class
llvm::SmallVectorImpl<class llvm::Instruction *> &,class
llvm::TargetLibraryInfo const *,class llvm::MemorySSAUpdater *)
C:\Dev\llvm9\llvm\lib\Transforms\Utils\Local.cpp:480:0
#17 0x00007ff76962ae6a llvm::RecursivelyDeleteTriviallyDeadInstructions(class
llvm::Value *,class llvm::TargetLibraryInfo const *,class
llvm::MemorySSAUpdater *)
C:\Dev\llvm9\llvm\lib\Transforms\Utils\Local.cpp:444:0
#18 0x00007ff76968bb3e llvm::bypassSlowDivision(class llvm::BasicBlock *,class
llvm::DenseMap<unsigned int,unsigned int,struct llvm::DenseMapInfo<unsigned
int>,struct llvm::detail::DenseMapPair<unsigned int,unsigned int> > const &)
C:\Dev\llvm9\llvm\lib\Transforms\Utils\BypassSlowDivision.cpp:471:0
#19 0x00007ff768179e82 `anonymous namespace'::CodeGenPrepare::runOnFunction
C:\Dev\llvm9\llvm\lib\CodeGen\CodeGenPrepare.cpp:454:0
#20 0x00007ff7686f980b llvm::FPPassManager::runOnFunction(class llvm::Function
&) C:\Dev\llvm9\llvm\lib\IR\LegacyPassManager.cpp:1648:0
#21 0x00007ff7686f9c0c llvm::FPPassManager::runOnModule(class llvm::Module &)
C:\Dev\llvm9\llvm\lib\IR\LegacyPassManager.cpp:1685:0
#22 0x00007ff7686fb259 `anonymous namespace'::MPPassManager::runOnModule
C:\Dev\llvm9\llvm\lib\IR\LegacyPassManager.cpp:1750:0
#23 0x00007ff7686fbcbc llvm::legacy::PassManagerImpl::run(class llvm::Module &)
C:\Dev\llvm9\llvm\lib\IR\LegacyPassManager.cpp:1863:0
#24 0x00007ff7686f3716 llvm::legacy::PassManager::run(class llvm::Module &)
C:\Dev\llvm9\llvm\lib\IR\LegacyPassManager.cpp:1895:0
#25 0x00007ff7671bd601 compileModule C:\Dev\llvm9\llvm\tools\llc\llc.cpp:603:0
#26 0x00007ff7671be704 main C:\Dev\llvm9\llvm\tools\llc\llc.cpp:355:0
#27 0x00007ff769ef6879 invoke_main
d:\agent\_work\3\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:79:0
#28 0x00007ff769ef675e __scrt_common_main_seh
d:\agent\_work\3\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
#29 0x00007ff769ef661e __scrt_common_main
d:\agent\_work\3\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0
#30 0x00007ff769ef6909 mainCRTStartup
d:\agent\_work\3\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0
#31 0x00007ffacfae7bd4 (C:\WINDOWS\System32\KERNEL32.DLL+0x17bd4)
#32 0x00007ffad15aced1 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x6ced1)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
--1569875901.FbC03b0.27963
Date: Mon, 30 Sep 2019 13:38:21 -0700
MIME-Version: 1.0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://bugs.llvm.org/
Auto-Submitted: auto-generated

<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - AssertingVH error in BypassSlowDivisions on dead srem instruction"
   href="https://bugs.llvm.org/show_bug.cgi?id=43514">43514</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>AssertingVH error in BypassSlowDivisions on dead srem instruction
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>9.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs&#64;nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>andrew&#64;scheidecker.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs&#64;lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22609" \
name="attach_22609" title="crash2.ll">attachment 22609</a> <a \
href="attachment.cgi?id=22609&amp;action=edit" title="crash2.ll">[details]</a></span> \
crash2.ll

To reproduce (in a debug build, or with assertions enabled):

  llc crash2.ll -O2 -mcpu=sandybridge

crash2.ll:

  target datalayout = &quot;e-m:w-i64:64-f80:128-n8:16:32:64-S128&quot;

  define fastcc void &#64;functionDef0(i8*, i64) {
  entry:
    %2 = load i8, i8* %0, align 1
    %3 = zext i8 %2 to i64
    %4 = srem i64 %1, %3
    ret void
  }

The essential ingredients seem to be:
  - A 64-bit div/rem that can be optimized to a narrower div/rem
  - The div/rem must be trivially dead. If I change &#64;functionDef0 to return the
result of the srem, then there's no error.
  - Targeting a CPU that has the &quot;slow 64-bit division&quot; feature flag. \
Whatever the default target CPU is for X86 doesn't have this problem. I tried
sandybridge, atom, and skylake-avx512, and they all triggered this error.
  - A debug build (or possibly a release build with assertions enabled, but I
haven't tested that)


The error message + call stack:

While deleting: i64 %
An asserting value handle still pointed to this value!
UNREACHABLE executed at C:\Dev\llvm9\llvm\lib\IR\Value.cpp:905!
Stack dump:
0.      Program arguments: llc C:\Build\crash2.ll -O2 -mcpu=sandybridge
1.      Running pass 'Function Pass Manager' on module 'C:\Build\crash2.ll'.
2.      Running pass 'CodeGen Prepare' on function '&#64;functionDef0'
 #0 0x00007ff76959a23c HandleAbort
C:\Dev\llvm9\llvm\lib\Support\Windows\Signals.inc:408:0
 #1 0x00007ffa54b6c3e1 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x6c3e1)
 #2 0x00007ffa54b6e039 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x6e039)
 #3 0x00007ff769487b93 llvm::llvm_unreachable_internal(char const *,char const
*,unsigned int) C:\Dev\llvm9\llvm\lib\Support\ErrorHandling.cpp:215:0
 #4 0x00007ff76862be45 llvm::ValueHandleBase::ValueIsDeleted(class llvm::Value
*) C:\Dev\llvm9\llvm\lib\IR\Value.cpp:908:0
 #5 0x00007ff768627d37 llvm::Value::~Value(void)
C:\Dev\llvm9\llvm\lib\IR\Value.cpp:76:0
 #6 0x00007ff767c071e8 llvm::User::~User(void)
C:\Dev\llvm9\llvm\include\llvm\IR\Constant.h:185:0
 #7 0x00007ff7689091f8 llvm::Instruction::~Instruction(void)
C:\Dev\llvm9\llvm\lib\IR\Instruction.cpp:48:0
 #8 0x00007ff768632908 llvm::UnaryInstruction::~UnaryInstruction(void)
(C:\Build\llvm9\Debug\bin\llc.exe+0x1622908)
 #9 0x00007ff768631978 llvm::CastInst::~CastInst(void)
(C:\Build\llvm9\Debug\bin\llc.exe+0x1621978)
#10 0x00007ff768632a48 llvm::ZExtInst::~ZExtInst(void)
C:\Dev\llvm9\llvm\include\llvm\IR\GlobalVariable.h:78:0
#11 0x00007ff76863571c llvm::ZExtInst::`scalar deleting destructor'(unsigned
int) C:\Dev\llvm9\llvm\include\llvm\ADT\DenseMap.h:1266:0
#12 0x00007ff768629001 llvm::Value::deleteValue(void)
C:\Dev\llvm9\llvm\include\llvm\IR\Instruction.def:185:0
#13 0x00007ff768495878 llvm::ilist_alloc_traits&lt;class
llvm::Instruction&gt;::deleteNode(class llvm::Instruction *)
C:\Dev\llvm9\llvm\include\llvm\IR\Instruction.h:775:0
#14 0x00007ff768495a0f llvm::iplist_impl&lt;class llvm::simple_ilist&lt;class
llvm::Instruction&gt;,class llvm::SymbolTableListTraits&lt;class \
llvm::Instruction&gt; <span class="quote">&gt;::erase(class \
llvm::ilist_iterator&lt;struct</span > llvm::ilist_detail::node_options&lt;class \
llvm::Instruction,0,0,void&gt;,0,0&gt;) \
C:\Dev\llvm9\llvm\include\llvm\ADT\ilist.h:267:0 #15 0x00007ff768909365 \
llvm::Instruction::eraseFromParent(void) \
C:\Dev\llvm9\llvm\lib\IR\Instruction.cpp:68:0 #16 0x00007ff76962b0b0 \
llvm::RecursivelyDeleteTriviallyDeadInstructions(class llvm::SmallVectorImpl&lt;class \
llvm::Instruction *&gt; &amp;,class llvm::TargetLibraryInfo const *,class \
llvm::MemorySSAUpdater *) C:\Dev\llvm9\llvm\lib\Transforms\Utils\Local.cpp:480:0
#17 0x00007ff76962ae6a llvm::RecursivelyDeleteTriviallyDeadInstructions(class
llvm::Value *,class llvm::TargetLibraryInfo const *,class
llvm::MemorySSAUpdater *)
C:\Dev\llvm9\llvm\lib\Transforms\Utils\Local.cpp:444:0
#18 0x00007ff76968bb3e llvm::bypassSlowDivision(class llvm::BasicBlock *,class
llvm::DenseMap&lt;unsigned int,unsigned int,struct llvm::DenseMapInfo&lt;unsigned
int&gt;,struct llvm::detail::DenseMapPair&lt;unsigned int,unsigned int&gt; &gt; const \
&amp;) C:\Dev\llvm9\llvm\lib\Transforms\Utils\BypassSlowDivision.cpp:471:0
#19 0x00007ff768179e82 `anonymous namespace'::CodeGenPrepare::runOnFunction
C:\Dev\llvm9\llvm\lib\CodeGen\CodeGenPrepare.cpp:454:0
#20 0x00007ff7686f980b llvm::FPPassManager::runOnFunction(class llvm::Function
&amp;) C:\Dev\llvm9\llvm\lib\IR\LegacyPassManager.cpp:1648:0
#21 0x00007ff7686f9c0c llvm::FPPassManager::runOnModule(class llvm::Module &amp;)
C:\Dev\llvm9\llvm\lib\IR\LegacyPassManager.cpp:1685:0
#22 0x00007ff7686fb259 `anonymous namespace'::MPPassManager::runOnModule
C:\Dev\llvm9\llvm\lib\IR\LegacyPassManager.cpp:1750:0
#23 0x00007ff7686fbcbc llvm::legacy::PassManagerImpl::run(class llvm::Module &amp;)
C:\Dev\llvm9\llvm\lib\IR\LegacyPassManager.cpp:1863:0
#24 0x00007ff7686f3716 llvm::legacy::PassManager::run(class llvm::Module &amp;)
C:\Dev\llvm9\llvm\lib\IR\LegacyPassManager.cpp:1895:0
#25 0x00007ff7671bd601 compileModule C:\Dev\llvm9\llvm\tools\llc\llc.cpp:603:0
#26 0x00007ff7671be704 main C:\Dev\llvm9\llvm\tools\llc\llc.cpp:355:0
#27 0x00007ff769ef6879 invoke_main
d:\agent\_work\3\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:79:0
#28 0x00007ff769ef675e __scrt_common_main_seh
d:\agent\_work\3\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
#29 0x00007ff769ef661e __scrt_common_main
d:\agent\_work\3\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0
#30 0x00007ff769ef6909 mainCRTStartup
d:\agent\_work\3\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0
#31 0x00007ffacfae7bd4 (C:\WINDOWS\System32\KERNEL32.DLL+0x17bd4)
#32 0x00007ffad15aced1 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x6ced1)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>
--1569875901.FbC03b0.27963--


[Attachment #3 (text/plain)]

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic