Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 5ea3570

Browse files
committed
Verifier: Reject any unknown named MD nodes in the llvm.dbg namespace.
This came out of a discussion in https://reviews.llvm.org/D25285. There used to be various other llvm.dbg.* nodes, but we don't support upgrading them and we want to reserve the namespace for future uses. This also removes an entirely obsolete and bitrotted testcase for PR7662. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283390 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 6a6f29c commit 5ea3570

File tree

3 files changed

+48
-79
lines changed

3 files changed

+48
-79
lines changed

lib/IR/Verifier.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,10 +698,15 @@ void Verifier::visitGlobalAlias(const GlobalAlias &GA) {
698698
}
699699

700700
void Verifier::visitNamedMDNode(const NamedMDNode &NMD) {
701+
// There used to be various other llvm.dbg.* nodes, but we don't support
702+
// upgrading them and we want to reserve the namespace for future uses.
703+
if (NMD.getName().startswith("llvm.dbg."))
704+
AssertDI(NMD.getName() == "llvm.dbg.cu",
705+
"unrecognized named metadata node in the llvm.dbg namespace",
706+
&NMD);
701707
for (const MDNode *MD : NMD.operands()) {
702-
if (NMD.getName() == "llvm.dbg.cu") {
708+
if (NMD.getName() == "llvm.dbg.cu")
703709
AssertDI(MD && isa<DICompileUnit>(MD), "invalid compile unit", &NMD, MD);
704-
}
705710

706711
if (!MD)
707712
continue;

test/CodeGen/X86/2010-06-01-DeadArg-DbgInfo.ll

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,49 @@
33
; Test to check that unused argument 'this' is not undefined in debug info.
44

55
target triple = "x86_64-apple-darwin10.2"
6+
67
%struct.foo = type { i32 }
78

8-
@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.foo*, i32)* @_ZN3foo3bazEi to i8*)], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0]
9+
@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.foo*, i32)* @_ZN3foo3bazEi to i8*)], section "llvm.metadata"
910

10-
define i32 @_ZN3foo3bazEi(%struct.foo* nocapture %this, i32 %x) nounwind readnone optsize noinline ssp align 2 !dbg !8 {
11-
;CHECK: DEBUG_VALUE: baz:this <- %RDI{{$}}
12-
entry:
13-
tail call void @llvm.dbg.value(metadata %struct.foo* %this, i64 0, metadata !15, metadata !DIExpression()), !dbg !DILocation(scope: !8)
14-
tail call void @llvm.dbg.value(metadata i32 %x, i64 0, metadata !16, metadata !DIExpression()), !dbg !DILocation(scope: !8)
15-
%0 = mul nsw i32 %x, 7, !dbg !29 ; <i32> [#uses=1]
16-
%1 = add nsw i32 %0, 1, !dbg !29 ; <i32> [#uses=1]
17-
ret i32 %1, !dbg !29
11+
; Function Attrs: noinline nounwind optsize readnone ssp
12+
define i32 @_ZN3foo3bazEi(%struct.foo* nocapture %this, i32 %x) #0 align 2 !dbg !4 {
13+
entry:
14+
; CHECK: DEBUG_VALUE: baz:this <- %RDI{{$}}
15+
tail call void @llvm.dbg.value(metadata %struct.foo* %this, i64 0, metadata !13, metadata !16), !dbg !17
16+
tail call void @llvm.dbg.value(metadata i32 %x, i64 0, metadata !18, metadata !16), !dbg !17
17+
%0 = mul nsw i32 %x, 7, !dbg !19
18+
%1 = add nsw i32 %0, 1, !dbg !19
19+
ret i32 %1, !dbg !19
1820
}
1921

20-
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
21-
22-
!llvm.dbg.cu = !{!4}
23-
!llvm.module.flags = !{!34}
24-
!llvm.dbg.lv = !{!0, !14, !15, !16, !17, !24, !25, !28}
25-
26-
!0 = !DILocalVariable(name: "this", line: 11, arg: 1, scope: !1, file: !3, type: !12)
27-
!1 = distinct !DISubprogram(name: "bar", linkageName: "_ZN3foo3barEi", line: 11, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !4, scopeLine: 11, file: !31, scope: !2, type: !9)
28-
!2 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", line: 3, size: 32, align: 32, file: !31, scope: !3, elements: !5)
29-
!3 = !DIFile(filename: "foo.cp", directory: "/tmp/")
30-
!4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "4.2.1 LLVM build", isOptimized: true, emissionKind: FullDebug, file: !31, enums: !32, retainedTypes: !32)
31-
!5 = !{!6, !1, !8}
32-
!6 = !DIDerivedType(tag: DW_TAG_member, name: "y", line: 8, size: 32, align: 32, file: !31, scope: !2, baseType: !7)
33-
!7 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
34-
!8 = distinct !DISubprogram(name: "baz", linkageName: "_ZN3foo3bazEi", line: 15, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !4, scopeLine: 15, file: !31, scope: !2, type: !9)
35-
!9 = !DISubroutineType(types: !10)
36-
!10 = !{!7, !11, !7}
37-
!11 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial, file: !31, scope: !3, baseType: !2)
38-
!12 = !DIDerivedType(tag: DW_TAG_const_type, size: 64, align: 64, flags: DIFlagArtificial, file: !31, scope: !3, baseType: !13)
39-
!13 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, file: !31, scope: !3, baseType: !2)
40-
!14 = !DILocalVariable(name: "x", line: 11, arg: 2, scope: !1, file: !3, type: !7)
41-
!15 = !DILocalVariable(name: "this", line: 15, arg: 1, scope: !8, file: !3, type: !12)
42-
!16 = !DILocalVariable(name: "x", line: 15, arg: 2, scope: !8, file: !3, type: !7)
43-
!17 = !DILocalVariable(name: "argc", line: 19, arg: 1, scope: !18, file: !3, type: !7)
44-
!18 = distinct !DISubprogram(name: "main", linkageName: "main", line: 19, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !4, scopeLine: 19, file: !31, scope: !3, type: !19)
45-
!19 = !DISubroutineType(types: !20)
46-
!20 = !{!7, !7, !21}
47-
!21 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, file: !31, scope: !3, baseType: !22)
48-
!22 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, file: !31, scope: !3, baseType: !23)
49-
!23 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
50-
!24 = !DILocalVariable(name: "argv", line: 19, arg: 2, scope: !18, file: !3, type: !21)
51-
!25 = !DILocalVariable(name: "a", line: 20, scope: !26, file: !3, type: !2)
52-
!26 = distinct !DILexicalBlock(line: 19, column: 0, file: !31, scope: !27)
53-
!27 = distinct !DILexicalBlock(line: 19, column: 0, file: !31, scope: !18)
54-
!28 = !DILocalVariable(name: "b", line: 21, scope: !26, file: !3, type: !7)
55-
!29 = !DILocation(line: 16, scope: !30)
56-
!30 = distinct !DILexicalBlock(line: 15, column: 0, file: !31, scope: !8)
57-
!31 = !DIFile(filename: "foo.cp", directory: "/tmp/")
58-
!32 = !{}
59-
!34 = !{i32 1, !"Debug Info Version", i32 3}
22+
; Function Attrs: nounwind readnone
23+
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
24+
25+
attributes #0 = { noinline nounwind optsize readnone ssp }
26+
attributes #1 = { nounwind readnone }
27+
28+
!llvm.dbg.cu = !{!0}
29+
!llvm.module.flags = !{!3}
30+
31+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "4.2.1 LLVM build", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2)
32+
!1 = !DIFile(filename: "foo.cp", directory: "/tmp/")
33+
!2 = !{}
34+
!3 = !{i32 1, !"Debug Info Version", i32 3}
35+
!4 = distinct !DISubprogram(name: "baz", linkageName: "_ZN3foo3bazEi", scope: !5, file: !1, line: 15, type: !10, isLocal: false, isDefinition: true, scopeLine: 15, virtualIndex: 6, isOptimized: true, unit: !0)
36+
!5 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", scope: !1, file: !1, line: 3, size: 32, align: 32, elements: !6)
37+
!6 = !{!7, !9, !4}
38+
!7 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !5, file: !1, line: 8, baseType: !8, size: 32, align: 32)
39+
!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
40+
!9 = distinct !DISubprogram(name: "bar", linkageName: "_ZN3foo3barEi", scope: !5, file: !1, line: 11, type: !10, isLocal: false, isDefinition: true, scopeLine: 11, virtualIndex: 6, isOptimized: true, unit: !0)
41+
!10 = !DISubroutineType(types: !11)
42+
!11 = !{!8, !12, !8}
43+
!12 = !DIDerivedType(tag: DW_TAG_pointer_type, scope: !1, file: !1, baseType: !5, size: 64, align: 64, flags: DIFlagArtificial)
44+
!13 = !DILocalVariable(name: "this", arg: 1, scope: !4, file: !1, line: 15, type: !14)
45+
!14 = !DIDerivedType(tag: DW_TAG_const_type, scope: !1, file: !1, baseType: !15, size: 64, align: 64, flags: DIFlagArtificial)
46+
!15 = !DIDerivedType(tag: DW_TAG_pointer_type, scope: !1, file: !1, baseType: !5, size: 64, align: 64)
47+
!16 = !DIExpression()
48+
!17 = !DILocation(line: 0, scope: !4)
49+
!18 = !DILocalVariable(name: "x", arg: 2, scope: !4, file: !1, line: 15, type: !8)
50+
!19 = !DILocation(line: 16, scope: !20)
51+
!20 = distinct !DILexicalBlock(scope: !4, file: !1, line: 15)

test/DebugInfo/Generic/2010-07-19-Crash.ll

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)