Reapply "[SelectionDAG] Selection of DBG_VALUE using a PHI node result (pt 2)"
Summary:
This reverts SVN r331441 (reapplies r331337), together with a fix
in to handle an already existing fragment expression in the
dbg.value that must be fragmented due to a split PHI node.
This should solve the problem seen in PR37321, which was the
reason for the revert of r331337.
The situation in PR37321 is that we have a PHI node like this
%u.sroa = phi i80 [ %u.sroa.x, %if.x ],
[ %u.sroa.y, %if.y ],
[ %u.sroa.z, %if.z ]
and a dbg.value like this
call void @llvm.dbg.value(metadata i80 %u.sroa,
metadata !13,
metadata !DIExpression(DW_OP_LLVM_fragment, 0, 80))
The phi node is split into three 32-bit PHI nodes
%30:gr32 = PHI %11:gr32, %bb.4, %14:gr32, %bb.5, %27:gr32, %bb.8
%31:gr32 = PHI %12:gr32, %bb.4, %15:gr32, %bb.5, %28:gr32, %bb.8
%32:gr32 = PHI %13:gr32, %bb.4, %16:gr32, %bb.5, %29:gr32, %bb.8
but since the original value only is 80 bits we need to adjust the size
of the last fragment expression, and with this patch we get
DBG_VALUE debug-use %30:gr32, debug-use $noreg, !"u", !DIExpression(DW_OP_LLVM_fragment, 0, 32)
DBG_VALUE debug-use %31:gr32, debug-use $noreg, !"u", !DIExpression(DW_OP_LLVM_fragment, 32, 32)
DBG_VALUE debug-use %32:gr32, debug-use $noreg, !"u", !DIExpression(DW_OP_LLVM_fragment, 64, 16)
Reviewers: vsk, aprantl, mstorsjo
Reviewed By: aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D46384
llvm-svn: 331464
2018-05-04 01:04:16 +08:00
|
|
|
; RUN: llc -start-after=codegenprepare -stop-before expand-isel-pseudos -o - %s | FileCheck %s
|
|
|
|
|
|
|
|
; This is a reproducer based on the test case from PR37321.
|
|
|
|
|
|
|
|
; We verify that the fragment for the last DBG_VALUE is limited depending
|
|
|
|
; on the size of the original fragment (and that we do not emit more
|
|
|
|
; DBG_VALUE instructions than needed in case we cover the whole original
|
|
|
|
; fragment with just a few DBG_VALUE instructions).
|
|
|
|
|
|
|
|
; CHECK-LABEL: bb.{{.*}}.if.end36:
|
|
|
|
; CHECK: [[REG1:%[0-9]+]]:gr32 = PHI
|
|
|
|
; CHECK-NEXT: [[REG2:%[0-9]+]]:gr32 = PHI
|
|
|
|
; CHECK-NEXT: [[REG3:%[0-9]+]]:gr32 = PHI
|
|
|
|
; CHECK-NEXT: DBG_VALUE debug-use [[REG1]], debug-use $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 0, 32)
|
|
|
|
; CHECK-NEXT: DBG_VALUE debug-use [[REG2]], debug-use $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 32, 32)
|
|
|
|
; CHECK-NEXT: DBG_VALUE debug-use [[REG3]], debug-use $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 64, 16)
|
|
|
|
; CHECK-NEXT: DBG_VALUE debug-use [[REG1]], debug-use $noreg, !12, !DIExpression(DW_OP_LLVM_fragment, 10, 32)
|
|
|
|
; CHECK-NEXT: DBG_VALUE debug-use [[REG2]], debug-use $noreg, !12, !DIExpression(DW_OP_LLVM_fragment, 42, 13)
|
|
|
|
; CHECK-NOT: DBG_VALUE
|
|
|
|
|
|
|
|
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
|
|
|
|
target triple = "i686-w64-windows-gnu"
|
|
|
|
|
|
|
|
; Function Attrs: nounwind readnone
|
|
|
|
define dso_local i64 @nextafterl(i80 %a) local_unnamed_addr #0 !dbg !6 {
|
|
|
|
entry:
|
|
|
|
br i1 undef, label %if.else, label %if.then13, !dbg !28
|
|
|
|
|
|
|
|
if.then13: ; preds = %entry
|
|
|
|
%u.sroa.0.8.insert.insert = or i80 %a, 2222, !dbg !29
|
|
|
|
br label %if.end36, !dbg !33
|
|
|
|
|
|
|
|
if.else: ; preds = %entry
|
|
|
|
br label %if.end36
|
|
|
|
|
|
|
|
if.end36: ; preds = %if.else, %if.then13
|
|
|
|
%u.sroa.0.1.in = phi i80 [ %u.sroa.0.8.insert.insert, %if.then13 ], [ 1234567, %if.else ]
|
|
|
|
call void @llvm.dbg.value(metadata i80 %u.sroa.0.1.in, metadata !13, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 80)), !dbg !34
|
|
|
|
call void @llvm.dbg.value(metadata i80 %u.sroa.0.1.in, metadata !12, metadata !DIExpression(DW_OP_LLVM_fragment, 10, 45)), !dbg !34
|
|
|
|
%u.sroa.0.0.extract.ashr = ashr i80 %u.sroa.0.1.in, 8, !dbg !35
|
|
|
|
%u.sroa.0.0.extract.trunc = trunc i80 %u.sroa.0.0.extract.ashr to i64, !dbg !35
|
|
|
|
ret i64 %u.sroa.0.0.extract.trunc
|
|
|
|
}
|
|
|
|
|
|
|
|
; Function Attrs: nounwind readnone speculatable
|
|
|
|
declare void @llvm.dbg.value(metadata, metadata, metadata) #1
|
|
|
|
|
|
|
|
attributes #0 = { nounwind readnone }
|
|
|
|
attributes #1 = { nounwind readnone speculatable }
|
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
|
|
!llvm.module.flags = !{!26, !27}
|
|
|
|
|
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 7.0.0 (trunk 330808) (llvm/trunk 330813)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3)
|
|
|
|
!1 = !DIFile(filename: "pr37321.c", directory: "")
|
|
|
|
!2 = !{}
|
|
|
|
!3 = !{!4}
|
|
|
|
!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
|
|
|
|
!5 = distinct !DIGlobalVariable(name: "normal_bit", scope: !6, file: !1, line: 31, type: !25, isLocal: true, isDefinition: true)
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
|
|
|
!6 = distinct !DISubprogram(name: "nextafterl", scope: !1, file: !1, line: 17, type: !7, isLocal: false, isDefinition: true, scopeLine: 18, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !10)
|
Reapply "[SelectionDAG] Selection of DBG_VALUE using a PHI node result (pt 2)"
Summary:
This reverts SVN r331441 (reapplies r331337), together with a fix
in to handle an already existing fragment expression in the
dbg.value that must be fragmented due to a split PHI node.
This should solve the problem seen in PR37321, which was the
reason for the revert of r331337.
The situation in PR37321 is that we have a PHI node like this
%u.sroa = phi i80 [ %u.sroa.x, %if.x ],
[ %u.sroa.y, %if.y ],
[ %u.sroa.z, %if.z ]
and a dbg.value like this
call void @llvm.dbg.value(metadata i80 %u.sroa,
metadata !13,
metadata !DIExpression(DW_OP_LLVM_fragment, 0, 80))
The phi node is split into three 32-bit PHI nodes
%30:gr32 = PHI %11:gr32, %bb.4, %14:gr32, %bb.5, %27:gr32, %bb.8
%31:gr32 = PHI %12:gr32, %bb.4, %15:gr32, %bb.5, %28:gr32, %bb.8
%32:gr32 = PHI %13:gr32, %bb.4, %16:gr32, %bb.5, %29:gr32, %bb.8
but since the original value only is 80 bits we need to adjust the size
of the last fragment expression, and with this patch we get
DBG_VALUE debug-use %30:gr32, debug-use $noreg, !"u", !DIExpression(DW_OP_LLVM_fragment, 0, 32)
DBG_VALUE debug-use %31:gr32, debug-use $noreg, !"u", !DIExpression(DW_OP_LLVM_fragment, 32, 32)
DBG_VALUE debug-use %32:gr32, debug-use $noreg, !"u", !DIExpression(DW_OP_LLVM_fragment, 64, 16)
Reviewers: vsk, aprantl, mstorsjo
Reviewed By: aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D46384
llvm-svn: 331464
2018-05-04 01:04:16 +08:00
|
|
|
!7 = !DISubroutineType(types: !8)
|
|
|
|
!8 = !{!9, !9, !9}
|
|
|
|
!9 = !DIBasicType(name: "long double", size: 96, encoding: DW_ATE_float)
|
|
|
|
!10 = !{!11, !12, !13}
|
|
|
|
!11 = !DILocalVariable(name: "x", arg: 1, scope: !6, file: !1, line: 17, type: !9)
|
|
|
|
!12 = !DILocalVariable(name: "y", arg: 2, scope: !6, file: !1, line: 17, type: !9)
|
|
|
|
!13 = !DILocalVariable(name: "u", scope: !6, file: !1, line: 27, type: !14)
|
|
|
|
!14 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !6, file: !1, line: 19, size: 128, elements: !15)
|
|
|
|
!15 = !{!16, !17}
|
|
|
|
!16 = !DIDerivedType(tag: DW_TAG_member, name: "ld", scope: !14, file: !1, line: 20, baseType: !9, size: 96)
|
|
|
|
!17 = !DIDerivedType(tag: DW_TAG_member, name: "parts", scope: !14, file: !1, line: 26, baseType: !18, size: 128)
|
|
|
|
!18 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !14, file: !1, line: 21, size: 128, elements: !19)
|
|
|
|
!19 = !{!20, !22, !24}
|
|
|
|
!20 = !DIDerivedType(tag: DW_TAG_member, name: "mantissa", scope: !18, file: !1, line: 23, baseType: !21, size: 64)
|
|
|
|
!21 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned)
|
|
|
|
!22 = !DIDerivedType(tag: DW_TAG_member, name: "expn", scope: !18, file: !1, line: 24, baseType: !23, size: 16, offset: 64)
|
|
|
|
!23 = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned)
|
|
|
|
!24 = !DIDerivedType(tag: DW_TAG_member, name: "pad", scope: !18, file: !1, line: 25, baseType: !23, size: 16, offset: 80)
|
|
|
|
!25 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !21)
|
|
|
|
!26 = !{i32 2, !"Debug Info Version", i32 3}
|
|
|
|
!27 = !{i32 1, !"wchar_size", i32 2}
|
|
|
|
!28 = !DILocation(line: 47, column: 7, scope: !6)
|
|
|
|
!29 = !DILocation(line: 51, column: 14, scope: !30)
|
|
|
|
!30 = distinct !DILexicalBlock(scope: !31, file: !1, line: 50, column: 11)
|
|
|
|
!31 = distinct !DILexicalBlock(scope: !32, file: !1, line: 48, column: 5)
|
|
|
|
!32 = distinct !DILexicalBlock(scope: !6, file: !1, line: 47, column: 7)
|
|
|
|
!33 = !DILocation(line: 51, column: 2, scope: !30)
|
|
|
|
!34 = !DILocation(line: 27, column: 5, scope: !6)
|
|
|
|
!35 = !DILocation(line: 63, column: 22, scope: !36)
|
|
|
|
!36 = distinct !DILexicalBlock(scope: !6, file: !1, line: 62, column: 7)
|