<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 - [InstCombine][DebugInfo] replaceInstUsesWith() makes dbg.values point to mis-sized values"
   href="https://bugs.llvm.org/show_bug.cgi?id=37883">37883</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[InstCombine][DebugInfo] replaceInstUsesWith() makes dbg.values point to mis-sized values
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>anastasis.gramm2@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In the following IR snippet instCombine turns the 
dbg.value for %and to something unusuable, by expanding
the size of the %and and then doing replaceAllUsesWith [RAUW]

(relevant code at InstCombine/InstCombineCasts.cpp: 
Instruction *InstCombiner::visitZExt(ZExtInst &CI) )

define <2 x i64> @test-fun(<2 x i64> %A) {                                      
  %trunc = trunc <2 x i64> %A to <2 x i32>                                      
  %and = and <2 x i32> %trunc, <i32 23, i32 42>                                 
  %zext = zext <2 x i32> %and to <2 x i64>                                      
  ret <2 x i64> %zext                                                           
}

$ opt -debugify -instcombine test.ll
(( Notice !10 ))

; ModuleID = 'test.ll'
source_filename = "test.ll"

define <2 x i64> @test-vector(<2 x i64> %A) !dbg !6 {
  %and = and <2 x i64> %A, <i64 23, i64 42>, !dbg !14
  call void @llvm.dbg.value(metadata <2 x i64> %and, metadata !12, metadata
!DIExpression()), !dbg !15
  ret <2 x i64> %and, !dbg !16
}

; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.value(metadata, metadata, metadata) #0

attributes #0 = { nounwind readnone speculatable }

!llvm.dbg.cu = !{!0}
!llvm.debugify = !{!3, !4}
!llvm.module.flags = !{!5}

!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer:
"debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug,
enums: !2)
!1 = !DIFile(filename: "test.ll", directory: "/")
!2 = !{}
!3 = !{i32 4}
!4 = !{i32 3}
!5 = !{i32 2, !"Debug Info Version", i32 3}
!6 = distinct !DISubprogram(name: "test-vector", linkageName: "test-vector",
scope: null, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true,
scopeLine: 1, isOptimized: true, unit: !0, retainedNodes: !8)
!7 = !DISubroutineType(types: !2)
!8 = !{!9, !11, !12}
!9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10)
!10 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_unsigned)
!11 = !DILocalVariable(name: "2", scope: !6, file: !1, line: 2, type: !10)
!12 = !DILocalVariable(name: "3", scope: !6, file: !1, line: 3, type: !13)
!13 = !DIBasicType(name: "ty128", size: 128, encoding: DW_ATE_unsigned)
!14 = !DILocation(line: 2, column: 1, scope: !6)
!15 = !DILocation(line: 3, column: 1, scope: !6)
!16 = !DILocation(line: 4, column: 1, scope: !6)

This is not used because currently instCombine drops that 
debug intrisinc. This poses a problem when trying to preserve the DI.</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>