Skip to content

Commit 3e325b9

Browse files
committed
[DEBUGINFO] Fix missed debug info for bool local var
During type promotion debug info is messed for bool vars.
1 parent d3153ad commit 3e325b9

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -6244,7 +6244,9 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
62446244
SDNodeFlags Flags;
62456245
if (OpOpcode == ISD::ZERO_EXTEND)
62466246
Flags.setNonNeg(N1->getFlags().hasNonNeg());
6247-
return getNode(OpOpcode, DL, VT, N1.getOperand(0), Flags);
6247+
SDValue NewVal = getNode(OpOpcode, DL, VT, N1.getOperand(0), Flags);
6248+
transferDbgValues(N1, NewVal);
6249+
return NewVal;
62486250
}
62496251
if (N1.isUndef())
62506252
// sext(undef) = 0, because the top bits will all be the same.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
; RUN: llc < %s -mtriple=nvptx64-nvidia-cuda | FileCheck %s
2+
3+
declare void @foo(i32)
4+
5+
define void @test1(i32 noundef %gid) !dbg !3 {
6+
entry:
7+
;
8+
; verify that debug info exists for "xyz" variable
9+
;
10+
; CHECK-LABEL: DW_TAG_variable
11+
; CHECK: .b8 120 // DW_AT_name
12+
; CHECK-NEXT: .b8 121
13+
; CHECK-NEXT: .b8 122
14+
; CHECK-NEXT: .b8 0
15+
; CHECK-NEXT: .b8 1 // DW_AT_decl_file
16+
; CHECK-NEXT: .b8 6 // DW_AT_decl_line
17+
;
18+
%cmp = icmp eq i32 %gid, 0, !dbg !12
19+
%conv = zext i1 %cmp to i32, !dbg !12
20+
%conv1 = trunc i32 %conv to i8, !dbg !12
21+
#dbg_value(i8 %conv1, !10, !DIExpression(), !13)
22+
%conv3 = sext i8 %conv1 to i32
23+
call void @foo(i32 %conv3)
24+
ret void
25+
}
26+
27+
!llvm.dbg.cu = !{!0}
28+
!llvm.module.flags = !{!2}
29+
30+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
31+
!1 = !DIFile(filename: "test.cu", directory: "/source/dir")
32+
!2 = !{i32 1, !"Debug Info Version", i32 3}
33+
!3 = distinct !DISubprogram(name: "test1", linkageName: "_test1i", scope: !1, file: !1, line: 5, type: !4, scopeLine: 5, unit: !0, retainedNodes: !8)
34+
!4 = !DISubroutineType(types: !5)
35+
!5 = !{!6, !7}
36+
!6 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "void")
37+
!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
38+
!8 = !{}
39+
!9 = distinct !DILexicalBlock(scope: !3, file: !1, line: 5, column: 30)
40+
!10 = !DILocalVariable(name: "xyz", scope: !9, file: !1, line: 6, type: !11)
41+
!11 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean)
42+
!12 = !DILocation(line: 1, column: 3, scope: !9)
43+
!13 = !DILocation(line: 2, scope: !9)

0 commit comments

Comments
 (0)