Skip to content

Commit 595d6e2

Browse files
authored
[IR] Find types used by DIExpressions in debug records (llvm#892)
2 parents 18e6036 + d0a5845 commit 595d6e2

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

llvm/lib/IR/TypeFinder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ void TypeFinder::run(const Module &M, bool onlyNamed) {
9999
if (DVI->isDbgAssign()) {
100100
if (Value *Addr = DVI->getAddress())
101101
incorporateValue(Addr);
102+
if (auto *Expr = DVI->getRawAddressExpression())
103+
incorporateMDNode(Expr);
102104
}
105+
if (auto *Expr = DVI->getRawExpression())
106+
incorporateMDNode(Expr);
103107
}
104108
}
105109
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
2+
3+
; CHECK: %struct.S = type { i32 }
4+
%struct.S = type { i32 }
5+
6+
define dso_local i32 @f() !dbg !7 {
7+
entry:
8+
; CHECK: #dbg_value(ptr null, !9, !DIExpression(DIOpArg(0, ptr), DIOpDeref(%struct.S)), !11)
9+
#dbg_value(ptr null, !9, !DIExpression(DIOpArg(0, ptr), DIOpDeref(%struct.S)), !11)
10+
ret i32 0, !dbg !11
11+
}
12+
13+
!llvm.dbg.cu = !{!0}
14+
!llvm.module.flags = !{!3, !4, !5}
15+
!llvm.ident = !{!6}
16+
17+
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 18.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
18+
!1 = !DIFile(filename: "print.c", directory: "/tmp")
19+
!2 = !{}
20+
!3 = !{i32 2, !"Dwarf Version", i32 5}
21+
!4 = !{i32 2, !"Debug Info Version", i32 3}
22+
!5 = !{i32 1, !"wchar_size", i32 4}
23+
!6 = !{!"clang version 18.0.0"}
24+
!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
25+
!8 = !DISubroutineType(types: !2)
26+
!9 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 3, type: !10)
27+
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
28+
!11 = !DILocation(line: 3, column: 15, scope: !7)

0 commit comments

Comments
 (0)