Skip to content

Commit 0f34707

Browse files
committed
Plus zext-zext case
Signed-off-by: Alexander Peskov <[email protected]>
1 parent 0651492 commit 0f34707

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -6266,7 +6266,9 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
62666266
if (OpOpcode == ISD::ZERO_EXTEND) { // (zext (zext x)) -> (zext x)
62676267
SDNodeFlags Flags;
62686268
Flags.setNonNeg(N1->getFlags().hasNonNeg());
6269-
return getNode(ISD::ZERO_EXTEND, DL, VT, N1.getOperand(0), Flags);
6269+
SDValue NewVal = getNode(ISD::ZERO_EXTEND, DL, VT, N1.getOperand(0), Flags);
6270+
transferDbgValues(N1, NewVal);
6271+
return NewVal;
62706272
}
62716273
if (N1.isUndef())
62726274
// zext(undef) = 0, because the top bits will be zero.

llvm/test/DebugInfo/NVPTX/debug-bool-var.ll

+43-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ declare void @foo(i32)
55
define void @test1(i32 noundef %gid) !dbg !3 {
66
entry:
77
;
8-
; verify that debug info exists for "xyz" variable
8+
; Equivalent of code:
9+
; extern void foo(int);
10+
; void test_kernel_bool(int a) {
11+
; bool xyz = a == 0;
12+
; foo(xyz);
13+
; }
914
;
10-
; CHECK-LABEL: DW_TAG_variable
15+
; Verify that debug info exists for "xyz" variable
16+
;
17+
; CHECK: DW_TAG_variable
1118
; CHECK: .b8 120 // DW_AT_name
1219
; CHECK-NEXT: .b8 121
1320
; CHECK-NEXT: .b8 122
@@ -24,6 +31,35 @@ entry:
2431
ret void
2532
}
2633

34+
define void @test2(i32 noundef %gid) !dbg !14 {
35+
entry:
36+
;
37+
; Equivalent of code:
38+
; extern void foo(int);
39+
; void test_kernel_bool(int a) {
40+
; unsigned char abc = a == 0;
41+
; foo(abc);
42+
; }
43+
;
44+
; Verify that debug info exists for "abc" variable
45+
;
46+
; CHECK: DW_TAG_variable
47+
; CHECK: .b8 97 // DW_AT_name
48+
; CHECK-NEXT: .b8 98
49+
; CHECK-NEXT: .b8 99
50+
; CHECK-NEXT: .b8 0
51+
; CHECK-NEXT: .b8 1 // DW_AT_decl_file
52+
; CHECK-NEXT: .b8 11 // DW_AT_decl_line
53+
;
54+
%cmp = icmp eq i32 %gid, 0, !dbg !17
55+
%conv = zext i1 %cmp to i32, !dbg !17
56+
%conv1 = trunc i32 %conv to i8, !dbg !17
57+
#dbg_value(i8 %conv1, !16, !DIExpression(), !18)
58+
%conv3 = zext i8 %conv1 to i32
59+
call void @foo(i32 %conv3)
60+
ret void
61+
}
62+
2763
!llvm.dbg.cu = !{!0}
2864
!llvm.module.flags = !{!2}
2965

@@ -41,3 +77,8 @@ entry:
4177
!11 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean)
4278
!12 = !DILocation(line: 1, column: 3, scope: !9)
4379
!13 = !DILocation(line: 2, scope: !9)
80+
!14 = distinct !DISubprogram(name: "test2", linkageName: "_test2i", scope: !1, file: !1, line: 10, type: !4, scopeLine: 10, unit: !0, retainedNodes: !8)
81+
!15 = distinct !DILexicalBlock(scope: !14, file: !1, line: 10, column: 30)
82+
!16 = !DILocalVariable(name: "abc", scope: !15, file: !1, line: 11, type: !11)
83+
!17 = !DILocation(line: 11, column: 3, scope: !15)
84+
!18 = !DILocation(line: 12, scope: !15)

0 commit comments

Comments
 (0)