[llvm-bugs] [Bug 37883] New: [InstCombine][DebugInfo] replaceInstUsesWith() makes dbg.values point to mis-sized values

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 20 15:42:51 PDT 2018


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

            Bug ID: 37883
           Summary: [InstCombine][DebugInfo] replaceInstUsesWith() makes
                    dbg.values point to mis-sized values
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: anastasis.gramm2 at gmail.com
                CC: llvm-bugs at lists.llvm.org

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.

-- 
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/20180620/4e3c0ad2/attachment.html>


More information about the llvm-bugs mailing list