summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-20 20:35:17 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-20 20:35:17 +0000
commita5c57ccf2da8fed28a96f12c3227577c580ea0ad (patch)
treeb2259107254c2a26569cf86c0882735b4a273d40 /llvm
parente0c4f7eb819ed99b66af11466cc2905e78941562 (diff)
downloadbcm5719-llvm-a5c57ccf2da8fed28a96f12c3227577c580ea0ad.tar.gz
bcm5719-llvm-a5c57ccf2da8fed28a96f12c3227577c580ea0ad.zip
IR: Change MDFile to directly store the filename/directory
In the old (well, current) schema, there are two types of file references: untagged and tagged (the latter references the former). !0 = !{!"filename", !"/directory"} !1 = !{!"0x29", !1} ; DW_TAG_file_type [filename] [/directory] The interface to `DIBuilder` universally takes the tagged version, described by `DIFile`. However, most `file:` references actually use the untagged version directly. In the new hierarchy, I'm merging this into a single node: `MDFile`. Originally I'd planned to keep the old schema unchanged until after I moved the new hierarchy into place. However, it turns out to be trivial to make `MDFile` match both nodes at the same time. - Anyone referencing !1 does so through `DIFile`, whose implementation I need to gut anyway (as I do the rest of the `DIDescriptor`s). - Anyone referencing !0 just references an `MDNode`, and expects a node with two `MDString` operands. This commit achieves that, and updates all the testcases for the parts of the new hierarchy that used the two-node schema (I've replaced the untagged nodes with `distinct !{}` to make the diff clear (otherwise the metadata all gets renumbered); it might be worthwhile to come back and delete those nodes and renumber the world, not sure). llvm-svn: 230057
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/IR/DebugInfoMetadata.h22
-rw-r--r--llvm/lib/IR/DebugInfoMetadata.cpp7
-rw-r--r--llvm/test/Assembler/debug-info.ll24
-rw-r--r--llvm/test/Assembler/mdcompileunit.ll2
-rw-r--r--llvm/test/Assembler/mdglobalvariable.ll6
-rw-r--r--llvm/test/Assembler/mdlexicalblock.ll2
-rw-r--r--llvm/test/Assembler/mdlocalvariable.ll10
-rw-r--r--llvm/test/Assembler/mdnamespace.ll2
-rw-r--r--llvm/test/Assembler/mdobjcproperty.ll6
-rw-r--r--llvm/test/Assembler/mdsubprogram.ll2
10 files changed, 33 insertions, 50 deletions
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index a2a4666d897..4534a149257 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -754,25 +754,11 @@ public:
TempMDFile clone() const { return cloneImpl(); }
- MDTuple *getFileNode() const { return cast<MDTuple>(getOperand(0)); }
+ StringRef getFilename() const { return getStringOperand(0); }
+ StringRef getDirectory() const { return getStringOperand(1); }
- StringRef getFilename() const {
- if (auto *S = getRawFilename())
- return S->getString();
- return StringRef();
- }
- StringRef getDirectory() const {
- if (auto *S = getRawDirectory())
- return S->getString();
- return StringRef();
- }
-
- MDString *getRawFilename() const {
- return cast_or_null<MDString>(getFileNode()->getOperand(0));
- }
- MDString *getRawDirectory() const {
- return cast_or_null<MDString>(getFileNode()->getOperand(1));
- }
+ MDString *getRawFilename() const { return getOperandAs<MDString>(0); }
+ MDString *getRawDirectory() const { return getOperandAs<MDString>(1); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == MDFileKind;
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index 83c816d18ae..89ec1bc9a9f 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -210,11 +210,8 @@ MDFile *MDFile::getImpl(LLVMContext &Context, MDString *Filename,
assert(isCanonical(Filename) && "Expected canonical MDString");
assert(isCanonical(Directory) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDFile, (getString(Filename), getString(Directory)));
- Metadata *NodeOps[] = {Filename, Directory};
- Metadata *Ops[] = {MDTuple::get(Context, NodeOps)};
- return storeImpl(new (ArrayRef<Metadata *>(Ops).size())
- MDFile(Context, Storage, Ops),
- Storage, Context.pImpl->MDFiles);
+ Metadata *Ops[] = {Filename, Directory};
+ DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(MDFile, Ops);
}
MDCompileUnit *MDCompileUnit::getImpl(
diff --git a/llvm/test/Assembler/debug-info.ll b/llvm/test/Assembler/debug-info.ll
index 7d71a26c6ad..9b808bd2355 100644
--- a/llvm/test/Assembler/debug-info.ll
+++ b/llvm/test/Assembler/debug-info.ll
@@ -28,35 +28,35 @@
!9 = !MDBasicType(tag: DW_TAG_base_type)
!10 = !MDBasicType(tag: DW_TAG_base_type, name: "", size: 0, align: 0, encoding: 0)
-; CHECK-NEXT: !9 = !{!"path/to/file", !"/path/to/dir"}
+; CHECK-NEXT: !9 = distinct !{}
; CHECK-NEXT: !10 = !MDFile(filename: "path/to/file", directory: "/path/to/dir")
-; CHECK-NEXT: !11 = !{null, null}
+; CHECK-NEXT: !11 = distinct !{}
; CHECK-NEXT: !12 = !MDFile(filename: "", directory: "")
-!11 = !{!"path/to/file", !"/path/to/dir"}
+!11 = distinct !{}
!12 = !MDFile(filename: "path/to/file", directory: "/path/to/dir")
-!13 = !{null, null}
+!13 = distinct !{}
!14 = !MDFile(filename: "", directory: "")
; CHECK-NEXT: !13 = !MDDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 32, align: 32)
!15 = !MDDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32, align: 32)
-; CHECK-NEXT: !14 = !MDCompositeType(tag: DW_TAG_structure_type, name: "MyType", file: !9, line: 2, size: 32, align: 32, identifier: "MangledMyType")
-; CHECK-NEXT: !15 = distinct !MDCompositeType(tag: DW_TAG_structure_type, name: "Base", file: !9, line: 3, scope: !14, size: 128, align: 32, offset: 64, flags: 3, elements: !16, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !15, templateParams: !18, identifier: "MangledBase")
+; CHECK-NEXT: !14 = !MDCompositeType(tag: DW_TAG_structure_type, name: "MyType", file: !10, line: 2, size: 32, align: 32, identifier: "MangledMyType")
+; CHECK-NEXT: !15 = distinct !MDCompositeType(tag: DW_TAG_structure_type, name: "Base", file: !10, line: 3, scope: !14, size: 128, align: 32, offset: 64, flags: 3, elements: !16, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !15, templateParams: !18, identifier: "MangledBase")
; CHECK-NEXT: !16 = !{!17}
-; CHECK-NEXT: !17 = !MDDerivedType(tag: DW_TAG_member, name: "field", file: !9, line: 4, scope: !15, baseType: !6, size: 32, align: 32, offset: 32, flags: 3)
+; CHECK-NEXT: !17 = !MDDerivedType(tag: DW_TAG_member, name: "field", file: !10, line: 4, scope: !15, baseType: !6, size: 32, align: 32, offset: 32, flags: 3)
; CHECK-NEXT: !18 = !{!6}
-; CHECK-NEXT: !19 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Derived", file: !9, line: 3, scope: !14, baseType: !15, size: 128, align: 32, offset: 64, flags: 3, elements: !20, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !15, templateParams: !18, identifier: "MangledBase")
+; CHECK-NEXT: !19 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Derived", file: !10, line: 3, scope: !14, baseType: !15, size: 128, align: 32, offset: 64, flags: 3, elements: !20, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !15, templateParams: !18, identifier: "MangledBase")
; CHECK-NEXT: !20 = !{!21}
; CHECK-NEXT: !21 = !MDDerivedType(tag: DW_TAG_inheritance, scope: !19, baseType: !15)
; CHECK-NEXT: !22 = !MDDerivedType(tag: DW_TAG_ptr_to_member_type, baseType: !6, size: 32, align: 32, extraData: !15)
; CHECK-NEXT: !23 = !MDCompositeType(tag: DW_TAG_structure_type)
; CHECK-NEXT: !24 = !MDCompositeType(tag: DW_TAG_structure_type, runtimeLang: DW_LANG_Cobol85)
-!16 = !MDCompositeType(tag: DW_TAG_structure_type, name: "MyType", file: !11, line: 2, size: 32, align: 32, identifier: "MangledMyType")
-!17 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Base", file: !11, line: 3, scope: !16, size: 128, align: 32, offset: 64, flags: 3, elements: !18, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !17, templateParams: !20, identifier: "MangledBase")
+!16 = !MDCompositeType(tag: DW_TAG_structure_type, name: "MyType", file: !12, line: 2, size: 32, align: 32, identifier: "MangledMyType")
+!17 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Base", file: !12, line: 3, scope: !16, size: 128, align: 32, offset: 64, flags: 3, elements: !18, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !17, templateParams: !20, identifier: "MangledBase")
!18 = !{!19}
-!19 = !MDDerivedType(tag: DW_TAG_member, name: "field", file: !11, line: 4, scope: !17, baseType: !7, size: 32, align: 32, offset: 32, flags: 3)
+!19 = !MDDerivedType(tag: DW_TAG_member, name: "field", file: !12, line: 4, scope: !17, baseType: !7, size: 32, align: 32, offset: 32, flags: 3)
!20 = !{!7}
-!21 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Derived", file: !11, line: 3, scope: !16, baseType: !17, size: 128, align: 32, offset: 64, flags: 3, elements: !22, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !17, templateParams: !20, identifier: "MangledBase")
+!21 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Derived", file: !12, line: 3, scope: !16, baseType: !17, size: 128, align: 32, offset: 64, flags: 3, elements: !22, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !17, templateParams: !20, identifier: "MangledBase")
!22 = !{!23}
!23 = !MDDerivedType(tag: DW_TAG_inheritance, scope: !21, baseType: !17)
!24 = !MDDerivedType(tag: DW_TAG_ptr_to_member_type, baseType: !7, size: 32, align: 32, extraData: !17)
diff --git a/llvm/test/Assembler/mdcompileunit.ll b/llvm/test/Assembler/mdcompileunit.ll
index ec2b35e36f5..ce0052367f4 100644
--- a/llvm/test/Assembler/mdcompileunit.ll
+++ b/llvm/test/Assembler/mdcompileunit.ll
@@ -4,7 +4,7 @@
; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !7, !8, !8}
!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10}
-!0 = !{!"path/to/file", !"/path/to/dir"}
+!0 = distinct !{}
!1 = !MDFile(filename: "path/to/file", directory: "/path/to/dir")
!2 = distinct !{}
!3 = distinct !{}
diff --git a/llvm/test/Assembler/mdglobalvariable.ll b/llvm/test/Assembler/mdglobalvariable.ll
index f52eaa710ed..ef04f3eeab1 100644
--- a/llvm/test/Assembler/mdglobalvariable.ll
+++ b/llvm/test/Assembler/mdglobalvariable.ll
@@ -7,14 +7,14 @@
!named = !{!0, !1, !2, !3, !4, !5, !6}
!0 = distinct !{}
-!1 = !{!"path/to/file", !"/path/to/dir"}
+!1 = distinct !{}
!2 = !MDFile(filename: "path/to/file", directory: "/path/to/dir")
!3 = distinct !{}
!4 = distinct !{}
-; CHECK: !5 = !MDGlobalVariable(scope: !0, name: "foo", linkageName: "foo", file: !1, line: 7, type: !3, isLocal: true, isDefinition: false, variable: i32* @foo, declaration: !4)
+; CHECK: !5 = !MDGlobalVariable(scope: !0, name: "foo", linkageName: "foo", file: !2, line: 7, type: !3, isLocal: true, isDefinition: false, variable: i32* @foo, declaration: !4)
!5 = !MDGlobalVariable(scope: !0, name: "foo", linkageName: "foo",
- file: !1, line: 7, type: !3, isLocal: true,
+ file: !2, line: 7, type: !3, isLocal: true,
isDefinition: false, variable: i32* @foo,
declaration: !4)
diff --git a/llvm/test/Assembler/mdlexicalblock.ll b/llvm/test/Assembler/mdlexicalblock.ll
index 78d77b4d0fe..0a2c3397d35 100644
--- a/llvm/test/Assembler/mdlexicalblock.ll
+++ b/llvm/test/Assembler/mdlexicalblock.ll
@@ -5,7 +5,7 @@
!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9}
!0 = distinct !{}
-!1 = !{!"path/to/file", !"/path/to/dir"}
+!1 = distinct !{}
!2 = !MDFile(filename: "path/to/file", directory: "/path/to/dir")
; CHECK: !3 = !MDLexicalBlock(scope: !0, file: !2, line: 7, column: 35)
diff --git a/llvm/test/Assembler/mdlocalvariable.ll b/llvm/test/Assembler/mdlocalvariable.ll
index 6a7e530175d..00e350dbf6f 100644
--- a/llvm/test/Assembler/mdlocalvariable.ll
+++ b/llvm/test/Assembler/mdlocalvariable.ll
@@ -7,18 +7,18 @@
!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
!0 = distinct !{}
-!1 = !{!"path/to/file", !"/path/to/dir"}
+!1 = distinct !{}
!2 = !MDFile(filename: "path/to/file", directory: "/path/to/dir")
!3 = distinct !{}
!4 = distinct !{}
-; CHECK: !5 = !MDLocalVariable(tag: DW_TAG_arg_variable, scope: !0, name: "foo", file: !1, line: 7, type: !3, arg: 3, flags: 8, inlinedAt: !4)
-; CHECK: !6 = !MDLocalVariable(tag: DW_TAG_auto_variable, scope: !0, name: "foo", file: !1, line: 7, type: !3, flags: 8, inlinedAt: !4)
+; CHECK: !5 = !MDLocalVariable(tag: DW_TAG_arg_variable, scope: !0, name: "foo", file: !2, line: 7, type: !3, arg: 3, flags: 8, inlinedAt: !4)
+; CHECK: !6 = !MDLocalVariable(tag: DW_TAG_auto_variable, scope: !0, name: "foo", file: !2, line: 7, type: !3, flags: 8, inlinedAt: !4)
!5 = !MDLocalVariable(tag: DW_TAG_arg_variable, scope: !0, name: "foo",
- file: !1, line: 7, type: !3, arg: 3,
+ file: !2, line: 7, type: !3, arg: 3,
flags: 8, inlinedAt: !4)
!6 = !MDLocalVariable(tag: DW_TAG_auto_variable, scope: !0, name: "foo",
- file: !1, line: 7, type: !3, flags: 8, inlinedAt: !4)
+ file: !2, line: 7, type: !3, flags: 8, inlinedAt: !4)
; CHECK: !7 = !MDLocalVariable(tag: DW_TAG_arg_variable, scope: null, name: "", arg: 0)
; CHECK: !8 = !MDLocalVariable(tag: DW_TAG_auto_variable, scope: null, name: "")
diff --git a/llvm/test/Assembler/mdnamespace.ll b/llvm/test/Assembler/mdnamespace.ll
index 205ee04ba7d..d7f68499d10 100644
--- a/llvm/test/Assembler/mdnamespace.ll
+++ b/llvm/test/Assembler/mdnamespace.ll
@@ -5,7 +5,7 @@
!named = !{!0, !1, !2, !3, !4, !5}
!0 = distinct !{}
-!1 = !{!"path/to/file", !"/path/to/dir"}
+!1 = distinct !{}
!2 = !MDFile(filename: "path/to/file", directory: "/path/to/dir")
; CHECK: !3 = !MDNamespace(scope: !0, file: !2, name: "Namespace", line: 7)
diff --git a/llvm/test/Assembler/mdobjcproperty.ll b/llvm/test/Assembler/mdobjcproperty.ll
index fb44fb10a40..8afe9438787 100644
--- a/llvm/test/Assembler/mdobjcproperty.ll
+++ b/llvm/test/Assembler/mdobjcproperty.ll
@@ -4,14 +4,14 @@
; CHECK: !named = !{!0, !1, !2, !3, !4, !4}
!named = !{!0, !1, !2, !3, !4, !5}
-!0 = !{!"path/to/file", !"/path/to/dir"}
+!0 = distinct !{}
!1 = !MDFile(filename: "path/to/file", directory: "/path/to/dir")
!2 = distinct !{}
; CHECK: !2 = distinct !{}
-; CHECK-NEXT: !3 = !MDObjCProperty(name: "foo", file: !0, line: 7, setter: "setFoo", getter: "getFoo", attributes: 7, type: !2)
-!3 = !MDObjCProperty(name: "foo", file: !0, line: 7, setter: "setFoo",
+; CHECK-NEXT: !3 = !MDObjCProperty(name: "foo", file: !1, line: 7, setter: "setFoo", getter: "getFoo", attributes: 7, type: !2)
+!3 = !MDObjCProperty(name: "foo", file: !1, line: 7, setter: "setFoo",
getter: "getFoo", attributes: 7, type: !2)
; CHECK-NEXT: !4 = !MDObjCProperty(name: "foo")
diff --git a/llvm/test/Assembler/mdsubprogram.ll b/llvm/test/Assembler/mdsubprogram.ll
index ba05bd21e69..7915a29fa37 100644
--- a/llvm/test/Assembler/mdsubprogram.ll
+++ b/llvm/test/Assembler/mdsubprogram.ll
@@ -7,7 +7,7 @@ declare void @_Z3foov()
!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9}
!0 = distinct !{}
-!1 = !{!"path/to/file", !"/path/to/dir"}
+!1 = distinct !{}
!2 = !MDFile(filename: "path/to/file", directory: "/path/to/dir")
!3 = distinct !{}
!4 = distinct !{}
OpenPOWER on IntegriCloud