Skip to content

Commit 7b039c0

Browse files
authored
[DebugInfo][RemoveDIs] Fix error from not tracking seen debug labels (#88718)
Fixes the reported errors on: #87379 A previous patch updated the bitcode reading for debug intrinsics/records to not perform the expensive debug info format conversion from records to intrinsics in cases where no records were present, but the patch did not actually track when debug labels had been seen, resulting in errors when parsing bitcode where functions contained debug label records but no other debug records. This patch fixes that case and adds a test for it.
1 parent 673da8c commit 7b039c0

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6454,6 +6454,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
64546454
case bitc::FUNC_CODE_DEBUG_RECORD_LABEL: {
64556455
// DbgLabelRecords are placed after the Instructions that they are
64566456
// attached to.
6457+
SeenDebugRecord = true;
64576458
Instruction *Inst = getLastInstruction();
64586459
if (!Inst)
64596460
return error("Invalid dbg record: missing instruction");
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
;; Tests that we can parse and print a function containing a debug label record
2+
;; and no other debug record kinds.
3+
4+
; RUN: llvm-as --write-experimental-debuginfo-iterators-to-bitcode=true %s -o - \
5+
; RUN: | opt -S | FileCheck %s --check-prefixes=CHECK,INTRINSIC
6+
7+
; RUN: llvm-as --write-experimental-debuginfo-iterators-to-bitcode=true %s -o - \
8+
; RUN: | opt -S --preserve-input-debuginfo-format=true \
9+
; RUN: | FileCheck %s --check-prefixes=CHECK,RECORD
10+
11+
source_filename = "bbi-94196.c"
12+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
13+
target triple = "x86_64-unknown-linux-gnu"
14+
15+
; CHECK-LABEL: void @foo()
16+
; CHECK: bar:
17+
; INTRINSIC-NEXT: call void @llvm.dbg.label(metadata ![[LABEL:[0-9]+]]), !dbg ![[LOC:[0-9]+]]
18+
; RECORD-NEXT: #dbg_label(![[LABEL:[0-9]+]], ![[LOC:[0-9]+]])
19+
20+
; CHECK-DAG: ![[LABEL]] = !DILabel({{.*}}name: "bar"
21+
; CHECK-DAG: ![[LOC]] = !DILocation(line: 5, column: 1
22+
23+
define dso_local void @foo() !dbg !5 {
24+
entry:
25+
br label %bar, !dbg !9
26+
27+
bar: ; preds = %entry
28+
tail call void @llvm.dbg.label(metadata !10), !dbg !11
29+
ret void, !dbg !12
30+
}
31+
32+
declare void @llvm.dbg.label(metadata)
33+
34+
!llvm.dbg.cu = !{!0}
35+
!llvm.module.flags = !{!2, !3}
36+
!llvm.ident = !{!4}
37+
38+
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 19.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
39+
!1 = !DIFile(filename: "<stdin>", directory: "/home/gbtozers/dev/llvm-project-ddd-textual-ir")
40+
!2 = !{i32 2, !"Debug Info Version", i32 3}
41+
!3 = !{i32 1, !"wchar_size", i32 4}
42+
!4 = !{!"clang version 19.0.0git"}
43+
!5 = distinct !DISubprogram(name: "foo", scope: !6, file: !6, line: 1, type: !7, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !0)
44+
!6 = !DIFile(filename: "bbi-94196.c", directory: "/home/gbtozers/dev/llvm-project-ddd-textual-ir")
45+
!7 = !DISubroutineType(types: !8)
46+
!8 = !{null}
47+
!9 = !DILocation(line: 3, column: 3, scope: !5)
48+
!10 = !DILabel(scope: !5, name: "bar", file: !6, line: 5)
49+
!11 = !DILocation(line: 5, column: 1, scope: !5)
50+
!12 = !DILocation(line: 6, column: 3, scope: !5)

0 commit comments

Comments
 (0)