<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 - Instruction combining error with llvm.invariant.end intrinsic"
   href="https://bugs.llvm.org/show_bug.cgi?id=43723">43723</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Instruction combining error with llvm.invariant.end intrinsic
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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>Transformation Utilities
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>kenner@adacore.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider the following small .ll file:

; ModuleID = '<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - I'm not getting email from bugzilla"
   href="show_bug.cgi?id=17">bug17</a>.adb'
source_filename = "<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - I'm not getting email from bugzilla"
   href="show_bug.cgi?id=17">bug17</a>.adb"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define void @_ada_bug17() {
entry:
  %tab = alloca [10 x i8], align 16
  %0 = bitcast [10 x i8]* %tab to i8*
  call void @llvm.memset.p0i8.i64(i8* align 16 %0, i8 9, i64 10, i1 false)
  %1= bitcast [10 x i8]* %tab to i8*
  %2 = call {}* @llvm.invariant.start.p0i8(i64 10, i8* align 16 %1)
  call void @llvm.invariant.end.p0i8({}* %2, i64 10, i8* align 16 %1)
  ret void
}

; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture nonnull writeonly, i8, i64, i1 
immarg) #0

; Function Attrs: argmemonly nounwind
declare {}* @llvm.invariant.start.p0i8(i64 immarg, i8* nocapture nonnull
readonl
y) #0

; Function Attrs: argmemonly nounwind
declare void @llvm.invariant.end.p0i8({}*, i64 immarg, i8* nocapture nonnull
rea
donly) #0

This crashes when being optimized with -O1, producing:

IC: ERASE   %0 = call {}* @llvm.invariant.start.p0i8(i64 10, i8* align 16
undef)
opt:
/llvm.a/gnat-llvm/llvm/llvm-9.0.0.src/lib/Transforms/InstCombine/InstCombineInternal.h:646:
llvm::Instruction*
llvm::InstCombiner::eraseInstFromFunction(llvm::Instruction&): Assertion
`I.use_empty() && "Cannot erase instruction that is used!"' failed.</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>