1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

IR: Give 'DI' prefix to debug info metadata

Finish off PR23080 by renaming the debug info IR constructs from `MD*`
to `DI*`.  The last of the `DIDescriptor` classes were deleted in
r235356, and the last of the related typedefs removed in r235413, so
this has all baked for about a week.

Note: If you have out-of-tree code (like a frontend), I recommend that
you get everything compiling and tests passing with the *previous*
commit before updating to this one.  It'll be easier to keep track of
what code is using the `DIDescriptor` hierarchy and what you've already
updated, and I think you're extremely unlikely to insert bugs.  YMMV of
course.

Back to *this* commit: I did this using the rename-md-di-nodes.sh
upgrade script I've attached to PR23080 (both code and testcases) and
filtered through clang-format-diff.py.  I edited the tests for
test/Assembler/invalid-generic-debug-node-*.ll by hand since the columns
were off-by-three.  It should work on your out-of-tree testcases (and
code, if you've followed the advice in the previous paragraph).

Some of the tests are in badly named files now (e.g.,
test/Assembler/invalid-mdcompositetype-missing-tag.ll should be
'dicompositetype'); I'll come back and move the files in a follow-up
commit.

llvm-svn: 236120
This commit is contained in:
Duncan P. N. Exon Smith 2015-04-29 16:38:44 +00:00
parent 339d8a9c1b
commit 09b5c9c24d
548 changed files with 11206 additions and 11217 deletions

View File

@ -56,8 +56,8 @@ LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(LLVMDIBuilderRef Dref,
unsigned Line, unsigned Line,
unsigned Column) { unsigned Column) {
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
auto *LB = D->createLexicalBlock(unwrap<MDLocalScope>(Scope), auto *LB = D->createLexicalBlock(unwrap<DILocalScope>(Scope),
unwrap<MDFile>(File), Line, Column); unwrap<DIFile>(File), Line, Column);
return wrap(LB); return wrap(LB);
} }
@ -66,8 +66,8 @@ LLVMMetadataRef LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Dref,
LLVMMetadataRef File, LLVMMetadataRef File,
unsigned Discriminator) { unsigned Discriminator) {
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
return wrap(D->createLexicalBlockFile(unwrap<MDLocalScope>(Scope), return wrap(D->createLexicalBlockFile(unwrap<DILocalScope>(Scope),
unwrap<MDFile>(File), Discriminator)); unwrap<DIFile>(File), Discriminator));
} }
LLVMMetadataRef LLVMDIBuilderCreateFunction( LLVMMetadataRef LLVMDIBuilderCreateFunction(
@ -76,9 +76,9 @@ LLVMMetadataRef LLVMDIBuilderCreateFunction(
LLVMMetadataRef CompositeType, int IsLocalToUnit, int IsDefinition, LLVMMetadataRef CompositeType, int IsLocalToUnit, int IsDefinition,
unsigned ScopeLine, unsigned Flags, int IsOptimized, LLVMValueRef Func) { unsigned ScopeLine, unsigned Flags, int IsOptimized, LLVMValueRef Func) {
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
return wrap(D->createFunction(unwrap<MDScope>(Scope), Name, LinkageName, return wrap(D->createFunction(unwrap<DIScope>(Scope), Name, LinkageName,
File ? unwrap<MDFile>(File) : nullptr, Line, File ? unwrap<DIFile>(File) : nullptr, Line,
unwrap<MDSubroutineType>(CompositeType), unwrap<DISubroutineType>(CompositeType),
IsLocalToUnit, IsDefinition, ScopeLine, Flags, IsLocalToUnit, IsDefinition, ScopeLine, Flags,
IsOptimized, unwrap<Function>(Func))); IsOptimized, unwrap<Function>(Func)));
} }
@ -89,8 +89,8 @@ LLVMMetadataRef LLVMDIBuilderCreateLocalVariable(
int AlwaysPreserve, unsigned Flags, unsigned ArgNo) { int AlwaysPreserve, unsigned Flags, unsigned ArgNo) {
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
return wrap(D->createLocalVariable( return wrap(D->createLocalVariable(
Tag, unwrap<MDScope>(Scope), Name, unwrap<MDFile>(File), Line, Tag, unwrap<DIScope>(Scope), Name, unwrap<DIFile>(File), Line,
unwrap<MDType>(Ty), AlwaysPreserve, Flags, ArgNo)); unwrap<DIType>(Ty), AlwaysPreserve, Flags, ArgNo));
} }
LLVMMetadataRef LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Dref, LLVMMetadataRef LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Dref,
@ -108,7 +108,7 @@ LLVMMetadataRef LLVMDIBuilderCreatePointerType(LLVMDIBuilderRef Dref,
uint64_t AlignInBits, uint64_t AlignInBits,
const char *Name) { const char *Name) {
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
return wrap(D->createPointerType(unwrap<MDType>(PointeeType), SizeInBits, return wrap(D->createPointerType(unwrap<DIType>(PointeeType), SizeInBits,
AlignInBits, Name)); AlignInBits, Name));
} }
@ -117,8 +117,8 @@ LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Dref, LLVMMetadataRef File,
LLVMMetadataRef ParameterTypes) { LLVMMetadataRef ParameterTypes) {
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
return wrap( return wrap(
D->createSubroutineType(File ? unwrap<MDFile>(File) : nullptr, D->createSubroutineType(File ? unwrap<DIFile>(File) : nullptr,
MDTypeRefArray(unwrap<MDTuple>(ParameterTypes)))); DITypeRefArray(unwrap<MDTuple>(ParameterTypes))));
} }
LLVMMetadataRef LLVMDIBuilderCreateStructType( LLVMMetadataRef LLVMDIBuilderCreateStructType(
@ -128,10 +128,10 @@ LLVMMetadataRef LLVMDIBuilderCreateStructType(
LLVMMetadataRef ElementTypes) { LLVMMetadataRef ElementTypes) {
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
return wrap(D->createStructType( return wrap(D->createStructType(
unwrap<MDScope>(Scope), Name, File ? unwrap<MDFile>(File) : nullptr, Line, unwrap<DIScope>(Scope), Name, File ? unwrap<DIFile>(File) : nullptr, Line,
SizeInBits, AlignInBits, Flags, SizeInBits, AlignInBits, Flags,
DerivedFrom ? unwrap<MDType>(DerivedFrom) : nullptr, DerivedFrom ? unwrap<DIType>(DerivedFrom) : nullptr,
ElementTypes ? DebugNodeArray(unwrap<MDTuple>(ElementTypes)) : nullptr)); ElementTypes ? DINodeArray(unwrap<MDTuple>(ElementTypes)) : nullptr));
} }
LLVMMetadataRef LLVMDIBuilderCreateReplaceableCompositeType( LLVMMetadataRef LLVMDIBuilderCreateReplaceableCompositeType(
@ -141,7 +141,7 @@ LLVMMetadataRef LLVMDIBuilderCreateReplaceableCompositeType(
unsigned Flags) { unsigned Flags) {
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
return wrap(D->createReplaceableCompositeType( return wrap(D->createReplaceableCompositeType(
Tag, Name, unwrap<MDScope>(Scope), File ? unwrap<MDFile>(File) : nullptr, Tag, Name, unwrap<DIScope>(Scope), File ? unwrap<DIFile>(File) : nullptr,
Line, RuntimeLang, SizeInBits, AlignInBits, Flags)); Line, RuntimeLang, SizeInBits, AlignInBits, Flags));
} }
@ -153,8 +153,8 @@ LLVMDIBuilderCreateMemberType(LLVMDIBuilderRef Dref, LLVMMetadataRef Scope,
unsigned Flags, LLVMMetadataRef Ty) { unsigned Flags, LLVMMetadataRef Ty) {
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
return wrap(D->createMemberType( return wrap(D->createMemberType(
unwrap<MDScope>(Scope), Name, File ? unwrap<MDFile>(File) : nullptr, Line, unwrap<DIScope>(Scope), Name, File ? unwrap<DIFile>(File) : nullptr, Line,
SizeInBits, AlignInBits, OffsetInBits, Flags, unwrap<MDType>(Ty))); SizeInBits, AlignInBits, OffsetInBits, Flags, unwrap<DIType>(Ty)));
} }
LLVMMetadataRef LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Dref, LLVMMetadataRef LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Dref,
@ -164,8 +164,8 @@ LLVMMetadataRef LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Dref,
LLVMMetadataRef Subscripts) { LLVMMetadataRef Subscripts) {
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
return wrap(D->createArrayType(SizeInBits, AlignInBits, return wrap(D->createArrayType(SizeInBits, AlignInBits,
unwrap<MDType>(ElementType), unwrap<DIType>(ElementType),
DebugNodeArray(unwrap<MDTuple>(Subscripts)))); DINodeArray(unwrap<MDTuple>(Subscripts))));
} }
LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Dref, LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Dref,
@ -173,9 +173,9 @@ LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Dref,
LLVMMetadataRef File, unsigned Line, LLVMMetadataRef File, unsigned Line,
LLVMMetadataRef Context) { LLVMMetadataRef Context) {
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
return wrap(D->createTypedef(unwrap<MDType>(Ty), Name, return wrap(D->createTypedef(unwrap<DIType>(Ty), Name,
File ? unwrap<MDFile>(File) : nullptr, Line, File ? unwrap<DIFile>(File) : nullptr, Line,
Context ? unwrap<MDScope>(Context) : nullptr)); Context ? unwrap<DIScope>(Context) : nullptr));
} }
LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Dref, LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Dref,
@ -190,7 +190,7 @@ LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Dref,
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
Metadata **DataValue = unwrap(Data); Metadata **DataValue = unwrap(Data);
ArrayRef<Metadata *> Elements(DataValue, Length); ArrayRef<Metadata *> Elements(DataValue, Length);
DebugNodeArray A = D->getOrCreateArray(Elements); DINodeArray A = D->getOrCreateArray(Elements);
return wrap(A.get()); return wrap(A.get());
} }
@ -200,7 +200,7 @@ LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Dref,
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
Metadata **DataValue = unwrap(Data); Metadata **DataValue = unwrap(Data);
ArrayRef<Metadata *> Elements(DataValue, Length); ArrayRef<Metadata *> Elements(DataValue, Length);
MDTypeRefArray A = D->getOrCreateTypeArray(Elements); DITypeRefArray A = D->getOrCreateTypeArray(Elements);
return wrap(A.get()); return wrap(A.get());
} }
@ -221,8 +221,8 @@ LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Dref,
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
Instruction *Instr = D->insertDeclare( Instruction *Instr = D->insertDeclare(
unwrap(Storage), unwrap<MDLocalVariable>(VarInfo), unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<MDExpression>(Expr), /* DebugLoc */ nullptr, unwrap(Block)); unwrap<DIExpression>(Expr), /* DebugLoc */ nullptr, unwrap(Block));
return wrap(Instr); return wrap(Instr);
} }
@ -237,7 +237,7 @@ LLVMValueRef LLVMDIBuilderInsertValueAtEnd(LLVMDIBuilderRef Dref,
DIBuilder *D = unwrap(Dref); DIBuilder *D = unwrap(Dref);
Instruction *Instr = D->insertDbgValueIntrinsic( Instruction *Instr = D->insertDbgValueIntrinsic(
unwrap(Val), Offset, unwrap<MDLocalVariable>(VarInfo), unwrap(Val), Offset, unwrap<DILocalVariable>(VarInfo),
unwrap<MDExpression>(Expr), /* DebugLoc */ nullptr, unwrap(Block)); unwrap<DIExpression>(Expr), /* DebugLoc */ nullptr, unwrap(Block));
return wrap(Instr); return wrap(Instr);
} }

View File

@ -200,9 +200,9 @@ For example, the following works like you'd expect:
.. code-block:: llvm .. code-block:: llvm
!0 = !MDLocation(line: 5, scope: !1, inlinedAt: !2) !0 = !DILocation(line: 5, scope: !1, inlinedAt: !2)
; CHECK: !MDLocation(line: 5, ; CHECK: !DILocation(line: 5,
; CHECK-NOT: column: ; CHECK-NOT: column:
; CHECK-SAME: scope: ![[SCOPE:[0-9]+]] ; CHECK-SAME: scope: ![[SCOPE:[0-9]+]]

View File

@ -2922,12 +2922,12 @@ order.
These aren't inherently debug info centric, but currently all the specialized These aren't inherently debug info centric, but currently all the specialized
metadata nodes are related to debug info. metadata nodes are related to debug info.
.. _MDCompileUnit: .. _DICompileUnit:
MDCompileUnit DICompileUnit
""""""""""""" """""""""""""
``MDCompileUnit`` nodes represent a compile unit. The ``enums:``, ``DICompileUnit`` nodes represent a compile unit. The ``enums:``,
``retainedTypes:``, ``subprograms:``, ``globals:`` and ``imports:`` fields are ``retainedTypes:``, ``subprograms:``, ``globals:`` and ``imports:`` fields are
tuples containing the debug info to be emitted along with the compile unit, tuples containing the debug info to be emitted along with the compile unit,
regardless of code optimizations (some nodes are only emitted if there are regardless of code optimizations (some nodes are only emitted if there are
@ -2935,7 +2935,7 @@ references to them from instructions).
.. code-block:: llvm .. code-block:: llvm
!0 = !MDCompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", !0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang",
isOptimized: true, flags: "-O2", runtimeVersion: 2, isOptimized: true, flags: "-O2", runtimeVersion: 2,
splitDebugFilename: "abc.debug", emissionKind: 1, splitDebugFilename: "abc.debug", emissionKind: 1,
enums: !2, retainedTypes: !3, subprograms: !4, enums: !2, retainedTypes: !3, subprograms: !4,
@ -2947,33 +2947,33 @@ These descriptors are collected by a named metadata ``!llvm.dbg.cu``. They
keep track of subprograms, global variables, type information, and imported keep track of subprograms, global variables, type information, and imported
entities (declarations and namespaces). entities (declarations and namespaces).
.. _MDFile: .. _DIFile:
MDFile DIFile
"""""" """"""
``MDFile`` nodes represent files. The ``filename:`` can include slashes. ``DIFile`` nodes represent files. The ``filename:`` can include slashes.
.. code-block:: llvm .. code-block:: llvm
!0 = !MDFile(filename: "path/to/file", directory: "/path/to/dir") !0 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
Files are sometimes used in ``scope:`` fields, and are the only valid target Files are sometimes used in ``scope:`` fields, and are the only valid target
for ``file:`` fields. for ``file:`` fields.
.. _MDLocation: .. _DILocation:
MDBasicType DIBasicType
""""""""""" """""""""""
``MDBasicType`` nodes represent primitive types, such as ``int``, ``bool`` and ``DIBasicType`` nodes represent primitive types, such as ``int``, ``bool`` and
``float``. ``tag:`` defaults to ``DW_TAG_base_type``. ``float``. ``tag:`` defaults to ``DW_TAG_base_type``.
.. code-block:: llvm .. code-block:: llvm
!0 = !MDBasicType(name: "unsigned char", size: 8, align: 8, !0 = !DIBasicType(name: "unsigned char", size: 8, align: 8,
encoding: DW_ATE_unsigned_char) encoding: DW_ATE_unsigned_char)
!1 = !MDBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)") !1 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
The ``encoding:`` describes the details of the type. Usually it's one of the The ``encoding:`` describes the details of the type. Usually it's one of the
following: following:
@ -2988,12 +2988,12 @@ following:
DW_ATE_unsigned = 7 DW_ATE_unsigned = 7
DW_ATE_unsigned_char = 8 DW_ATE_unsigned_char = 8
.. _MDSubroutineType: .. _DISubroutineType:
MDSubroutineType DISubroutineType
"""""""""""""""" """"""""""""""""
``MDSubroutineType`` nodes represent subroutine types. Their ``types:`` field ``DISubroutineType`` nodes represent subroutine types. Their ``types:`` field
refers to a tuple; the first operand is the return type, while the rest are the refers to a tuple; the first operand is the return type, while the rest are the
types of the formal arguments in order. If the first operand is ``null``, that types of the formal arguments in order. If the first operand is ``null``, that
represents a function with no return value (such as ``void foo() {}`` in C++). represents a function with no return value (such as ``void foo() {}`` in C++).
@ -3002,21 +3002,21 @@ represents a function with no return value (such as ``void foo() {}`` in C++).
!0 = !BasicType(name: "int", size: 32, align: 32, DW_ATE_signed) !0 = !BasicType(name: "int", size: 32, align: 32, DW_ATE_signed)
!1 = !BasicType(name: "char", size: 8, align: 8, DW_ATE_signed_char) !1 = !BasicType(name: "char", size: 8, align: 8, DW_ATE_signed_char)
!2 = !MDSubroutineType(types: !{null, !0, !1}) ; void (int, char) !2 = !DISubroutineType(types: !{null, !0, !1}) ; void (int, char)
.. _MDDerivedType: .. _DIDerivedType:
MDDerivedType DIDerivedType
""""""""""""" """""""""""""
``MDDerivedType`` nodes represent types derived from other types, such as ``DIDerivedType`` nodes represent types derived from other types, such as
qualified types. qualified types.
.. code-block:: llvm .. code-block:: llvm
!0 = !MDBasicType(name: "unsigned char", size: 8, align: 8, !0 = !DIBasicType(name: "unsigned char", size: 8, align: 8,
encoding: DW_ATE_unsigned_char) encoding: DW_ATE_unsigned_char)
!1 = !MDDerivedType(tag: DW_TAG_pointer_type, baseType: !0, size: 32, !1 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !0, size: 32,
align: 32) align: 32)
The following ``tag:`` values are valid: The following ``tag:`` values are valid:
@ -3034,7 +3034,7 @@ The following ``tag:`` values are valid:
DW_TAG_restrict_type = 55 DW_TAG_restrict_type = 55
``DW_TAG_member`` is used to define a member of a :ref:`composite type ``DW_TAG_member`` is used to define a member of a :ref:`composite type
<MDCompositeType>` or :ref:`subprogram <MDSubprogram>`. The type of the member <DICompositeType>` or :ref:`subprogram <DISubprogram>`. The type of the member
is the ``baseType:``. The ``offset:`` is the member's bit offset. is the ``baseType:``. The ``offset:`` is the member's bit offset.
``DW_TAG_formal_parameter`` is used to define a member which is a formal ``DW_TAG_formal_parameter`` is used to define a member which is a formal
argument of a subprogram. argument of a subprogram.
@ -3047,12 +3047,12 @@ argument of a subprogram.
Note that the ``void *`` type is expressed as a type derived from NULL. Note that the ``void *`` type is expressed as a type derived from NULL.
.. _MDCompositeType: .. _DICompositeType:
MDCompositeType DICompositeType
""""""""""""""" """""""""""""""
``MDCompositeType`` nodes represent types composed of other types, like ``DICompositeType`` nodes represent types composed of other types, like
structures and unions. ``elements:`` points to a tuple of the composed types. structures and unions. ``elements:`` points to a tuple of the composed types.
If the source language supports ODR, the ``identifier:`` field gives the unique If the source language supports ODR, the ``identifier:`` field gives the unique
@ -3062,10 +3062,10 @@ can refer to composite types indirectly via a :ref:`metadata string
.. code-block:: llvm .. code-block:: llvm
!0 = !MDEnumerator(name: "SixKind", value: 7) !0 = !DIEnumerator(name: "SixKind", value: 7)
!1 = !MDEnumerator(name: "SevenKind", value: 7) !1 = !DIEnumerator(name: "SevenKind", value: 7)
!2 = !MDEnumerator(name: "NegEightKind", value: -8) !2 = !DIEnumerator(name: "NegEightKind", value: -8)
!3 = !MDCompositeType(tag: DW_TAG_enumeration_type, name: "Enum", file: !12, !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", file: !12,
line: 2, size: 32, align: 32, identifier: "_M4Enum", line: 2, size: 32, align: 32, identifier: "_M4Enum",
elements: !{!0, !1, !2}) elements: !{!0, !1, !2})
@ -3083,108 +3083,108 @@ The following ``tag:`` values are valid:
For ``DW_TAG_array_type``, the ``elements:`` should be :ref:`subrange For ``DW_TAG_array_type``, the ``elements:`` should be :ref:`subrange
descriptors <MDSubrange>`, each representing the range of subscripts at that descriptors <DISubrange>`, each representing the range of subscripts at that
level of indexing. The ``DIFlagVector`` flag to ``flags:`` indicates that an level of indexing. The ``DIFlagVector`` flag to ``flags:`` indicates that an
array type is a native packed vector. array type is a native packed vector.
For ``DW_TAG_enumeration_type``, the ``elements:`` should be :ref:`enumerator For ``DW_TAG_enumeration_type``, the ``elements:`` should be :ref:`enumerator
descriptors <MDEnumerator>`, each representing the definition of an enumeration descriptors <DIEnumerator>`, each representing the definition of an enumeration
value for the set. All enumeration type descriptors are collected in the value for the set. All enumeration type descriptors are collected in the
``enums:`` field of the :ref:`compile unit <MDCompileUnit>`. ``enums:`` field of the :ref:`compile unit <DICompileUnit>`.
For ``DW_TAG_structure_type``, ``DW_TAG_class_type``, and For ``DW_TAG_structure_type``, ``DW_TAG_class_type``, and
``DW_TAG_union_type``, the ``elements:`` should be :ref:`derived types ``DW_TAG_union_type``, the ``elements:`` should be :ref:`derived types
<MDDerivedType>` with ``tag: DW_TAG_member`` or ``tag: DW_TAG_inheritance``. <DIDerivedType>` with ``tag: DW_TAG_member`` or ``tag: DW_TAG_inheritance``.
.. _MDSubrange: .. _DISubrange:
MDSubrange DISubrange
"""""""""" """"""""""
``MDSubrange`` nodes are the elements for ``DW_TAG_array_type`` variants of ``DISubrange`` nodes are the elements for ``DW_TAG_array_type`` variants of
:ref:`MDCompositeType`. ``count: -1`` indicates an empty array. :ref:`DICompositeType`. ``count: -1`` indicates an empty array.
.. code-block:: llvm .. code-block:: llvm
!0 = !MDSubrange(count: 5, lowerBound: 0) ; array counting from 0 !0 = !DISubrange(count: 5, lowerBound: 0) ; array counting from 0
!1 = !MDSubrange(count: 5, lowerBound: 1) ; array counting from 1 !1 = !DISubrange(count: 5, lowerBound: 1) ; array counting from 1
!2 = !MDSubrange(count: -1) ; empty array. !2 = !DISubrange(count: -1) ; empty array.
.. _MDEnumerator: .. _DIEnumerator:
MDEnumerator DIEnumerator
"""""""""""" """"""""""""
``MDEnumerator`` nodes are the elements for ``DW_TAG_enumeration_type`` ``DIEnumerator`` nodes are the elements for ``DW_TAG_enumeration_type``
variants of :ref:`MDCompositeType`. variants of :ref:`DICompositeType`.
.. code-block:: llvm .. code-block:: llvm
!0 = !MDEnumerator(name: "SixKind", value: 7) !0 = !DIEnumerator(name: "SixKind", value: 7)
!1 = !MDEnumerator(name: "SevenKind", value: 7) !1 = !DIEnumerator(name: "SevenKind", value: 7)
!2 = !MDEnumerator(name: "NegEightKind", value: -8) !2 = !DIEnumerator(name: "NegEightKind", value: -8)
MDTemplateTypeParameter DITemplateTypeParameter
""""""""""""""""""""""" """""""""""""""""""""""
``MDTemplateTypeParameter`` nodes represent type parameters to generic source ``DITemplateTypeParameter`` nodes represent type parameters to generic source
language constructs. They are used (optionally) in :ref:`MDCompositeType` and language constructs. They are used (optionally) in :ref:`DICompositeType` and
:ref:`MDSubprogram` ``templateParams:`` fields. :ref:`DISubprogram` ``templateParams:`` fields.
.. code-block:: llvm .. code-block:: llvm
!0 = !MDTemplateTypeParameter(name: "Ty", type: !1) !0 = !DITemplateTypeParameter(name: "Ty", type: !1)
MDTemplateValueParameter DITemplateValueParameter
"""""""""""""""""""""""" """"""""""""""""""""""""
``MDTemplateValueParameter`` nodes represent value parameters to generic source ``DITemplateValueParameter`` nodes represent value parameters to generic source
language constructs. ``tag:`` defaults to ``DW_TAG_template_value_parameter``, language constructs. ``tag:`` defaults to ``DW_TAG_template_value_parameter``,
but if specified can also be set to ``DW_TAG_GNU_template_template_param`` or but if specified can also be set to ``DW_TAG_GNU_template_template_param`` or
``DW_TAG_GNU_template_param_pack``. They are used (optionally) in ``DW_TAG_GNU_template_param_pack``. They are used (optionally) in
:ref:`MDCompositeType` and :ref:`MDSubprogram` ``templateParams:`` fields. :ref:`DICompositeType` and :ref:`DISubprogram` ``templateParams:`` fields.
.. code-block:: llvm .. code-block:: llvm
!0 = !MDTemplateValueParameter(name: "Ty", type: !1, value: i32 7) !0 = !DITemplateValueParameter(name: "Ty", type: !1, value: i32 7)
MDNamespace DINamespace
""""""""""" """""""""""
``MDNamespace`` nodes represent namespaces in the source language. ``DINamespace`` nodes represent namespaces in the source language.
.. code-block:: llvm .. code-block:: llvm
!0 = !MDNamespace(name: "myawesomeproject", scope: !1, file: !2, line: 7) !0 = !DINamespace(name: "myawesomeproject", scope: !1, file: !2, line: 7)
MDGlobalVariable DIGlobalVariable
"""""""""""""""" """"""""""""""""
``MDGlobalVariable`` nodes represent global variables in the source language. ``DIGlobalVariable`` nodes represent global variables in the source language.
.. code-block:: llvm .. code-block:: llvm
!0 = !MDGlobalVariable(name: "foo", linkageName: "foo", scope: !1, !0 = !DIGlobalVariable(name: "foo", linkageName: "foo", scope: !1,
file: !2, line: 7, type: !3, isLocal: true, file: !2, line: 7, type: !3, isLocal: true,
isDefinition: false, variable: i32* @foo, isDefinition: false, variable: i32* @foo,
declaration: !4) declaration: !4)
All global variables should be referenced by the `globals:` field of a All global variables should be referenced by the `globals:` field of a
:ref:`compile unit <MDCompileUnit>`. :ref:`compile unit <DICompileUnit>`.
.. _MDSubprogram: .. _DISubprogram:
MDSubprogram DISubprogram
"""""""""""" """"""""""""
``MDSubprogram`` nodes represent functions from the source language. The ``DISubprogram`` nodes represent functions from the source language. The
``variables:`` field points at :ref:`variables <MDLocalVariable>` that must be ``variables:`` field points at :ref:`variables <DILocalVariable>` that must be
retained, even if their IR counterparts are optimized out of the IR. The retained, even if their IR counterparts are optimized out of the IR. The
``type:`` field must point at an :ref:`MDSubroutineType`. ``type:`` field must point at an :ref:`DISubroutineType`.
.. code-block:: llvm .. code-block:: llvm
!0 = !MDSubprogram(name: "foo", linkageName: "_Zfoov", scope: !1, !0 = !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1,
file: !2, line: 7, type: !3, isLocal: true, file: !2, line: 7, type: !3, isLocal: true,
isDefinition: false, scopeLine: 8, containingType: !4, isDefinition: false, scopeLine: 8, containingType: !4,
virtuality: DW_VIRTUALITY_pure_virtual, virtualIndex: 10, virtuality: DW_VIRTUALITY_pure_virtual, virtualIndex: 10,
@ -3192,76 +3192,76 @@ retained, even if their IR counterparts are optimized out of the IR. The
function: void ()* @_Z3foov, function: void ()* @_Z3foov,
templateParams: !5, declaration: !6, variables: !7) templateParams: !5, declaration: !6, variables: !7)
.. _MDLexicalBlock: .. _DILexicalBlock:
MDLexicalBlock DILexicalBlock
"""""""""""""" """"""""""""""
``MDLexicalBlock`` nodes describe nested blocks within a :ref:`subprogram ``DILexicalBlock`` nodes describe nested blocks within a :ref:`subprogram
<MDSubprogram>`. The line number and column numbers are used to dinstinguish <DISubprogram>`. The line number and column numbers are used to dinstinguish
two lexical blocks at same depth. They are valid targets for ``scope:`` two lexical blocks at same depth. They are valid targets for ``scope:``
fields. fields.
.. code-block:: llvm .. code-block:: llvm
!0 = distinct !MDLexicalBlock(scope: !1, file: !2, line: 7, column: 35) !0 = distinct !DILexicalBlock(scope: !1, file: !2, line: 7, column: 35)
Usually lexical blocks are ``distinct`` to prevent node merging based on Usually lexical blocks are ``distinct`` to prevent node merging based on
operands. operands.
.. _MDLexicalBlockFile: .. _DILexicalBlockFile:
MDLexicalBlockFile DILexicalBlockFile
"""""""""""""""""" """"""""""""""""""
``MDLexicalBlockFile`` nodes are used to discriminate between sections of a ``DILexicalBlockFile`` nodes are used to discriminate between sections of a
:ref:`lexical block <MDLexicalBlock>`. The ``file:`` field can be changed to :ref:`lexical block <DILexicalBlock>`. The ``file:`` field can be changed to
indicate textual inclusion, or the ``discriminator:`` field can be used to indicate textual inclusion, or the ``discriminator:`` field can be used to
discriminate between control flow within a single block in the source language. discriminate between control flow within a single block in the source language.
.. code-block:: llvm .. code-block:: llvm
!0 = !MDLexicalBlock(scope: !3, file: !4, line: 7, column: 35) !0 = !DILexicalBlock(scope: !3, file: !4, line: 7, column: 35)
!1 = !MDLexicalBlockFile(scope: !0, file: !4, discriminator: 0) !1 = !DILexicalBlockFile(scope: !0, file: !4, discriminator: 0)
!2 = !MDLexicalBlockFile(scope: !0, file: !4, discriminator: 1) !2 = !DILexicalBlockFile(scope: !0, file: !4, discriminator: 1)
MDLocation DILocation
"""""""""" """"""""""
``MDLocation`` nodes represent source debug locations. The ``scope:`` field is ``DILocation`` nodes represent source debug locations. The ``scope:`` field is
mandatory, and points at an :ref:`MDLexicalBlockFile`, an mandatory, and points at an :ref:`DILexicalBlockFile`, an
:ref:`MDLexicalBlock`, or an :ref:`MDSubprogram`. :ref:`DILexicalBlock`, or an :ref:`DISubprogram`.
.. code-block:: llvm .. code-block:: llvm
!0 = !MDLocation(line: 2900, column: 42, scope: !1, inlinedAt: !2) !0 = !DILocation(line: 2900, column: 42, scope: !1, inlinedAt: !2)
.. _MDLocalVariable: .. _DILocalVariable:
MDLocalVariable DILocalVariable
""""""""""""""" """""""""""""""
``MDLocalVariable`` nodes represent local variables in the source language. ``DILocalVariable`` nodes represent local variables in the source language.
Instead of ``DW_TAG_variable``, they use LLVM-specific fake tags to Instead of ``DW_TAG_variable``, they use LLVM-specific fake tags to
discriminate between local variables (``DW_TAG_auto_variable``) and subprogram discriminate between local variables (``DW_TAG_auto_variable``) and subprogram
arguments (``DW_TAG_arg_variable``). In the latter case, the ``arg:`` field arguments (``DW_TAG_arg_variable``). In the latter case, the ``arg:`` field
specifies the argument position, and this variable will be included in the specifies the argument position, and this variable will be included in the
``variables:`` field of its :ref:`MDSubprogram`. ``variables:`` field of its :ref:`DISubprogram`.
.. code-block:: llvm .. code-block:: llvm
!0 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "this", arg: 0, !0 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "this", arg: 0,
scope: !3, file: !2, line: 7, type: !3, scope: !3, file: !2, line: 7, type: !3,
flags: DIFlagArtificial) flags: DIFlagArtificial)
!1 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "x", arg: 1, !1 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "x", arg: 1,
scope: !4, file: !2, line: 7, type: !3) scope: !4, file: !2, line: 7, type: !3)
!1 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "y", !1 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "y",
scope: !5, file: !2, line: 7, type: !3) scope: !5, file: !2, line: 7, type: !3)
MDExpression DIExpression
"""""""""""" """"""""""""
``MDExpression`` nodes represent DWARF expression sequences. They are used in ``DIExpression`` nodes represent DWARF expression sequences. They are used in
:ref:`debug intrinsics<dbg_intrinsics>` (such as ``llvm.dbg.declare``) to :ref:`debug intrinsics<dbg_intrinsics>` (such as ``llvm.dbg.declare``) to
describe how the referenced LLVM variable relates to the source language describe how the referenced LLVM variable relates to the source language
variable. variable.
@ -3275,30 +3275,30 @@ The current supported vocabulary is limited:
.. code-block:: llvm .. code-block:: llvm
!0 = !MDExpression(DW_OP_deref) !0 = !DIExpression(DW_OP_deref)
!1 = !MDExpression(DW_OP_plus, 3) !1 = !DIExpression(DW_OP_plus, 3)
!2 = !MDExpression(DW_OP_bit_piece, 3, 7) !2 = !DIExpression(DW_OP_bit_piece, 3, 7)
!3 = !MDExpression(DW_OP_deref, DW_OP_plus, 3, DW_OP_bit_piece, 3, 7) !3 = !DIExpression(DW_OP_deref, DW_OP_plus, 3, DW_OP_bit_piece, 3, 7)
MDObjCProperty DIObjCProperty
"""""""""""""" """"""""""""""
``MDObjCProperty`` nodes represent Objective-C property nodes. ``DIObjCProperty`` nodes represent Objective-C property nodes.
.. code-block:: llvm .. code-block:: llvm
!3 = !MDObjCProperty(name: "foo", file: !1, line: 7, setter: "setFoo", !3 = !DIObjCProperty(name: "foo", file: !1, line: 7, setter: "setFoo",
getter: "getFoo", attributes: 7, type: !2) getter: "getFoo", attributes: 7, type: !2)
MDImportedEntity DIImportedEntity
"""""""""""""""" """"""""""""""""
``MDImportedEntity`` nodes represent entities (such as modules) imported into a ``DIImportedEntity`` nodes represent entities (such as modules) imported into a
compile unit. compile unit.
.. code-block:: llvm .. code-block:: llvm
!2 = !MDImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0, !2 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0,
entity: !1, line: 7) entity: !1, line: 7)
'``tbaa``' Metadata '``tbaa``' Metadata

View File

@ -153,8 +153,8 @@ debugger to interpret the information.
To provide basic functionality, the LLVM debugger does have to make some To provide basic functionality, the LLVM debugger does have to make some
assumptions about the source-level language being debugged, though it keeps assumptions about the source-level language being debugged, though it keeps
these to a minimum. The only common features that the LLVM debugger assumes these to a minimum. The only common features that the LLVM debugger assumes
exist are `source files <LangRef.html#MDFile>`_, and `program objects exist are `source files <LangRef.html#DIFile>`_, and `program objects
<LangRef.html#MDGlobalVariable>`_. These abstract objects are used by a <LangRef.html#DIGlobalVariable>`_. These abstract objects are used by a
debugger to form stack traces, show information about local variables, etc. debugger to form stack traces, show information about local variables, etc.
This section of the documentation first describes the representation aspects This section of the documentation first describes the representation aspects
@ -181,9 +181,9 @@ provide debug information at various points in generated code.
This intrinsic provides information about a local element (e.g., variable). This intrinsic provides information about a local element (e.g., variable).
The first argument is metadata holding the alloca for the variable. The second The first argument is metadata holding the alloca for the variable. The second
argument is a `local variable <LangRef.html#MDLocalVariable>`_ containing a argument is a `local variable <LangRef.html#DILocalVariable>`_ containing a
description of the variable. The third argument is a `complex expression description of the variable. The third argument is a `complex expression
<LangRef.html#MDExpression>`_. <LangRef.html#DIExpression>`_.
``llvm.dbg.value`` ``llvm.dbg.value``
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
@ -196,8 +196,8 @@ This intrinsic provides information when a user source variable is set to a new
value. The first argument is the new value (wrapped as metadata). The second value. The first argument is the new value (wrapped as metadata). The second
argument is the offset in the user source variable where the new value is argument is the offset in the user source variable where the new value is
written. The third argument is a `local variable written. The third argument is a `local variable
<LangRef.html#MDLocalVariable>`_ containing a description of the variable. The <LangRef.html#DILocalVariable>`_ containing a description of the variable. The
third argument is a `complex expression <LangRef.html#MDExpression>`_. third argument is a `complex expression <LangRef.html#DIExpression>`_.
Object lifetimes and scoping Object lifetimes and scoping
============================ ============================
@ -259,31 +259,31 @@ Compiled to LLVM, this function would be represented like this:
!llvm.module.flags = !{!7, !8, !9} !llvm.module.flags = !{!7, !8, !9}
!llvm.ident = !{!10} !llvm.ident = !{!10}
!0 = !MDCompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 231150) (llvm/trunk 231154)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) !0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 231150) (llvm/trunk 231154)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
!1 = !MDFile(filename: "/dev/stdin", directory: "/Users/dexonsmith/data/llvm/debug-info") !1 = !DIFile(filename: "/dev/stdin", directory: "/Users/dexonsmith/data/llvm/debug-info")
!2 = !{} !2 = !{}
!3 = !{!4} !3 = !{!4}
!4 = !MDSubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, function: void ()* @foo, variables: !2) !4 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, function: void ()* @foo, variables: !2)
!5 = !MDSubroutineType(types: !6) !5 = !DISubroutineType(types: !6)
!6 = !{null} !6 = !{null}
!7 = !{i32 2, !"Dwarf Version", i32 2} !7 = !{i32 2, !"Dwarf Version", i32 2}
!8 = !{i32 2, !"Debug Info Version", i32 3} !8 = !{i32 2, !"Debug Info Version", i32 3}
!9 = !{i32 1, !"PIC Level", i32 2} !9 = !{i32 1, !"PIC Level", i32 2}
!10 = !{!"clang version 3.7.0 (trunk 231150) (llvm/trunk 231154)"} !10 = !{!"clang version 3.7.0 (trunk 231150) (llvm/trunk 231154)"}
!11 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "X", scope: !4, file: !1, line: 2, type: !12) !11 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "X", scope: !4, file: !1, line: 2, type: !12)
!12 = !MDBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) !12 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
!13 = !MDExpression() !13 = !DIExpression()
!14 = !MDLocation(line: 2, column: 9, scope: !4) !14 = !DILocation(line: 2, column: 9, scope: !4)
!15 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "Y", scope: !4, file: !1, line: 3, type: !12) !15 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "Y", scope: !4, file: !1, line: 3, type: !12)
!16 = !MDLocation(line: 3, column: 9, scope: !4) !16 = !DILocation(line: 3, column: 9, scope: !4)
!17 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "Z", scope: !18, file: !1, line: 5, type: !12) !17 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "Z", scope: !18, file: !1, line: 5, type: !12)
!18 = distinct !MDLexicalBlock(scope: !4, file: !1, line: 4, column: 5) !18 = distinct !DILexicalBlock(scope: !4, file: !1, line: 4, column: 5)
!19 = !MDLocation(line: 5, column: 11, scope: !18) !19 = !DILocation(line: 5, column: 11, scope: !18)
!20 = !MDLocation(line: 6, column: 11, scope: !18) !20 = !DILocation(line: 6, column: 11, scope: !18)
!21 = !MDLocation(line: 6, column: 9, scope: !18) !21 = !DILocation(line: 6, column: 9, scope: !18)
!22 = !MDLocation(line: 8, column: 9, scope: !4) !22 = !DILocation(line: 8, column: 9, scope: !4)
!23 = !MDLocation(line: 8, column: 7, scope: !4) !23 = !DILocation(line: 8, column: 7, scope: !4)
!24 = !MDLocation(line: 9, column: 3, scope: !4) !24 = !DILocation(line: 9, column: 3, scope: !4)
This example illustrates a few important details about LLVM debugging This example illustrates a few important details about LLVM debugging
@ -303,15 +303,15 @@ scope information for the variable ``X``.
.. code-block:: llvm .. code-block:: llvm
!14 = !MDLocation(line: 2, column: 9, scope: !4) !14 = !DILocation(line: 2, column: 9, scope: !4)
!4 = !MDSubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, !4 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5,
isLocal: false, isDefinition: true, scopeLine: 1, isLocal: false, isDefinition: true, scopeLine: 1,
isOptimized: false, function: void ()* @foo, isOptimized: false, function: void ()* @foo,
variables: !2) variables: !2)
Here ``!14`` is metadata providing `location information Here ``!14`` is metadata providing `location information
<LangRef.html#MDLocation>`_. In this example, scope is encoded by ``!4``, a <LangRef.html#DILocation>`_. In this example, scope is encoded by ``!4``, a
`subprogram descriptor <LangRef.html#MDSubprogram>`_. This way the location `subprogram descriptor <LangRef.html#DISubprogram>`_. This way the location
information attached to the intrinsics indicates that the variable ``X`` is information attached to the intrinsics indicates that the variable ``X`` is
declared at line number 2 at a function level scope in function ``foo``. declared at line number 2 at a function level scope in function ``foo``.
@ -328,8 +328,8 @@ scope information for the variable ``Z``.
.. code-block:: llvm .. code-block:: llvm
!18 = distinct !MDLexicalBlock(scope: !4, file: !1, line: 4, column: 5) !18 = distinct !DILexicalBlock(scope: !4, file: !1, line: 4, column: 5)
!19 = !MDLocation(line: 5, column: 11, scope: !18) !19 = !DILocation(line: 5, column: 11, scope: !18)
Here ``!19`` indicates that ``Z`` is declared at line number 5 and column Here ``!19`` indicates that ``Z`` is declared at line number 5 and column
number 0 inside of lexical scope ``!18``. The lexical scope itself resides number 0 inside of lexical scope ``!18``. The lexical scope itself resides
@ -406,7 +406,7 @@ a C/C++ front-end would generate the following descriptors:
!llvm.module.flags = !{!6, !7} !llvm.module.flags = !{!6, !7}
;; Define the compile unit. ;; Define the compile unit.
!0 = !MDCompileUnit(language: DW_LANG_C99, file: !1, !0 = !DICompileUnit(language: DW_LANG_C99, file: !1,
producer: producer:
"clang version 3.7.0 (trunk 231150) (llvm/trunk 231154)", "clang version 3.7.0 (trunk 231150) (llvm/trunk 231154)",
isOptimized: false, runtimeVersion: 0, emissionKind: 1, isOptimized: false, runtimeVersion: 0, emissionKind: 1,
@ -416,7 +416,7 @@ a C/C++ front-end would generate the following descriptors:
;; ;;
;; Define the file ;; Define the file
;; ;;
!1 = !MDFile(filename: "/dev/stdin", !1 = !DIFile(filename: "/dev/stdin",
directory: "/Users/dexonsmith/data/llvm/debug-info") directory: "/Users/dexonsmith/data/llvm/debug-info")
;; An empty array. ;; An empty array.
@ -428,14 +428,14 @@ a C/C++ front-end would generate the following descriptors:
;; ;;
;; Define the global variable itself. ;; Define the global variable itself.
;; ;;
!4 = !MDGlobalVariable(name: "MyGlobal", scope: !0, file: !1, line: 1, !4 = !DIGlobalVariable(name: "MyGlobal", scope: !0, file: !1, line: 1,
type: !5, isLocal: false, isDefinition: true, type: !5, isLocal: false, isDefinition: true,
variable: i32* @MyGlobal) variable: i32* @MyGlobal)
;; ;;
;; Define the type ;; Define the type
;; ;;
!5 = !MDBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) !5 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
;; Dwarf version to output. ;; Dwarf version to output.
!6 = !{i32 2, !"Dwarf Version", i32 2} !6 = !{i32 2, !"Dwarf Version", i32 2}
@ -461,7 +461,7 @@ a C/C++ front-end would generate the following descriptors:
;; ;;
;; Define the anchor for subprograms. ;; Define the anchor for subprograms.
;; ;;
!4 = !MDSubprogram(name: "main", scope: !1, file: !1, line: 1, type: !5, !4 = !DISubprogram(name: "main", scope: !1, file: !1, line: 1, type: !5,
isLocal: false, isDefinition: true, scopeLine: 1, isLocal: false, isDefinition: true, scopeLine: 1,
flags: DIFlagPrototyped, isOptimized: false, flags: DIFlagPrototyped, isOptimized: false,
function: i32 (i32, i8**)* @main, variables: !2) function: i32 (i32, i8**)* @main, variables: !2)

View File

@ -187,13 +187,13 @@ expressions:
static DIBuilder *DBuilder; static DIBuilder *DBuilder;
struct DebugInfo { struct DebugInfo {
MDCompileUnit *TheCU; DICompileUnit *TheCU;
MDType *DblTy; DIType *DblTy;
MDType *getDoubleTy(); DIType *getDoubleTy();
} KSDbgInfo; } KSDbgInfo;
MDType *DebugInfo::getDoubleTy() { DIType *DebugInfo::getDoubleTy() {
if (DblTy.isValid()) if (DblTy.isValid())
return DblTy; return DblTy;
@ -245,25 +245,25 @@ So the context:
.. code-block:: c++ .. code-block:: c++
MDFile *Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(), DIFile *Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(),
KSDbgInfo.TheCU.getDirectory()); KSDbgInfo.TheCU.getDirectory());
giving us an MDFile and asking the ``Compile Unit`` we created above for the giving us an DIFile and asking the ``Compile Unit`` we created above for the
directory and filename where we are currently. Then, for now, we use some directory and filename where we are currently. Then, for now, we use some
source locations of 0 (since our AST doesn't currently have source location source locations of 0 (since our AST doesn't currently have source location
information) and construct our function definition: information) and construct our function definition:
.. code-block:: c++ .. code-block:: c++
MDScope *FContext = Unit; DIScope *FContext = Unit;
unsigned LineNo = 0; unsigned LineNo = 0;
unsigned ScopeLine = 0; unsigned ScopeLine = 0;
MDSubprogram *SP = DBuilder->createFunction( DISubprogram *SP = DBuilder->createFunction(
FContext, Name, StringRef(), Unit, LineNo, FContext, Name, StringRef(), Unit, LineNo,
CreateFunctionType(Args.size(), Unit), false /* internal linkage */, CreateFunctionType(Args.size(), Unit), false /* internal linkage */,
true /* definition */, ScopeLine, DebugNode::FlagPrototyped, false, F); true /* definition */, ScopeLine, DINode::FlagPrototyped, false, F);
and we now have an MDSubprogram that contains a reference to all of our and we now have an DISubprogram that contains a reference to all of our
metadata for the function. metadata for the function.
Source Locations Source Locations
@ -330,7 +330,7 @@ by constructing another small function:
.. code-block:: c++ .. code-block:: c++
void DebugInfo::emitLocation(ExprAST *AST) { void DebugInfo::emitLocation(ExprAST *AST) {
MDScope *Scope; DIScope *Scope;
if (LexicalBlocks.empty()) if (LexicalBlocks.empty())
Scope = TheCU; Scope = TheCU;
else else
@ -347,11 +347,11 @@ of scopes:
.. code-block:: c++ .. code-block:: c++
std::vector<MDScope *> LexicalBlocks; std::vector<DIScope *> LexicalBlocks;
std::map<const PrototypeAST *, MDScope *> FnScopeMap; std::map<const PrototypeAST *, DIScope *> FnScopeMap;
and keep a map of each function to the scope that it represents (an and keep a map of each function to the scope that it represents (an
MDSubprogram is also an MDScope). DISubprogram is also an DIScope).
Then we make sure to: Then we make sure to:
@ -392,10 +392,10 @@ argument allocas in ``PrototypeAST::CreateArgumentAllocas``.
.. code-block:: c++ .. code-block:: c++
MDScope *Scope = KSDbgInfo.LexicalBlocks.back(); DIScope *Scope = KSDbgInfo.LexicalBlocks.back();
MDFile *Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(), DIFile *Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(),
KSDbgInfo.TheCU.getDirectory()); KSDbgInfo.TheCU.getDirectory());
MDLocalVariable D = DBuilder->createLocalVariable( DILocalVariable D = DBuilder->createLocalVariable(
dwarf::DW_TAG_arg_variable, Scope, Args[Idx], Unit, Line, dwarf::DW_TAG_arg_variable, Scope, Args[Idx], Unit, Line,
KSDbgInfo.getDoubleTy(), Idx); KSDbgInfo.getDoubleTy(), Idx);

View File

@ -93,13 +93,13 @@ class ExprAST;
} }
static IRBuilder<> Builder(getGlobalContext()); static IRBuilder<> Builder(getGlobalContext());
struct DebugInfo { struct DebugInfo {
MDCompileUnit *TheCU; DICompileUnit *TheCU;
MDType *DblTy; DIType *DblTy;
std::vector<MDScope *> LexicalBlocks; std::vector<DIScope *> LexicalBlocks;
std::map<const PrototypeAST *, MDScope *> FnScopeMap; std::map<const PrototypeAST *, DIScope *> FnScopeMap;
void emitLocation(ExprAST *AST); void emitLocation(ExprAST *AST);
MDType *getDoubleTy(); DIType *getDoubleTy();
} KSDbgInfo; } KSDbgInfo;
static std::string IdentifierStr; // Filled in if tok_identifier static std::string IdentifierStr; // Filled in if tok_identifier
@ -816,7 +816,7 @@ static PrototypeAST *ParseExtern() {
static DIBuilder *DBuilder; static DIBuilder *DBuilder;
MDType *DebugInfo::getDoubleTy() { DIType *DebugInfo::getDoubleTy() {
if (DblTy) if (DblTy)
return DblTy; return DblTy;
@ -827,7 +827,7 @@ MDType *DebugInfo::getDoubleTy() {
void DebugInfo::emitLocation(ExprAST *AST) { void DebugInfo::emitLocation(ExprAST *AST) {
if (!AST) if (!AST)
return Builder.SetCurrentDebugLocation(DebugLoc()); return Builder.SetCurrentDebugLocation(DebugLoc());
MDScope *Scope; DIScope *Scope;
if (LexicalBlocks.empty()) if (LexicalBlocks.empty())
Scope = TheCU; Scope = TheCU;
else else
@ -836,9 +836,9 @@ void DebugInfo::emitLocation(ExprAST *AST) {
DebugLoc::get(AST->getLine(), AST->getCol(), Scope)); DebugLoc::get(AST->getLine(), AST->getCol(), Scope));
} }
static MDSubroutineType *CreateFunctionType(unsigned NumArgs, MDFile *Unit) { static DISubroutineType *CreateFunctionType(unsigned NumArgs, DIFile *Unit) {
SmallVector<Metadata *, 8> EltTys; SmallVector<Metadata *, 8> EltTys;
MDType *DblTy = KSDbgInfo.getDoubleTy(); DIType *DblTy = KSDbgInfo.getDoubleTy();
// Add the result type. // Add the result type.
EltTys.push_back(DblTy); EltTys.push_back(DblTy);
@ -1227,15 +1227,15 @@ Function *PrototypeAST::Codegen() {
AI->setName(Args[Idx]); AI->setName(Args[Idx]);
// Create a subprogram DIE for this function. // Create a subprogram DIE for this function.
MDFile *Unit = DBuilder->createFile(KSDbgInfo.TheCU->getFilename(), DIFile *Unit = DBuilder->createFile(KSDbgInfo.TheCU->getFilename(),
KSDbgInfo.TheCU->getDirectory()); KSDbgInfo.TheCU->getDirectory());
MDScope *FContext = Unit; DIScope *FContext = Unit;
unsigned LineNo = Line; unsigned LineNo = Line;
unsigned ScopeLine = Line; unsigned ScopeLine = Line;
MDSubprogram *SP = DBuilder->createFunction( DISubprogram *SP = DBuilder->createFunction(
FContext, Name, StringRef(), Unit, LineNo, FContext, Name, StringRef(), Unit, LineNo,
CreateFunctionType(Args.size(), Unit), false /* internal linkage */, CreateFunctionType(Args.size(), Unit), false /* internal linkage */,
true /* definition */, ScopeLine, DebugNode::FlagPrototyped, false, F); true /* definition */, ScopeLine, DINode::FlagPrototyped, false, F);
KSDbgInfo.FnScopeMap[this] = SP; KSDbgInfo.FnScopeMap[this] = SP;
return F; return F;
@ -1250,10 +1250,10 @@ void PrototypeAST::CreateArgumentAllocas(Function *F) {
AllocaInst *Alloca = CreateEntryBlockAlloca(F, Args[Idx]); AllocaInst *Alloca = CreateEntryBlockAlloca(F, Args[Idx]);
// Create a debug descriptor for the variable. // Create a debug descriptor for the variable.
MDScope *Scope = KSDbgInfo.LexicalBlocks.back(); DIScope *Scope = KSDbgInfo.LexicalBlocks.back();
MDFile *Unit = DBuilder->createFile(KSDbgInfo.TheCU->getFilename(), DIFile *Unit = DBuilder->createFile(KSDbgInfo.TheCU->getFilename(),
KSDbgInfo.TheCU->getDirectory()); KSDbgInfo.TheCU->getDirectory());
MDLocalVariable *D = DBuilder->createLocalVariable( DILocalVariable *D = DBuilder->createLocalVariable(
dwarf::DW_TAG_arg_variable, Scope, Args[Idx], Unit, Line, dwarf::DW_TAG_arg_variable, Scope, Args[Idx], Unit, Line,
KSDbgInfo.getDoubleTy(), Idx); KSDbgInfo.getDoubleTy(), Idx);

View File

@ -45,7 +45,7 @@ typedef std::pair<const MachineInstr *, const MachineInstr *> InsnRange;
class LexicalScope { class LexicalScope {
public: public:
LexicalScope(LexicalScope *P, const MDLocalScope *D, const MDLocation *I, LexicalScope(LexicalScope *P, const DILocalScope *D, const DILocation *I,
bool A) bool A)
: Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(A), : Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(A),
LastInsn(nullptr), FirstInsn(nullptr), DFSIn(0), DFSOut(0) { LastInsn(nullptr), FirstInsn(nullptr), DFSIn(0), DFSOut(0) {
@ -58,8 +58,8 @@ public:
// Accessors. // Accessors.
LexicalScope *getParent() const { return Parent; } LexicalScope *getParent() const { return Parent; }
const MDNode *getDesc() const { return Desc; } const MDNode *getDesc() const { return Desc; }
const MDLocation *getInlinedAt() const { return InlinedAtLocation; } const DILocation *getInlinedAt() const { return InlinedAtLocation; }
const MDLocalScope *getScopeNode() const { return Desc; } const DILocalScope *getScopeNode() const { return Desc; }
bool isAbstractScope() const { return AbstractScope; } bool isAbstractScope() const { return AbstractScope; }
SmallVectorImpl<LexicalScope *> &getChildren() { return Children; } SmallVectorImpl<LexicalScope *> &getChildren() { return Children; }
SmallVectorImpl<InsnRange> &getRanges() { return Ranges; } SmallVectorImpl<InsnRange> &getRanges() { return Ranges; }
@ -119,8 +119,8 @@ public:
private: private:
LexicalScope *Parent; // Parent to this scope. LexicalScope *Parent; // Parent to this scope.
const MDLocalScope *Desc; // Debug info descriptor. const DILocalScope *Desc; // Debug info descriptor.
const MDLocation *InlinedAtLocation; // Location at which this const DILocation *InlinedAtLocation; // Location at which this
// scope is inlined. // scope is inlined.
bool AbstractScope; // Abstract Scope bool AbstractScope; // Abstract Scope
SmallVector<LexicalScope *, 4> Children; // Scopes defined in scope. SmallVector<LexicalScope *, 4> Children; // Scopes defined in scope.
@ -159,16 +159,16 @@ public:
/// getMachineBasicBlocks - Populate given set using machine basic blocks /// getMachineBasicBlocks - Populate given set using machine basic blocks
/// which have machine instructions that belong to lexical scope identified by /// which have machine instructions that belong to lexical scope identified by
/// DebugLoc. /// DebugLoc.
void getMachineBasicBlocks(const MDLocation *DL, void getMachineBasicBlocks(const DILocation *DL,
SmallPtrSetImpl<const MachineBasicBlock *> &MBBs); SmallPtrSetImpl<const MachineBasicBlock *> &MBBs);
/// dominates - Return true if DebugLoc's lexical scope dominates at least one /// dominates - Return true if DebugLoc's lexical scope dominates at least one
/// machine instruction's lexical scope in a given machine basic block. /// machine instruction's lexical scope in a given machine basic block.
bool dominates(const MDLocation *DL, MachineBasicBlock *MBB); bool dominates(const DILocation *DL, MachineBasicBlock *MBB);
/// findLexicalScope - Find lexical scope, either regular or inlined, for the /// findLexicalScope - Find lexical scope, either regular or inlined, for the
/// given DebugLoc. Return NULL if not found. /// given DebugLoc. Return NULL if not found.
LexicalScope *findLexicalScope(const MDLocation *DL); LexicalScope *findLexicalScope(const DILocation *DL);
/// getAbstractScopesList - Return a reference to list of abstract scopes. /// getAbstractScopesList - Return a reference to list of abstract scopes.
ArrayRef<LexicalScope *> getAbstractScopesList() const { ArrayRef<LexicalScope *> getAbstractScopesList() const {
@ -176,19 +176,19 @@ public:
} }
/// findAbstractScope - Find an abstract scope or return null. /// findAbstractScope - Find an abstract scope or return null.
LexicalScope *findAbstractScope(const MDLocalScope *N) { LexicalScope *findAbstractScope(const DILocalScope *N) {
auto I = AbstractScopeMap.find(N); auto I = AbstractScopeMap.find(N);
return I != AbstractScopeMap.end() ? &I->second : nullptr; return I != AbstractScopeMap.end() ? &I->second : nullptr;
} }
/// findInlinedScope - Find an inlined scope for the given scope/inlined-at. /// findInlinedScope - Find an inlined scope for the given scope/inlined-at.
LexicalScope *findInlinedScope(const MDLocalScope *N, const MDLocation *IA) { LexicalScope *findInlinedScope(const DILocalScope *N, const DILocation *IA) {
auto I = InlinedLexicalScopeMap.find(std::make_pair(N, IA)); auto I = InlinedLexicalScopeMap.find(std::make_pair(N, IA));
return I != InlinedLexicalScopeMap.end() ? &I->second : nullptr; return I != InlinedLexicalScopeMap.end() ? &I->second : nullptr;
} }
/// findLexicalScope - Find regular lexical scope or return null. /// findLexicalScope - Find regular lexical scope or return null.
LexicalScope *findLexicalScope(const MDLocalScope *N) { LexicalScope *findLexicalScope(const DILocalScope *N) {
auto I = LexicalScopeMap.find(N); auto I = LexicalScopeMap.find(N);
return I != LexicalScopeMap.end() ? &I->second : nullptr; return I != LexicalScopeMap.end() ? &I->second : nullptr;
} }
@ -197,24 +197,24 @@ public:
void dump(); void dump();
/// getOrCreateAbstractScope - Find or create an abstract lexical scope. /// getOrCreateAbstractScope - Find or create an abstract lexical scope.
LexicalScope *getOrCreateAbstractScope(const MDLocalScope *Scope); LexicalScope *getOrCreateAbstractScope(const DILocalScope *Scope);
private: private:
/// getOrCreateLexicalScope - Find lexical scope for the given Scope/IA. If /// getOrCreateLexicalScope - Find lexical scope for the given Scope/IA. If
/// not available then create new lexical scope. /// not available then create new lexical scope.
LexicalScope *getOrCreateLexicalScope(const MDLocalScope *Scope, LexicalScope *getOrCreateLexicalScope(const DILocalScope *Scope,
const MDLocation *IA = nullptr); const DILocation *IA = nullptr);
LexicalScope *getOrCreateLexicalScope(const MDLocation *DL) { LexicalScope *getOrCreateLexicalScope(const DILocation *DL) {
return DL ? getOrCreateLexicalScope(DL->getScope(), DL->getInlinedAt()) return DL ? getOrCreateLexicalScope(DL->getScope(), DL->getInlinedAt())
: nullptr; : nullptr;
} }
/// getOrCreateRegularScope - Find or create a regular lexical scope. /// getOrCreateRegularScope - Find or create a regular lexical scope.
LexicalScope *getOrCreateRegularScope(const MDLocalScope *Scope); LexicalScope *getOrCreateRegularScope(const DILocalScope *Scope);
/// getOrCreateInlinedScope - Find or create an inlined lexical scope. /// getOrCreateInlinedScope - Find or create an inlined lexical scope.
LexicalScope *getOrCreateInlinedScope(const MDLocalScope *Scope, LexicalScope *getOrCreateInlinedScope(const DILocalScope *Scope,
const MDLocation *InlinedAt); const DILocation *InlinedAt);
/// extractLexicalScopes - Extract instruction ranges for each lexical scopes /// extractLexicalScopes - Extract instruction ranges for each lexical scopes
/// for the given machine function. /// for the given machine function.
@ -230,18 +230,18 @@ private:
/// LexicalScopeMap - Tracks the scopes in the current function. /// LexicalScopeMap - Tracks the scopes in the current function.
// Use an unordered_map to ensure value pointer validity over insertion. // Use an unordered_map to ensure value pointer validity over insertion.
std::unordered_map<const MDLocalScope *, LexicalScope> LexicalScopeMap; std::unordered_map<const DILocalScope *, LexicalScope> LexicalScopeMap;
/// InlinedLexicalScopeMap - Tracks inlined function scopes in current /// InlinedLexicalScopeMap - Tracks inlined function scopes in current
/// function. /// function.
std::unordered_map<std::pair<const MDLocalScope *, const MDLocation *>, std::unordered_map<std::pair<const DILocalScope *, const DILocation *>,
LexicalScope, LexicalScope,
pair_hash<const MDLocalScope *, const MDLocation *>> pair_hash<const DILocalScope *, const DILocation *>>
InlinedLexicalScopeMap; InlinedLexicalScopeMap;
/// AbstractScopeMap - These scopes are not included LexicalScopeMap. /// AbstractScopeMap - These scopes are not included LexicalScopeMap.
// Use an unordered_map to ensure value pointer validity over insertion. // Use an unordered_map to ensure value pointer validity over insertion.
std::unordered_map<const MDLocalScope *, LexicalScope> AbstractScopeMap; std::unordered_map<const DILocalScope *, LexicalScope> AbstractScopeMap;
/// AbstractScopesList - Tracks abstract scopes constructed while processing /// AbstractScopesList - Tracks abstract scopes constructed while processing
/// a function. /// a function.

View File

@ -246,16 +246,16 @@ public:
/// \brief Return the debug variable referenced by /// \brief Return the debug variable referenced by
/// this DBG_VALUE instruction. /// this DBG_VALUE instruction.
const MDLocalVariable *getDebugVariable() const { const DILocalVariable *getDebugVariable() const {
assert(isDebugValue() && "not a DBG_VALUE"); assert(isDebugValue() && "not a DBG_VALUE");
return cast<MDLocalVariable>(getOperand(2).getMetadata()); return cast<DILocalVariable>(getOperand(2).getMetadata());
} }
/// \brief Return the complex address expression referenced by /// \brief Return the complex address expression referenced by
/// this DBG_VALUE instruction. /// this DBG_VALUE instruction.
const MDExpression *getDebugExpression() const { const DIExpression *getDebugExpression() const {
assert(isDebugValue() && "not a DBG_VALUE"); assert(isDebugValue() && "not a DBG_VALUE");
return cast<MDExpression>(getOperand(3).getMetadata()); return cast<DIExpression>(getOperand(3).getMetadata());
} }
/// emitError - Emit an error referring to the source location of this /// emitError - Emit an error referring to the source location of this

View File

@ -356,9 +356,9 @@ inline MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL,
const MCInstrDesc &MCID, bool IsIndirect, const MCInstrDesc &MCID, bool IsIndirect,
unsigned Reg, unsigned Offset, unsigned Reg, unsigned Offset,
const MDNode *Variable, const MDNode *Expr) { const MDNode *Variable, const MDNode *Expr) {
assert(isa<MDLocalVariable>(Variable) && "not a variable"); assert(isa<DILocalVariable>(Variable) && "not a variable");
assert(cast<MDExpression>(Expr)->isValid() && "not an expression"); assert(cast<DIExpression>(Expr)->isValid() && "not an expression");
assert(cast<MDLocalVariable>(Variable)->isValidLocationForIntrinsic(DL) && assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree"); "Expected inlined-at fields to agree");
if (IsIndirect) if (IsIndirect)
return BuildMI(MF, DL, MCID) return BuildMI(MF, DL, MCID)
@ -385,8 +385,8 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
const MCInstrDesc &MCID, bool IsIndirect, const MCInstrDesc &MCID, bool IsIndirect,
unsigned Reg, unsigned Offset, unsigned Reg, unsigned Offset,
const MDNode *Variable, const MDNode *Expr) { const MDNode *Variable, const MDNode *Expr) {
assert(isa<MDLocalVariable>(Variable) && "not a variable"); assert(isa<DILocalVariable>(Variable) && "not a variable");
assert(cast<MDExpression>(Expr)->isValid() && "not an expression"); assert(cast<DIExpression>(Expr)->isValid() && "not an expression");
MachineFunction &MF = *BB.getParent(); MachineFunction &MF = *BB.getParent();
MachineInstr *MI = MachineInstr *MI =
BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, Variable, Expr); BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, Variable, Expr);

View File

@ -193,13 +193,13 @@ public:
static char ID; // Pass identification, replacement for typeid static char ID; // Pass identification, replacement for typeid
struct VariableDbgInfo { struct VariableDbgInfo {
const MDLocalVariable *Var; const DILocalVariable *Var;
const MDExpression *Expr; const DIExpression *Expr;
unsigned Slot; unsigned Slot;
const MDLocation *Loc; const DILocation *Loc;
VariableDbgInfo(const MDLocalVariable *Var, const MDExpression *Expr, VariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr,
unsigned Slot, const MDLocation *Loc) unsigned Slot, const DILocation *Loc)
: Var(Var), Expr(Expr), Slot(Slot), Loc(Loc) {} : Var(Var), Expr(Expr), Slot(Slot), Loc(Loc) {}
}; };
typedef SmallVector<VariableDbgInfo, 4> VariableDbgInfoMapTy; typedef SmallVector<VariableDbgInfo, 4> VariableDbgInfoMapTy;
@ -448,8 +448,8 @@ public:
/// setVariableDbgInfo - Collect information used to emit debugging /// setVariableDbgInfo - Collect information used to emit debugging
/// information of a variable. /// information of a variable.
void setVariableDbgInfo(const MDLocalVariable *Var, const MDExpression *Expr, void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr,
unsigned Slot, const MDLocation *Loc) { unsigned Slot, const DILocation *Loc) {
VariableDbgInfos.emplace_back(Var, Expr, Slot, Loc); VariableDbgInfos.emplace_back(Var, Expr, Slot, Loc);
} }

View File

@ -104,7 +104,7 @@ namespace llvm {
/// source location information in the back end /// source location information in the back end
/// without actually changing the output (e.g., /// without actually changing the output (e.g.,
/// when using optimization remarks). /// when using optimization remarks).
MDCompileUnit *createCompileUnit(unsigned Lang, StringRef File, DICompileUnit *createCompileUnit(unsigned Lang, StringRef File,
StringRef Dir, StringRef Producer, StringRef Dir, StringRef Producer,
bool isOptimized, StringRef Flags, bool isOptimized, StringRef Flags,
unsigned RV, StringRef SplitName = "", unsigned RV, StringRef SplitName = "",
@ -113,16 +113,16 @@ namespace llvm {
/// createFile - Create a file descriptor to hold debugging information /// createFile - Create a file descriptor to hold debugging information
/// for a file. /// for a file.
MDFile *createFile(StringRef Filename, StringRef Directory); DIFile *createFile(StringRef Filename, StringRef Directory);
/// createEnumerator - Create a single enumerator value. /// createEnumerator - Create a single enumerator value.
MDEnumerator *createEnumerator(StringRef Name, int64_t Val); DIEnumerator *createEnumerator(StringRef Name, int64_t Val);
/// \brief Create a DWARF unspecified type. /// \brief Create a DWARF unspecified type.
MDBasicType *createUnspecifiedType(StringRef Name); DIBasicType *createUnspecifiedType(StringRef Name);
/// \brief Create C++11 nullptr type. /// \brief Create C++11 nullptr type.
MDBasicType *createNullPtrType(); DIBasicType *createNullPtrType();
/// createBasicType - Create debugging information entry for a basic /// createBasicType - Create debugging information entry for a basic
/// type. /// type.
@ -130,21 +130,21 @@ namespace llvm {
/// @param SizeInBits Size of the type. /// @param SizeInBits Size of the type.
/// @param AlignInBits Type alignment. /// @param AlignInBits Type alignment.
/// @param Encoding DWARF encoding code, e.g. dwarf::DW_ATE_float. /// @param Encoding DWARF encoding code, e.g. dwarf::DW_ATE_float.
MDBasicType *createBasicType(StringRef Name, uint64_t SizeInBits, DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits,
uint64_t AlignInBits, unsigned Encoding); uint64_t AlignInBits, unsigned Encoding);
/// createQualifiedType - Create debugging information entry for a qualified /// createQualifiedType - Create debugging information entry for a qualified
/// type, e.g. 'const int'. /// type, e.g. 'const int'.
/// @param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type /// @param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type
/// @param FromTy Base Type. /// @param FromTy Base Type.
MDDerivedType *createQualifiedType(unsigned Tag, MDType *FromTy); DIDerivedType *createQualifiedType(unsigned Tag, DIType *FromTy);
/// createPointerType - Create debugging information entry for a pointer. /// createPointerType - Create debugging information entry for a pointer.
/// @param PointeeTy Type pointed by this pointer. /// @param PointeeTy Type pointed by this pointer.
/// @param SizeInBits Size. /// @param SizeInBits Size.
/// @param AlignInBits Alignment. (optional) /// @param AlignInBits Alignment. (optional)
/// @param Name Pointer type name. (optional) /// @param Name Pointer type name. (optional)
MDDerivedType *createPointerType(MDType *PointeeTy, uint64_t SizeInBits, DIDerivedType *createPointerType(DIType *PointeeTy, uint64_t SizeInBits,
uint64_t AlignInBits = 0, uint64_t AlignInBits = 0,
StringRef Name = ""); StringRef Name = "");
@ -153,13 +153,13 @@ namespace llvm {
/// @param SizeInBits Size. /// @param SizeInBits Size.
/// @param AlignInBits Alignment. (optional) /// @param AlignInBits Alignment. (optional)
/// @param Class Type for which this pointer points to members of. /// @param Class Type for which this pointer points to members of.
MDDerivedType *createMemberPointerType(MDType *PointeeTy, MDType *Class, DIDerivedType *createMemberPointerType(DIType *PointeeTy, DIType *Class,
uint64_t SizeInBits, uint64_t SizeInBits,
uint64_t AlignInBits = 0); uint64_t AlignInBits = 0);
/// createReferenceType - Create debugging information entry for a c++ /// createReferenceType - Create debugging information entry for a c++
/// style reference or rvalue reference type. /// style reference or rvalue reference type.
MDDerivedType *createReferenceType(unsigned Tag, MDType *RTy); DIDerivedType *createReferenceType(unsigned Tag, DIType *RTy);
/// createTypedef - Create debugging information entry for a typedef. /// createTypedef - Create debugging information entry for a typedef.
/// @param Ty Original type. /// @param Ty Original type.
@ -167,11 +167,11 @@ namespace llvm {
/// @param File File where this type is defined. /// @param File File where this type is defined.
/// @param LineNo Line number. /// @param LineNo Line number.
/// @param Context The surrounding context for the typedef. /// @param Context The surrounding context for the typedef.
MDDerivedType *createTypedef(MDType *Ty, StringRef Name, MDFile *File, DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File,
unsigned LineNo, MDScope *Context); unsigned LineNo, DIScope *Context);
/// createFriend - Create debugging information entry for a 'friend'. /// createFriend - Create debugging information entry for a 'friend'.
MDDerivedType *createFriend(MDType *Ty, MDType *FriendTy); DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
/// createInheritance - Create debugging information entry to establish /// createInheritance - Create debugging information entry to establish
/// inheritance relationship between two types. /// inheritance relationship between two types.
@ -180,7 +180,7 @@ namespace llvm {
/// @param BaseOffset Base offset. /// @param BaseOffset Base offset.
/// @param Flags Flags to describe inheritance attribute, /// @param Flags Flags to describe inheritance attribute,
/// e.g. private /// e.g. private
MDDerivedType *createInheritance(MDType *Ty, MDType *BaseTy, DIDerivedType *createInheritance(DIType *Ty, DIType *BaseTy,
uint64_t BaseOffset, unsigned Flags); uint64_t BaseOffset, unsigned Flags);
/// createMemberType - Create debugging information entry for a member. /// createMemberType - Create debugging information entry for a member.
@ -193,11 +193,11 @@ namespace llvm {
/// @param OffsetInBits Member offset. /// @param OffsetInBits Member offset.
/// @param Flags Flags to encode member attribute, e.g. private /// @param Flags Flags to encode member attribute, e.g. private
/// @param Ty Parent type. /// @param Ty Parent type.
MDDerivedType *createMemberType(MDScope *Scope, StringRef Name, DIDerivedType *createMemberType(DIScope *Scope, StringRef Name,
MDFile *File, unsigned LineNo, DIFile *File, unsigned LineNo,
uint64_t SizeInBits, uint64_t AlignInBits, uint64_t SizeInBits, uint64_t AlignInBits,
uint64_t OffsetInBits, unsigned Flags, uint64_t OffsetInBits, unsigned Flags,
MDType *Ty); DIType *Ty);
/// createStaticMemberType - Create debugging information entry for a /// createStaticMemberType - Create debugging information entry for a
/// C++ static data member. /// C++ static data member.
@ -208,9 +208,9 @@ namespace llvm {
/// @param Ty Type of the static member. /// @param Ty Type of the static member.
/// @param Flags Flags to encode member attribute, e.g. private. /// @param Flags Flags to encode member attribute, e.g. private.
/// @param Val Const initializer of the member. /// @param Val Const initializer of the member.
MDDerivedType *createStaticMemberType(MDScope *Scope, StringRef Name, DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
MDFile *File, unsigned LineNo, DIFile *File, unsigned LineNo,
MDType *Ty, unsigned Flags, DIType *Ty, unsigned Flags,
llvm::Constant *Val); llvm::Constant *Val);
/// createObjCIVar - Create debugging information entry for Objective-C /// createObjCIVar - Create debugging information entry for Objective-C
@ -224,10 +224,10 @@ namespace llvm {
/// @param Flags Flags to encode member attribute, e.g. private /// @param Flags Flags to encode member attribute, e.g. private
/// @param Ty Parent type. /// @param Ty Parent type.
/// @param PropertyNode Property associated with this ivar. /// @param PropertyNode Property associated with this ivar.
MDDerivedType *createObjCIVar(StringRef Name, MDFile *File, unsigned LineNo, DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo,
uint64_t SizeInBits, uint64_t AlignInBits, uint64_t SizeInBits, uint64_t AlignInBits,
uint64_t OffsetInBits, unsigned Flags, uint64_t OffsetInBits, unsigned Flags,
MDType *Ty, MDNode *PropertyNode); DIType *Ty, MDNode *PropertyNode);
/// createObjCProperty - Create debugging information entry for Objective-C /// createObjCProperty - Create debugging information entry for Objective-C
/// property. /// property.
@ -238,11 +238,11 @@ namespace llvm {
/// @param SetterName Name of the Objective C property setter selector. /// @param SetterName Name of the Objective C property setter selector.
/// @param PropertyAttributes Objective C property attributes. /// @param PropertyAttributes Objective C property attributes.
/// @param Ty Type. /// @param Ty Type.
MDObjCProperty *createObjCProperty(StringRef Name, MDFile *File, DIObjCProperty *createObjCProperty(StringRef Name, DIFile *File,
unsigned LineNumber, unsigned LineNumber,
StringRef GetterName, StringRef GetterName,
StringRef SetterName, StringRef SetterName,
unsigned PropertyAttributes, MDType *Ty); unsigned PropertyAttributes, DIType *Ty);
/// createClassType - Create debugging information entry for a class. /// createClassType - Create debugging information entry for a class.
/// @param Scope Scope in which this class is defined. /// @param Scope Scope in which this class is defined.
@ -260,12 +260,14 @@ namespace llvm {
/// for more info. /// for more info.
/// @param TemplateParms Template type parameters. /// @param TemplateParms Template type parameters.
/// @param UniqueIdentifier A unique identifier for the class. /// @param UniqueIdentifier A unique identifier for the class.
MDCompositeType *createClassType( DICompositeType *createClassType(DIScope *Scope, StringRef Name,
MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNumber, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, uint64_t SizeInBits, uint64_t AlignInBits,
unsigned Flags, MDType *DerivedFrom, DebugNodeArray Elements, uint64_t OffsetInBits, unsigned Flags,
MDType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr, DIType *DerivedFrom, DINodeArray Elements,
StringRef UniqueIdentifier = ""); DIType *VTableHolder = nullptr,
MDNode *TemplateParms = nullptr,
StringRef UniqueIdentifier = "");
/// createStructType - Create debugging information entry for a struct. /// createStructType - Create debugging information entry for a struct.
/// @param Scope Scope in which this struct is defined. /// @param Scope Scope in which this struct is defined.
@ -278,11 +280,11 @@ namespace llvm {
/// @param Elements Struct elements. /// @param Elements Struct elements.
/// @param RunTimeLang Optional parameter, Objective-C runtime version. /// @param RunTimeLang Optional parameter, Objective-C runtime version.
/// @param UniqueIdentifier A unique identifier for the struct. /// @param UniqueIdentifier A unique identifier for the struct.
MDCompositeType *createStructType( DICompositeType *createStructType(
MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNumber, DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
MDType *DerivedFrom, DebugNodeArray Elements, unsigned RunTimeLang = 0, DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0,
MDType *VTableHolder = nullptr, StringRef UniqueIdentifier = ""); DIType *VTableHolder = nullptr, StringRef UniqueIdentifier = "");
/// createUnionType - Create debugging information entry for an union. /// createUnionType - Create debugging information entry for an union.
/// @param Scope Scope in which this union is defined. /// @param Scope Scope in which this union is defined.
@ -295,10 +297,10 @@ namespace llvm {
/// @param Elements Union elements. /// @param Elements Union elements.
/// @param RunTimeLang Optional parameter, Objective-C runtime version. /// @param RunTimeLang Optional parameter, Objective-C runtime version.
/// @param UniqueIdentifier A unique identifier for the union. /// @param UniqueIdentifier A unique identifier for the union.
MDCompositeType *createUnionType(MDScope *Scope, StringRef Name, DICompositeType *createUnionType(DIScope *Scope, StringRef Name,
MDFile *File, unsigned LineNumber, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t AlignInBits, uint64_t SizeInBits, uint64_t AlignInBits,
unsigned Flags, DebugNodeArray Elements, unsigned Flags, DINodeArray Elements,
unsigned RunTimeLang = 0, unsigned RunTimeLang = 0,
StringRef UniqueIdentifier = ""); StringRef UniqueIdentifier = "");
@ -307,8 +309,8 @@ namespace llvm {
/// @param Scope Scope in which this type is defined. /// @param Scope Scope in which this type is defined.
/// @param Name Type parameter name. /// @param Name Type parameter name.
/// @param Ty Parameter type. /// @param Ty Parameter type.
MDTemplateTypeParameter * DITemplateTypeParameter *
createTemplateTypeParameter(MDScope *Scope, StringRef Name, MDType *Ty); createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty);
/// createTemplateValueParameter - Create debugging information for template /// createTemplateValueParameter - Create debugging information for template
/// value parameter. /// value parameter.
@ -316,9 +318,9 @@ namespace llvm {
/// @param Name Value parameter name. /// @param Name Value parameter name.
/// @param Ty Parameter type. /// @param Ty Parameter type.
/// @param Val Constant parameter value. /// @param Val Constant parameter value.
MDTemplateValueParameter *createTemplateValueParameter(MDScope *Scope, DITemplateValueParameter *createTemplateValueParameter(DIScope *Scope,
StringRef Name, StringRef Name,
MDType *Ty, DIType *Ty,
Constant *Val); Constant *Val);
/// \brief Create debugging information for a template template parameter. /// \brief Create debugging information for a template template parameter.
@ -326,9 +328,9 @@ namespace llvm {
/// @param Name Value parameter name. /// @param Name Value parameter name.
/// @param Ty Parameter type. /// @param Ty Parameter type.
/// @param Val The fully qualified name of the template. /// @param Val The fully qualified name of the template.
MDTemplateValueParameter *createTemplateTemplateParameter(MDScope *Scope, DITemplateValueParameter *createTemplateTemplateParameter(DIScope *Scope,
StringRef Name, StringRef Name,
MDType *Ty, DIType *Ty,
StringRef Val); StringRef Val);
/// \brief Create debugging information for a template parameter pack. /// \brief Create debugging information for a template parameter pack.
@ -336,26 +338,26 @@ namespace llvm {
/// @param Name Value parameter name. /// @param Name Value parameter name.
/// @param Ty Parameter type. /// @param Ty Parameter type.
/// @param Val An array of types in the pack. /// @param Val An array of types in the pack.
MDTemplateValueParameter *createTemplateParameterPack(MDScope *Scope, DITemplateValueParameter *createTemplateParameterPack(DIScope *Scope,
StringRef Name, StringRef Name,
MDType *Ty, DIType *Ty,
DebugNodeArray Val); DINodeArray Val);
/// createArrayType - Create debugging information entry for an array. /// createArrayType - Create debugging information entry for an array.
/// @param Size Array size. /// @param Size Array size.
/// @param AlignInBits Alignment. /// @param AlignInBits Alignment.
/// @param Ty Element type. /// @param Ty Element type.
/// @param Subscripts Subscripts. /// @param Subscripts Subscripts.
MDCompositeType *createArrayType(uint64_t Size, uint64_t AlignInBits, DICompositeType *createArrayType(uint64_t Size, uint64_t AlignInBits,
MDType *Ty, DebugNodeArray Subscripts); DIType *Ty, DINodeArray Subscripts);
/// createVectorType - Create debugging information entry for a vector type. /// createVectorType - Create debugging information entry for a vector type.
/// @param Size Array size. /// @param Size Array size.
/// @param AlignInBits Alignment. /// @param AlignInBits Alignment.
/// @param Ty Element type. /// @param Ty Element type.
/// @param Subscripts Subscripts. /// @param Subscripts Subscripts.
MDCompositeType *createVectorType(uint64_t Size, uint64_t AlignInBits, DICompositeType *createVectorType(uint64_t Size, uint64_t AlignInBits,
MDType *Ty, DebugNodeArray Subscripts); DIType *Ty, DINodeArray Subscripts);
/// createEnumerationType - Create debugging information entry for an /// createEnumerationType - Create debugging information entry for an
/// enumeration. /// enumeration.
@ -368,10 +370,10 @@ namespace llvm {
/// @param Elements Enumeration elements. /// @param Elements Enumeration elements.
/// @param UnderlyingType Underlying type of a C++11/ObjC fixed enum. /// @param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
/// @param UniqueIdentifier A unique identifier for the enum. /// @param UniqueIdentifier A unique identifier for the enum.
MDCompositeType *createEnumerationType( DICompositeType *createEnumerationType(
MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNumber, DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t AlignInBits, DebugNodeArray Elements, uint64_t SizeInBits, uint64_t AlignInBits, DINodeArray Elements,
MDType *UnderlyingType, StringRef UniqueIdentifier = ""); DIType *UnderlyingType, StringRef UniqueIdentifier = "");
/// createSubroutineType - Create subroutine type. /// createSubroutineType - Create subroutine type.
/// @param File File in which this subroutine is defined. /// @param File File in which this subroutine is defined.
@ -379,49 +381,49 @@ namespace llvm {
/// includes return type at 0th index. /// includes return type at 0th index.
/// @param Flags E.g.: LValueReference. /// @param Flags E.g.: LValueReference.
/// These flags are used to emit dwarf attributes. /// These flags are used to emit dwarf attributes.
MDSubroutineType *createSubroutineType(MDFile *File, DISubroutineType *createSubroutineType(DIFile *File,
MDTypeRefArray ParameterTypes, DITypeRefArray ParameterTypes,
unsigned Flags = 0); unsigned Flags = 0);
/// createArtificialType - Create a new MDType* with "artificial" flag set. /// createArtificialType - Create a new DIType* with "artificial" flag set.
MDType *createArtificialType(MDType *Ty); DIType *createArtificialType(DIType *Ty);
/// createObjectPointerType - Create a new MDType* with the "object pointer" /// createObjectPointerType - Create a new DIType* with the "object pointer"
/// flag set. /// flag set.
MDType *createObjectPointerType(MDType *Ty); DIType *createObjectPointerType(DIType *Ty);
/// \brief Create a permanent forward-declared type. /// \brief Create a permanent forward-declared type.
MDCompositeType *createForwardDecl(unsigned Tag, StringRef Name, DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,
MDScope *Scope, MDFile *F, unsigned Line, DIScope *Scope, DIFile *F, unsigned Line,
unsigned RuntimeLang = 0, unsigned RuntimeLang = 0,
uint64_t SizeInBits = 0, uint64_t SizeInBits = 0,
uint64_t AlignInBits = 0, uint64_t AlignInBits = 0,
StringRef UniqueIdentifier = ""); StringRef UniqueIdentifier = "");
/// \brief Create a temporary forward-declared type. /// \brief Create a temporary forward-declared type.
MDCompositeType *createReplaceableCompositeType( DICompositeType *createReplaceableCompositeType(
unsigned Tag, StringRef Name, MDScope *Scope, MDFile *F, unsigned Line, unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
unsigned RuntimeLang = 0, uint64_t SizeInBits = 0, unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
uint64_t AlignInBits = 0, unsigned Flags = DebugNode::FlagFwdDecl, uint64_t AlignInBits = 0, unsigned Flags = DINode::FlagFwdDecl,
StringRef UniqueIdentifier = ""); StringRef UniqueIdentifier = "");
/// retainType - Retain MDType* in a module even if it is not referenced /// retainType - Retain DIType* in a module even if it is not referenced
/// through debug info anchors. /// through debug info anchors.
void retainType(MDType *T); void retainType(DIType *T);
/// createUnspecifiedParameter - Create unspecified parameter type /// createUnspecifiedParameter - Create unspecified parameter type
/// for a subroutine type. /// for a subroutine type.
MDBasicType *createUnspecifiedParameter(); DIBasicType *createUnspecifiedParameter();
/// getOrCreateArray - Get a DebugNodeArray, create one if required. /// getOrCreateArray - Get a DINodeArray, create one if required.
DebugNodeArray getOrCreateArray(ArrayRef<Metadata *> Elements); DINodeArray getOrCreateArray(ArrayRef<Metadata *> Elements);
/// getOrCreateTypeArray - Get a MDTypeRefArray, create one if required. /// getOrCreateTypeArray - Get a DITypeRefArray, create one if required.
MDTypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements); DITypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements);
/// getOrCreateSubrange - Create a descriptor for a value range. This /// getOrCreateSubrange - Create a descriptor for a value range. This
/// implicitly uniques the values returned. /// implicitly uniques the values returned.
MDSubrange *getOrCreateSubrange(int64_t Lo, int64_t Count); DISubrange *getOrCreateSubrange(int64_t Lo, int64_t Count);
/// createGlobalVariable - Create a new descriptor for the specified /// createGlobalVariable - Create a new descriptor for the specified
/// variable. /// variable.
@ -435,18 +437,18 @@ namespace llvm {
/// externally visible or not. /// externally visible or not.
/// @param Val llvm::Value of the variable. /// @param Val llvm::Value of the variable.
/// @param Decl Reference to the corresponding declaration. /// @param Decl Reference to the corresponding declaration.
MDGlobalVariable *createGlobalVariable(MDScope *Context, StringRef Name, DIGlobalVariable *createGlobalVariable(DIScope *Context, StringRef Name,
StringRef LinkageName, MDFile *File, StringRef LinkageName, DIFile *File,
unsigned LineNo, MDType *Ty, unsigned LineNo, DIType *Ty,
bool isLocalToUnit, bool isLocalToUnit,
llvm::Constant *Val, llvm::Constant *Val,
MDNode *Decl = nullptr); MDNode *Decl = nullptr);
/// createTempGlobalVariableFwdDecl - Identical to createGlobalVariable /// createTempGlobalVariableFwdDecl - Identical to createGlobalVariable
/// except that the resulting DbgNode is temporary and meant to be RAUWed. /// except that the resulting DbgNode is temporary and meant to be RAUWed.
MDGlobalVariable *createTempGlobalVariableFwdDecl( DIGlobalVariable *createTempGlobalVariableFwdDecl(
MDScope *Context, StringRef Name, StringRef LinkageName, MDFile *File, DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
unsigned LineNo, MDType *Ty, bool isLocalToUnit, llvm::Constant *Val, unsigned LineNo, DIType *Ty, bool isLocalToUnit, llvm::Constant *Val,
MDNode *Decl = nullptr); MDNode *Decl = nullptr);
/// createLocalVariable - Create a new descriptor for the specified /// createLocalVariable - Create a new descriptor for the specified
@ -463,9 +465,9 @@ namespace llvm {
/// @param Flags Flags, e.g. artificial variable. /// @param Flags Flags, e.g. artificial variable.
/// @param ArgNo If this variable is an argument then this argument's /// @param ArgNo If this variable is an argument then this argument's
/// number. 1 indicates 1st argument. /// number. 1 indicates 1st argument.
MDLocalVariable *createLocalVariable(unsigned Tag, MDScope *Scope, DILocalVariable *createLocalVariable(unsigned Tag, DIScope *Scope,
StringRef Name, MDFile *File, StringRef Name, DIFile *File,
unsigned LineNo, MDType *Ty, unsigned LineNo, DIType *Ty,
bool AlwaysPreserve = false, bool AlwaysPreserve = false,
unsigned Flags = 0, unsigned Flags = 0,
unsigned ArgNo = 0); unsigned ArgNo = 0);
@ -473,19 +475,19 @@ namespace llvm {
/// createExpression - Create a new descriptor for the specified /// createExpression - Create a new descriptor for the specified
/// variable which has a complex address expression for its address. /// variable which has a complex address expression for its address.
/// @param Addr An array of complex address operations. /// @param Addr An array of complex address operations.
MDExpression *createExpression(ArrayRef<uint64_t> Addr = None); DIExpression *createExpression(ArrayRef<uint64_t> Addr = None);
MDExpression *createExpression(ArrayRef<int64_t> Addr); DIExpression *createExpression(ArrayRef<int64_t> Addr);
/// createBitPieceExpression - Create a descriptor to describe one part /// createBitPieceExpression - Create a descriptor to describe one part
/// of aggregate variable that is fragmented across multiple Values. /// of aggregate variable that is fragmented across multiple Values.
/// ///
/// @param OffsetInBits Offset of the piece in bits. /// @param OffsetInBits Offset of the piece in bits.
/// @param SizeInBits Size of the piece in bits. /// @param SizeInBits Size of the piece in bits.
MDExpression *createBitPieceExpression(unsigned OffsetInBits, DIExpression *createBitPieceExpression(unsigned OffsetInBits,
unsigned SizeInBits); unsigned SizeInBits);
/// createFunction - Create a new descriptor for the specified subprogram. /// createFunction - Create a new descriptor for the specified subprogram.
/// See comments in MDSubprogram* for descriptions of these fields. /// See comments in DISubprogram* for descriptions of these fields.
/// @param Scope Function scope. /// @param Scope Function scope.
/// @param Name Function name. /// @param Name Function name.
/// @param LinkageName Mangled function name. /// @param LinkageName Mangled function name.
@ -500,9 +502,9 @@ namespace llvm {
/// @param isOptimized True if optimization is ON. /// @param isOptimized True if optimization is ON.
/// @param Fn llvm::Function pointer. /// @param Fn llvm::Function pointer.
/// @param TParam Function template parameters. /// @param TParam Function template parameters.
MDSubprogram * DISubprogram *
createFunction(MDScope *Scope, StringRef Name, StringRef LinkageName, createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName,
MDFile *File, unsigned LineNo, MDSubroutineType *Ty, DIFile *File, unsigned LineNo, DISubroutineType *Ty,
bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine,
unsigned Flags = 0, bool isOptimized = false, unsigned Flags = 0, bool isOptimized = false,
Function *Fn = nullptr, MDNode *TParam = nullptr, Function *Fn = nullptr, MDNode *TParam = nullptr,
@ -510,25 +512,25 @@ namespace llvm {
/// createTempFunctionFwdDecl - Identical to createFunction, /// createTempFunctionFwdDecl - Identical to createFunction,
/// except that the resulting DbgNode is meant to be RAUWed. /// except that the resulting DbgNode is meant to be RAUWed.
MDSubprogram *createTempFunctionFwdDecl( DISubprogram *createTempFunctionFwdDecl(
MDScope *Scope, StringRef Name, StringRef LinkageName, MDFile *File, DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
unsigned LineNo, MDSubroutineType *Ty, bool isLocalToUnit, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
bool isDefinition, unsigned ScopeLine, unsigned Flags = 0, bool isDefinition, unsigned ScopeLine, unsigned Flags = 0,
bool isOptimized = false, Function *Fn = nullptr, bool isOptimized = false, Function *Fn = nullptr,
MDNode *TParam = nullptr, MDNode *Decl = nullptr); MDNode *TParam = nullptr, MDNode *Decl = nullptr);
/// FIXME: this is added for dragonegg. Once we update dragonegg /// FIXME: this is added for dragonegg. Once we update dragonegg
/// to call resolve function, this will be removed. /// to call resolve function, this will be removed.
MDSubprogram * DISubprogram *
createFunction(MDScopeRef Scope, StringRef Name, StringRef LinkageName, createFunction(DIScopeRef Scope, StringRef Name, StringRef LinkageName,
MDFile *File, unsigned LineNo, MDSubroutineType *Ty, DIFile *File, unsigned LineNo, DISubroutineType *Ty,
bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine,
unsigned Flags = 0, bool isOptimized = false, unsigned Flags = 0, bool isOptimized = false,
Function *Fn = nullptr, MDNode *TParam = nullptr, Function *Fn = nullptr, MDNode *TParam = nullptr,
MDNode *Decl = nullptr); MDNode *Decl = nullptr);
/// createMethod - Create a new descriptor for the specified C++ method. /// createMethod - Create a new descriptor for the specified C++ method.
/// See comments in MDSubprogram* for descriptions of these fields. /// See comments in DISubprogram* for descriptions of these fields.
/// @param Scope Function scope. /// @param Scope Function scope.
/// @param Name Function name. /// @param Name Function name.
/// @param LinkageName Mangled function name. /// @param LinkageName Mangled function name.
@ -546,11 +548,11 @@ namespace llvm {
/// @param isOptimized True if optimization is ON. /// @param isOptimized True if optimization is ON.
/// @param Fn llvm::Function pointer. /// @param Fn llvm::Function pointer.
/// @param TParam Function template parameters. /// @param TParam Function template parameters.
MDSubprogram * DISubprogram *
createMethod(MDScope *Scope, StringRef Name, StringRef LinkageName, createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName,
MDFile *File, unsigned LineNo, MDSubroutineType *Ty, DIFile *File, unsigned LineNo, DISubroutineType *Ty,
bool isLocalToUnit, bool isDefinition, unsigned Virtuality = 0, bool isLocalToUnit, bool isDefinition, unsigned Virtuality = 0,
unsigned VTableIndex = 0, MDType *VTableHolder = nullptr, unsigned VTableIndex = 0, DIType *VTableHolder = nullptr,
unsigned Flags = 0, bool isOptimized = false, unsigned Flags = 0, bool isOptimized = false,
Function *Fn = nullptr, MDNode *TParam = nullptr); Function *Fn = nullptr, MDNode *TParam = nullptr);
@ -560,7 +562,7 @@ namespace llvm {
/// @param Name Name of this namespace /// @param Name Name of this namespace
/// @param File Source file /// @param File Source file
/// @param LineNo Line number /// @param LineNo Line number
MDNamespace *createNameSpace(MDScope *Scope, StringRef Name, MDFile *File, DINamespace *createNameSpace(DIScope *Scope, StringRef Name, DIFile *File,
unsigned LineNo); unsigned LineNo);
/// createLexicalBlockFile - This creates a descriptor for a lexical /// createLexicalBlockFile - This creates a descriptor for a lexical
@ -569,7 +571,7 @@ namespace llvm {
/// @param Scope Lexical block. /// @param Scope Lexical block.
/// @param File Source file. /// @param File Source file.
/// @param Discriminator DWARF path discriminator value. /// @param Discriminator DWARF path discriminator value.
MDLexicalBlockFile *createLexicalBlockFile(MDScope *Scope, MDFile *File, DILexicalBlockFile *createLexicalBlockFile(DIScope *Scope, DIFile *File,
unsigned Discriminator = 0); unsigned Discriminator = 0);
/// createLexicalBlock - This creates a descriptor for a lexical block /// createLexicalBlock - This creates a descriptor for a lexical block
@ -578,30 +580,30 @@ namespace llvm {
/// @param File Source file. /// @param File Source file.
/// @param Line Line number. /// @param Line Line number.
/// @param Col Column number. /// @param Col Column number.
MDLexicalBlock *createLexicalBlock(MDScope *Scope, MDFile *File, DILexicalBlock *createLexicalBlock(DIScope *Scope, DIFile *File,
unsigned Line, unsigned Col); unsigned Line, unsigned Col);
/// \brief Create a descriptor for an imported module. /// \brief Create a descriptor for an imported module.
/// @param Context The scope this module is imported into /// @param Context The scope this module is imported into
/// @param NS The namespace being imported here /// @param NS The namespace being imported here
/// @param Line Line number /// @param Line Line number
MDImportedEntity *createImportedModule(MDScope *Context, MDNamespace *NS, DIImportedEntity *createImportedModule(DIScope *Context, DINamespace *NS,
unsigned Line); unsigned Line);
/// \brief Create a descriptor for an imported module. /// \brief Create a descriptor for an imported module.
/// @param Context The scope this module is imported into /// @param Context The scope this module is imported into
/// @param NS An aliased namespace /// @param NS An aliased namespace
/// @param Line Line number /// @param Line Line number
MDImportedEntity *createImportedModule(MDScope *Context, DIImportedEntity *createImportedModule(DIScope *Context,
MDImportedEntity *NS, unsigned Line); DIImportedEntity *NS, unsigned Line);
/// \brief Create a descriptor for an imported function. /// \brief Create a descriptor for an imported function.
/// @param Context The scope this module is imported into /// @param Context The scope this module is imported into
/// @param Decl The declaration (or definition) of a function, type, or /// @param Decl The declaration (or definition) of a function, type, or
/// variable /// variable
/// @param Line Line number /// @param Line Line number
MDImportedEntity *createImportedDeclaration(MDScope *Context, DIImportedEntity *createImportedDeclaration(DIScope *Context, DINode *Decl,
DebugNode *Decl, unsigned Line, unsigned Line,
StringRef Name = ""); StringRef Name = "");
/// insertDeclare - Insert a new llvm.dbg.declare intrinsic call. /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
@ -610,8 +612,8 @@ namespace llvm {
/// @param Expr A complex location expression. /// @param Expr A complex location expression.
/// @param DL Debug info location. /// @param DL Debug info location.
/// @param InsertAtEnd Location for the new intrinsic. /// @param InsertAtEnd Location for the new intrinsic.
Instruction *insertDeclare(llvm::Value *Storage, MDLocalVariable *VarInfo, Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
MDExpression *Expr, const MDLocation *DL, DIExpression *Expr, const DILocation *DL,
BasicBlock *InsertAtEnd); BasicBlock *InsertAtEnd);
/// insertDeclare - Insert a new llvm.dbg.declare intrinsic call. /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
@ -620,8 +622,8 @@ namespace llvm {
/// @param Expr A complex location expression. /// @param Expr A complex location expression.
/// @param DL Debug info location. /// @param DL Debug info location.
/// @param InsertBefore Location for the new intrinsic. /// @param InsertBefore Location for the new intrinsic.
Instruction *insertDeclare(llvm::Value *Storage, MDLocalVariable *VarInfo, Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
MDExpression *Expr, const MDLocation *DL, DIExpression *Expr, const DILocation *DL,
Instruction *InsertBefore); Instruction *InsertBefore);
/// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
@ -632,9 +634,9 @@ namespace llvm {
/// @param DL Debug info location. /// @param DL Debug info location.
/// @param InsertAtEnd Location for the new intrinsic. /// @param InsertAtEnd Location for the new intrinsic.
Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset, Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
MDLocalVariable *VarInfo, DILocalVariable *VarInfo,
MDExpression *Expr, DIExpression *Expr,
const MDLocation *DL, const DILocation *DL,
BasicBlock *InsertAtEnd); BasicBlock *InsertAtEnd);
/// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
@ -645,25 +647,25 @@ namespace llvm {
/// @param DL Debug info location. /// @param DL Debug info location.
/// @param InsertBefore Location for the new intrinsic. /// @param InsertBefore Location for the new intrinsic.
Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset, Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
MDLocalVariable *VarInfo, DILocalVariable *VarInfo,
MDExpression *Expr, DIExpression *Expr,
const MDLocation *DL, const DILocation *DL,
Instruction *InsertBefore); Instruction *InsertBefore);
/// \brief Replace the vtable holder in the given composite type. /// \brief Replace the vtable holder in the given composite type.
/// ///
/// If this creates a self reference, it may orphan some unresolved cycles /// If this creates a self reference, it may orphan some unresolved cycles
/// in the operands of \c T, so \a DIBuilder needs to track that. /// in the operands of \c T, so \a DIBuilder needs to track that.
void replaceVTableHolder(MDCompositeType *&T, void replaceVTableHolder(DICompositeType *&T,
MDCompositeType *VTableHolder); DICompositeType *VTableHolder);
/// \brief Replace arrays on a composite type. /// \brief Replace arrays on a composite type.
/// ///
/// If \c T is resolved, but the arrays aren't -- which can happen if \c T /// If \c T is resolved, but the arrays aren't -- which can happen if \c T
/// has a self-reference -- \a DIBuilder needs to track the array to /// has a self-reference -- \a DIBuilder needs to track the array to
/// resolve cycles. /// resolve cycles.
void replaceArrays(MDCompositeType *&T, DebugNodeArray Elements, void replaceArrays(DICompositeType *&T, DINodeArray Elements,
DebugNodeArray TParems = DebugNodeArray()); DINodeArray TParems = DINodeArray());
/// \brief Replace a temporary node. /// \brief Replace a temporary node.
/// ///

View File

@ -34,18 +34,18 @@ class DbgDeclareInst;
class DbgValueInst; class DbgValueInst;
/// \brief Maps from type identifier to the actual MDNode. /// \brief Maps from type identifier to the actual MDNode.
typedef DenseMap<const MDString *, MDType *> DITypeIdentifierMap; typedef DenseMap<const MDString *, DIType *> DITypeIdentifierMap;
/// \brief Find subprogram that is enclosing this scope. /// \brief Find subprogram that is enclosing this scope.
MDSubprogram *getDISubprogram(const MDNode *Scope); DISubprogram *getDISubprogram(const MDNode *Scope);
/// \brief Find debug info for a given function. /// \brief Find debug info for a given function.
/// ///
/// \returns a valid subprogram, if found. Otherwise, return \c nullptr. /// \returns a valid subprogram, if found. Otherwise, return \c nullptr.
MDSubprogram *getDISubprogram(const Function *F); DISubprogram *getDISubprogram(const Function *F);
/// \brief Find underlying composite type. /// \brief Find underlying composite type.
MDCompositeTypeBase *getDICompositeType(MDType *T); DICompositeTypeBase *getDICompositeType(DIType *T);
/// \brief Generate map by visiting all retained types. /// \brief Generate map by visiting all retained types.
DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes); DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes);
@ -81,7 +81,7 @@ public:
/// \brief Process DbgValueInst. /// \brief Process DbgValueInst.
void processValue(const Module &M, const DbgValueInst *DVI); void processValue(const Module &M, const DbgValueInst *DVI);
/// \brief Process debug info location. /// \brief Process debug info location.
void processLocation(const Module &M, const MDLocation *Loc); void processLocation(const Module &M, const DILocation *Loc);
/// \brief Clear all lists. /// \brief Clear all lists.
void reset(); void reset();
@ -89,23 +89,23 @@ public:
private: private:
void InitializeTypeMap(const Module &M); void InitializeTypeMap(const Module &M);
void processType(MDType *DT); void processType(DIType *DT);
void processSubprogram(MDSubprogram *SP); void processSubprogram(DISubprogram *SP);
void processScope(MDScope *Scope); void processScope(DIScope *Scope);
bool addCompileUnit(MDCompileUnit *CU); bool addCompileUnit(DICompileUnit *CU);
bool addGlobalVariable(MDGlobalVariable *DIG); bool addGlobalVariable(DIGlobalVariable *DIG);
bool addSubprogram(MDSubprogram *SP); bool addSubprogram(DISubprogram *SP);
bool addType(MDType *DT); bool addType(DIType *DT);
bool addScope(MDScope *Scope); bool addScope(DIScope *Scope);
public: public:
typedef SmallVectorImpl<MDCompileUnit *>::const_iterator typedef SmallVectorImpl<DICompileUnit *>::const_iterator
compile_unit_iterator; compile_unit_iterator;
typedef SmallVectorImpl<MDSubprogram *>::const_iterator subprogram_iterator; typedef SmallVectorImpl<DISubprogram *>::const_iterator subprogram_iterator;
typedef SmallVectorImpl<MDGlobalVariable *>::const_iterator typedef SmallVectorImpl<DIGlobalVariable *>::const_iterator
global_variable_iterator; global_variable_iterator;
typedef SmallVectorImpl<MDType *>::const_iterator type_iterator; typedef SmallVectorImpl<DIType *>::const_iterator type_iterator;
typedef SmallVectorImpl<MDScope *>::const_iterator scope_iterator; typedef SmallVectorImpl<DIScope *>::const_iterator scope_iterator;
iterator_range<compile_unit_iterator> compile_units() const { iterator_range<compile_unit_iterator> compile_units() const {
return iterator_range<compile_unit_iterator>(CUs.begin(), CUs.end()); return iterator_range<compile_unit_iterator>(CUs.begin(), CUs.end());
@ -134,11 +134,11 @@ public:
unsigned scope_count() const { return Scopes.size(); } unsigned scope_count() const { return Scopes.size(); }
private: private:
SmallVector<MDCompileUnit *, 8> CUs; SmallVector<DICompileUnit *, 8> CUs;
SmallVector<MDSubprogram *, 8> SPs; SmallVector<DISubprogram *, 8> SPs;
SmallVector<MDGlobalVariable *, 8> GVs; SmallVector<DIGlobalVariable *, 8> GVs;
SmallVector<MDType *, 8> TYs; SmallVector<DIType *, 8> TYs;
SmallVector<MDScope *, 8> Scopes; SmallVector<DIScope *, 8> Scopes;
SmallPtrSet<const MDNode *, 64> NodesSeen; SmallPtrSet<const MDNode *, 64> NodesSeen;
DITypeIdentifierMap TypeIdentifierMap; DITypeIdentifierMap TypeIdentifierMap;
@ -146,7 +146,7 @@ private:
bool TypeMapInitialized; bool TypeMapInitialized;
}; };
DenseMap<const Function *, MDSubprogram *> makeSubprogramMap(const Module &M); DenseMap<const Function *, DISubprogram *> makeSubprogramMap(const Module &M);
} // end namespace llvm } // end namespace llvm

File diff suppressed because it is too large Load Diff

View File

@ -22,14 +22,14 @@ namespace llvm {
class LLVMContext; class LLVMContext;
class raw_ostream; class raw_ostream;
class MDLocation; class DILocation;
/// \brief A debug info location. /// \brief A debug info location.
/// ///
/// This class is a wrapper around a tracking reference to an \a MDLocation /// This class is a wrapper around a tracking reference to an \a DILocation
/// pointer. /// pointer.
/// ///
/// To avoid extra includes, \a DebugLoc doubles the \a MDLocation API with a /// To avoid extra includes, \a DebugLoc doubles the \a DILocation API with a
/// one based on relatively opaque \a MDNode pointers. /// one based on relatively opaque \a MDNode pointers.
class DebugLoc { class DebugLoc {
TrackingMDNodeRef Loc; TrackingMDNodeRef Loc;
@ -47,31 +47,31 @@ namespace llvm {
return *this; return *this;
} }
/// \brief Construct from an \a MDLocation. /// \brief Construct from an \a DILocation.
DebugLoc(const MDLocation *L); DebugLoc(const DILocation *L);
/// \brief Construct from an \a MDNode. /// \brief Construct from an \a MDNode.
/// ///
/// Note: if \c N is not an \a MDLocation, a verifier check will fail, and /// Note: if \c N is not an \a DILocation, a verifier check will fail, and
/// accessors will crash. However, construction from other nodes is /// accessors will crash. However, construction from other nodes is
/// supported in order to handle forward references when reading textual /// supported in order to handle forward references when reading textual
/// IR. /// IR.
explicit DebugLoc(const MDNode *N); explicit DebugLoc(const MDNode *N);
/// \brief Get the underlying \a MDLocation. /// \brief Get the underlying \a DILocation.
/// ///
/// \pre !*this or \c isa<MDLocation>(getAsMDNode()). /// \pre !*this or \c isa<DILocation>(getAsMDNode()).
/// @{ /// @{
MDLocation *get() const; DILocation *get() const;
operator MDLocation *() const { return get(); } operator DILocation *() const { return get(); }
MDLocation *operator->() const { return get(); } DILocation *operator->() const { return get(); }
MDLocation &operator*() const { return *get(); } DILocation &operator*() const { return *get(); }
/// @} /// @}
/// \brief Check for null. /// \brief Check for null.
/// ///
/// Check for null in a way that is safe with broken debug info. Unlike /// Check for null in a way that is safe with broken debug info. Unlike
/// the conversion to \c MDLocation, this doesn't require that \c Loc is of /// the conversion to \c DILocation, this doesn't require that \c Loc is of
/// the right type. Important for cases like \a llvm::StripDebugInfo() and /// the right type. Important for cases like \a llvm::StripDebugInfo() and
/// \a Instruction::hasMetadata(). /// \a Instruction::hasMetadata().
explicit operator bool() const { return Loc; } explicit operator bool() const { return Loc; }
@ -82,18 +82,18 @@ namespace llvm {
/// \brief Create a new DebugLoc. /// \brief Create a new DebugLoc.
/// ///
/// Create a new DebugLoc at the specified line/col and scope/inline. This /// Create a new DebugLoc at the specified line/col and scope/inline. This
/// forwards to \a MDLocation::get(). /// forwards to \a DILocation::get().
/// ///
/// If \c !Scope, returns a default-constructed \a DebugLoc. /// If \c !Scope, returns a default-constructed \a DebugLoc.
/// ///
/// FIXME: Remove this. Users should use MDLocation::get(). /// FIXME: Remove this. Users should use DILocation::get().
static DebugLoc get(unsigned Line, unsigned Col, const MDNode *Scope, static DebugLoc get(unsigned Line, unsigned Col, const MDNode *Scope,
const MDNode *InlinedAt = nullptr); const MDNode *InlinedAt = nullptr);
unsigned getLine() const; unsigned getLine() const;
unsigned getCol() const; unsigned getCol() const;
MDNode *getScope() const; MDNode *getScope() const;
MDLocation *getInlinedAt() const; DILocation *getInlinedAt() const;
/// \brief Get the fully inlined-at scope for a DebugLoc. /// \brief Get the fully inlined-at scope for a DebugLoc.
/// ///
@ -105,8 +105,8 @@ namespace llvm {
/// Walk up the scope chain of given debug loc and find line number info /// Walk up the scope chain of given debug loc and find line number info
/// for the function. /// for the function.
/// ///
/// FIXME: Remove this. Users should use MDLocation/MDLocalScope API to /// FIXME: Remove this. Users should use DILocation/DILocalScope API to
/// find the subprogram, and then MDLocation::get(). /// find the subprogram, and then DILocation::get().
DebugLoc getFnDebugLoc() const; DebugLoc getFnDebugLoc() const;
/// \brief Return \c this as a bar \a MDNode. /// \brief Return \c this as a bar \a MDNode.

View File

@ -82,11 +82,11 @@ namespace llvm {
class DbgDeclareInst : public DbgInfoIntrinsic { class DbgDeclareInst : public DbgInfoIntrinsic {
public: public:
Value *getAddress() const; Value *getAddress() const;
MDLocalVariable *getVariable() const { DILocalVariable *getVariable() const {
return cast<MDLocalVariable>(getRawVariable()); return cast<DILocalVariable>(getRawVariable());
} }
MDExpression *getExpression() const { DIExpression *getExpression() const {
return cast<MDExpression>(getRawExpression()); return cast<DIExpression>(getRawExpression());
} }
Metadata *getRawVariable() const { Metadata *getRawVariable() const {
@ -115,11 +115,11 @@ namespace llvm {
return cast<ConstantInt>( return cast<ConstantInt>(
const_cast<Value*>(getArgOperand(1)))->getZExtValue(); const_cast<Value*>(getArgOperand(1)))->getZExtValue();
} }
MDLocalVariable *getVariable() const { DILocalVariable *getVariable() const {
return cast<MDLocalVariable>(getRawVariable()); return cast<DILocalVariable>(getRawVariable());
} }
MDExpression *getExpression() const { DIExpression *getExpression() const {
return cast<MDExpression>(getRawExpression()); return cast<DIExpression>(getRawExpression());
} }
Metadata *getRawVariable() const { Metadata *getRawVariable() const {

View File

@ -60,36 +60,36 @@ HANDLE_METADATA_LEAF(ConstantAsMetadata)
HANDLE_METADATA_LEAF(LocalAsMetadata) HANDLE_METADATA_LEAF(LocalAsMetadata)
HANDLE_MDNODE_BRANCH(MDNode) HANDLE_MDNODE_BRANCH(MDNode)
HANDLE_MDNODE_LEAF(MDTuple) HANDLE_MDNODE_LEAF(MDTuple)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDLocation) HANDLE_SPECIALIZED_MDNODE_LEAF(DILocation)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDExpression) HANDLE_SPECIALIZED_MDNODE_LEAF(DIExpression)
HANDLE_SPECIALIZED_MDNODE_BRANCH(DebugNode) HANDLE_SPECIALIZED_MDNODE_BRANCH(DINode)
HANDLE_SPECIALIZED_MDNODE_LEAF(GenericDebugNode) HANDLE_SPECIALIZED_MDNODE_LEAF(GenericDINode)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDSubrange) HANDLE_SPECIALIZED_MDNODE_LEAF(DISubrange)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDEnumerator) HANDLE_SPECIALIZED_MDNODE_LEAF(DIEnumerator)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDScope) HANDLE_SPECIALIZED_MDNODE_BRANCH(DIScope)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDType) HANDLE_SPECIALIZED_MDNODE_BRANCH(DIType)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDBasicType) HANDLE_SPECIALIZED_MDNODE_LEAF(DIBasicType)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDDerivedTypeBase) HANDLE_SPECIALIZED_MDNODE_BRANCH(DIDerivedTypeBase)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDDerivedType) HANDLE_SPECIALIZED_MDNODE_LEAF(DIDerivedType)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDCompositeTypeBase) HANDLE_SPECIALIZED_MDNODE_BRANCH(DICompositeTypeBase)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDCompositeType) HANDLE_SPECIALIZED_MDNODE_LEAF(DICompositeType)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDSubroutineType) HANDLE_SPECIALIZED_MDNODE_LEAF(DISubroutineType)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDFile) HANDLE_SPECIALIZED_MDNODE_LEAF(DIFile)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDCompileUnit) HANDLE_SPECIALIZED_MDNODE_LEAF(DICompileUnit)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDLocalScope) HANDLE_SPECIALIZED_MDNODE_BRANCH(DILocalScope)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDSubprogram) HANDLE_SPECIALIZED_MDNODE_LEAF(DISubprogram)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDLexicalBlockBase) HANDLE_SPECIALIZED_MDNODE_BRANCH(DILexicalBlockBase)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDLexicalBlock) HANDLE_SPECIALIZED_MDNODE_LEAF(DILexicalBlock)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDLexicalBlockFile) HANDLE_SPECIALIZED_MDNODE_LEAF(DILexicalBlockFile)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDNamespace) HANDLE_SPECIALIZED_MDNODE_LEAF(DINamespace)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDTemplateParameter) HANDLE_SPECIALIZED_MDNODE_BRANCH(DITemplateParameter)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDTemplateTypeParameter) HANDLE_SPECIALIZED_MDNODE_LEAF(DITemplateTypeParameter)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDTemplateValueParameter) HANDLE_SPECIALIZED_MDNODE_LEAF(DITemplateValueParameter)
HANDLE_SPECIALIZED_MDNODE_BRANCH(MDVariable) HANDLE_SPECIALIZED_MDNODE_BRANCH(DIVariable)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDGlobalVariable) HANDLE_SPECIALIZED_MDNODE_LEAF(DIGlobalVariable)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDLocalVariable) HANDLE_SPECIALIZED_MDNODE_LEAF(DILocalVariable)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDObjCProperty) HANDLE_SPECIALIZED_MDNODE_LEAF(DIObjCProperty)
HANDLE_SPECIALIZED_MDNODE_LEAF(MDImportedEntity) HANDLE_SPECIALIZED_MDNODE_LEAF(DIImportedEntity)
#undef HANDLE_METADATA #undef HANDLE_METADATA
#undef HANDLE_METADATA_LEAF #undef HANDLE_METADATA_LEAF

View File

@ -59,27 +59,27 @@ protected:
public: public:
enum MetadataKind { enum MetadataKind {
MDTupleKind, MDTupleKind,
MDLocationKind, DILocationKind,
GenericDebugNodeKind, GenericDINodeKind,
MDSubrangeKind, DISubrangeKind,
MDEnumeratorKind, DIEnumeratorKind,
MDBasicTypeKind, DIBasicTypeKind,
MDDerivedTypeKind, DIDerivedTypeKind,
MDCompositeTypeKind, DICompositeTypeKind,
MDSubroutineTypeKind, DISubroutineTypeKind,
MDFileKind, DIFileKind,
MDCompileUnitKind, DICompileUnitKind,
MDSubprogramKind, DISubprogramKind,
MDLexicalBlockKind, DILexicalBlockKind,
MDLexicalBlockFileKind, DILexicalBlockFileKind,
MDNamespaceKind, DINamespaceKind,
MDTemplateTypeParameterKind, DITemplateTypeParameterKind,
MDTemplateValueParameterKind, DITemplateValueParameterKind,
MDGlobalVariableKind, DIGlobalVariableKind,
MDLocalVariableKind, DILocalVariableKind,
MDExpressionKind, DIExpressionKind,
MDObjCPropertyKind, DIObjCPropertyKind,
MDImportedEntityKind, DIImportedEntityKind,
ConstantAsMetadataKind, ConstantAsMetadataKind,
LocalAsMetadataKind, LocalAsMetadataKind,
MDStringKind MDStringKind

View File

@ -72,7 +72,7 @@ void ModuleDebugInfoPrinter::print(raw_ostream &O, const Module *M) const {
// Printing the nodes directly isn't particularly helpful (since they // Printing the nodes directly isn't particularly helpful (since they
// reference other nodes that won't be printed, particularly for the // reference other nodes that won't be printed, particularly for the
// filenames), so just print a few useful things. // filenames), so just print a few useful things.
for (MDCompileUnit *CU : Finder.compile_units()) { for (DICompileUnit *CU : Finder.compile_units()) {
O << "Compile unit: "; O << "Compile unit: ";
if (const char *Lang = dwarf::LanguageString(CU->getSourceLanguage())) if (const char *Lang = dwarf::LanguageString(CU->getSourceLanguage()))
O << Lang; O << Lang;
@ -82,7 +82,7 @@ void ModuleDebugInfoPrinter::print(raw_ostream &O, const Module *M) const {
O << '\n'; O << '\n';
} }
for (MDSubprogram *S : Finder.subprograms()) { for (DISubprogram *S : Finder.subprograms()) {
O << "Subprogram: " << S->getName(); O << "Subprogram: " << S->getName();
printFile(O, S->getFilename(), S->getDirectory(), S->getLine()); printFile(O, S->getFilename(), S->getDirectory(), S->getLine());
if (!S->getLinkageName().empty()) if (!S->getLinkageName().empty())
@ -90,7 +90,7 @@ void ModuleDebugInfoPrinter::print(raw_ostream &O, const Module *M) const {
O << '\n'; O << '\n';
} }
for (const MDGlobalVariable *GV : Finder.global_variables()) { for (const DIGlobalVariable *GV : Finder.global_variables()) {
O << "Global variable: " << GV->getName(); O << "Global variable: " << GV->getName();
printFile(O, GV->getFilename(), GV->getDirectory(), GV->getLine()); printFile(O, GV->getFilename(), GV->getDirectory(), GV->getLine());
if (!GV->getLinkageName().empty()) if (!GV->getLinkageName().empty())
@ -98,12 +98,12 @@ void ModuleDebugInfoPrinter::print(raw_ostream &O, const Module *M) const {
O << '\n'; O << '\n';
} }
for (const MDType *T : Finder.types()) { for (const DIType *T : Finder.types()) {
O << "Type:"; O << "Type:";
if (!T->getName().empty()) if (!T->getName().empty())
O << ' ' << T->getName(); O << ' ' << T->getName();
printFile(O, T->getFilename(), T->getDirectory(), T->getLine()); printFile(O, T->getFilename(), T->getDirectory(), T->getLine());
if (auto *BT = dyn_cast<MDBasicType>(T)) { if (auto *BT = dyn_cast<DIBasicType>(T)) {
O << " "; O << " ";
if (const char *Encoding = if (const char *Encoding =
dwarf::AttributeEncodingString(BT->getEncoding())) dwarf::AttributeEncodingString(BT->getEncoding()))
@ -117,7 +117,7 @@ void ModuleDebugInfoPrinter::print(raw_ostream &O, const Module *M) const {
else else
O << "unknown-tag(" << T->getTag() << ")"; O << "unknown-tag(" << T->getTag() << ")";
} }
if (auto *CT = dyn_cast<MDCompositeType>(T)) { if (auto *CT = dyn_cast<DICompositeType>(T)) {
if (auto *S = CT->getRawIdentifier()) if (auto *S = CT->getRawIdentifier())
O << " (identifier: '" << S->getString() << "')"; O << " (identifier: '" << S->getString() << "')";
} }

View File

@ -2994,7 +2994,7 @@ bool LLParser::ParseMDTuple(MDNode *&MD, bool IsDistinct) {
/// MDNode: /// MDNode:
/// ::= !{ ... } /// ::= !{ ... }
/// ::= !7 /// ::= !7
/// ::= !MDLocation(...) /// ::= !DILocation(...)
bool LLParser::ParseMDNode(MDNode *&N) { bool LLParser::ParseMDNode(MDNode *&N) {
if (Lex.getKind() == lltok::MetadataVar) if (Lex.getKind() == lltok::MetadataVar)
return ParseSpecializedMDNode(N); return ParseSpecializedMDNode(N);
@ -3209,7 +3209,7 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DIFlagField &Result) {
if (Lex.getKind() != lltok::DIFlag) if (Lex.getKind() != lltok::DIFlag)
return TokError("expected debug info flag"); return TokError("expected debug info flag");
Val = DebugNode::getFlag(Lex.getStrVal()); Val = DINode::getFlag(Lex.getStrVal());
if (!Val) if (!Val)
return TokError(Twine("invalid debug info flag flag '") + return TokError(Twine("invalid debug info flag flag '") +
Lex.getStrVal() + "'"); Lex.getStrVal() + "'");
@ -3391,9 +3391,9 @@ bool LLParser::ParseSpecializedMDNode(MDNode *&N, bool IsDistinct) {
#define GET_OR_DISTINCT(CLASS, ARGS) \ #define GET_OR_DISTINCT(CLASS, ARGS) \
(IsDistinct ? CLASS::getDistinct ARGS : CLASS::get ARGS) (IsDistinct ? CLASS::getDistinct ARGS : CLASS::get ARGS)
/// ParseMDLocationFields: /// ParseDILocationFields:
/// ::= !MDLocation(line: 43, column: 8, scope: !5, inlinedAt: !6) /// ::= !DILocation(line: 43, column: 8, scope: !5, inlinedAt: !6)
bool LLParser::ParseMDLocation(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDILocation(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
OPTIONAL(line, LineField, ); \ OPTIONAL(line, LineField, ); \
OPTIONAL(column, ColumnField, ); \ OPTIONAL(column, ColumnField, ); \
@ -3403,13 +3403,13 @@ bool LLParser::ParseMDLocation(MDNode *&Result, bool IsDistinct) {
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT( Result = GET_OR_DISTINCT(
MDLocation, (Context, line.Val, column.Val, scope.Val, inlinedAt.Val)); DILocation, (Context, line.Val, column.Val, scope.Val, inlinedAt.Val));
return false; return false;
} }
/// ParseGenericDebugNode: /// ParseGenericDINode:
/// ::= !GenericDebugNode(tag: 15, header: "...", operands: {...}) /// ::= !GenericDINode(tag: 15, header: "...", operands: {...})
bool LLParser::ParseGenericDebugNode(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseGenericDINode(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(tag, DwarfTagField, ); \ REQUIRED(tag, DwarfTagField, ); \
OPTIONAL(header, MDStringField, ); \ OPTIONAL(header, MDStringField, ); \
@ -3417,40 +3417,40 @@ bool LLParser::ParseGenericDebugNode(MDNode *&Result, bool IsDistinct) {
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(GenericDebugNode, Result = GET_OR_DISTINCT(GenericDINode,
(Context, tag.Val, header.Val, operands.Val)); (Context, tag.Val, header.Val, operands.Val));
return false; return false;
} }
/// ParseMDSubrange: /// ParseDISubrange:
/// ::= !MDSubrange(count: 30, lowerBound: 2) /// ::= !DISubrange(count: 30, lowerBound: 2)
bool LLParser::ParseMDSubrange(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDISubrange(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(count, MDSignedField, (-1, -1, INT64_MAX)); \ REQUIRED(count, MDSignedField, (-1, -1, INT64_MAX)); \
OPTIONAL(lowerBound, MDSignedField, ); OPTIONAL(lowerBound, MDSignedField, );
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDSubrange, (Context, count.Val, lowerBound.Val)); Result = GET_OR_DISTINCT(DISubrange, (Context, count.Val, lowerBound.Val));
return false; return false;
} }
/// ParseMDEnumerator: /// ParseDIEnumerator:
/// ::= !MDEnumerator(value: 30, name: "SomeKind") /// ::= !DIEnumerator(value: 30, name: "SomeKind")
bool LLParser::ParseMDEnumerator(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDIEnumerator(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(name, MDStringField, ); \ REQUIRED(name, MDStringField, ); \
REQUIRED(value, MDSignedField, ); REQUIRED(value, MDSignedField, );
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDEnumerator, (Context, value.Val, name.Val)); Result = GET_OR_DISTINCT(DIEnumerator, (Context, value.Val, name.Val));
return false; return false;
} }
/// ParseMDBasicType: /// ParseDIBasicType:
/// ::= !MDBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32) /// ::= !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32)
bool LLParser::ParseMDBasicType(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDIBasicType(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
OPTIONAL(tag, DwarfTagField, (dwarf::DW_TAG_base_type)); \ OPTIONAL(tag, DwarfTagField, (dwarf::DW_TAG_base_type)); \
OPTIONAL(name, MDStringField, ); \ OPTIONAL(name, MDStringField, ); \
@ -3460,16 +3460,16 @@ bool LLParser::ParseMDBasicType(MDNode *&Result, bool IsDistinct) {
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDBasicType, (Context, tag.Val, name.Val, size.Val, Result = GET_OR_DISTINCT(DIBasicType, (Context, tag.Val, name.Val, size.Val,
align.Val, encoding.Val)); align.Val, encoding.Val));
return false; return false;
} }
/// ParseMDDerivedType: /// ParseDIDerivedType:
/// ::= !MDDerivedType(tag: DW_TAG_pointer_type, name: "int", file: !0, /// ::= !DIDerivedType(tag: DW_TAG_pointer_type, name: "int", file: !0,
/// line: 7, scope: !1, baseType: !2, size: 32, /// line: 7, scope: !1, baseType: !2, size: 32,
/// align: 32, offset: 0, flags: 0, extraData: !3) /// align: 32, offset: 0, flags: 0, extraData: !3)
bool LLParser::ParseMDDerivedType(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDIDerivedType(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(tag, DwarfTagField, ); \ REQUIRED(tag, DwarfTagField, ); \
OPTIONAL(name, MDStringField, ); \ OPTIONAL(name, MDStringField, ); \
@ -3485,14 +3485,14 @@ bool LLParser::ParseMDDerivedType(MDNode *&Result, bool IsDistinct) {
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDDerivedType, Result = GET_OR_DISTINCT(DIDerivedType,
(Context, tag.Val, name.Val, file.Val, line.Val, (Context, tag.Val, name.Val, file.Val, line.Val,
scope.Val, baseType.Val, size.Val, align.Val, scope.Val, baseType.Val, size.Val, align.Val,
offset.Val, flags.Val, extraData.Val)); offset.Val, flags.Val, extraData.Val));
return false; return false;
} }
bool LLParser::ParseMDCompositeType(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDICompositeType(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(tag, DwarfTagField, ); \ REQUIRED(tag, DwarfTagField, ); \
OPTIONAL(name, MDStringField, ); \ OPTIONAL(name, MDStringField, ); \
@ -3513,44 +3513,44 @@ bool LLParser::ParseMDCompositeType(MDNode *&Result, bool IsDistinct) {
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT( Result = GET_OR_DISTINCT(
MDCompositeType, DICompositeType,
(Context, tag.Val, name.Val, file.Val, line.Val, scope.Val, baseType.Val, (Context, tag.Val, name.Val, file.Val, line.Val, scope.Val, baseType.Val,
size.Val, align.Val, offset.Val, flags.Val, elements.Val, size.Val, align.Val, offset.Val, flags.Val, elements.Val,
runtimeLang.Val, vtableHolder.Val, templateParams.Val, identifier.Val)); runtimeLang.Val, vtableHolder.Val, templateParams.Val, identifier.Val));
return false; return false;
} }
bool LLParser::ParseMDSubroutineType(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDISubroutineType(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
OPTIONAL(flags, DIFlagField, ); \ OPTIONAL(flags, DIFlagField, ); \
REQUIRED(types, MDField, ); REQUIRED(types, MDField, );
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDSubroutineType, (Context, flags.Val, types.Val)); Result = GET_OR_DISTINCT(DISubroutineType, (Context, flags.Val, types.Val));
return false; return false;
} }
/// ParseMDFileType: /// ParseDIFileType:
/// ::= !MDFileType(filename: "path/to/file", directory: "/path/to/dir") /// ::= !DIFileType(filename: "path/to/file", directory: "/path/to/dir")
bool LLParser::ParseMDFile(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDIFile(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(filename, MDStringField, ); \ REQUIRED(filename, MDStringField, ); \
REQUIRED(directory, MDStringField, ); REQUIRED(directory, MDStringField, );
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDFile, (Context, filename.Val, directory.Val)); Result = GET_OR_DISTINCT(DIFile, (Context, filename.Val, directory.Val));
return false; return false;
} }
/// ParseMDCompileUnit: /// ParseDICompileUnit:
/// ::= !MDCompileUnit(language: DW_LANG_C99, file: !0, producer: "clang", /// ::= !DICompileUnit(language: DW_LANG_C99, file: !0, producer: "clang",
/// isOptimized: true, flags: "-O2", runtimeVersion: 1, /// isOptimized: true, flags: "-O2", runtimeVersion: 1,
/// splitDebugFilename: "abc.debug", emissionKind: 1, /// splitDebugFilename: "abc.debug", emissionKind: 1,
/// enums: !1, retainedTypes: !2, subprograms: !3, /// enums: !1, retainedTypes: !2, subprograms: !3,
/// globals: !4, imports: !5) /// globals: !4, imports: !5)
bool LLParser::ParseMDCompileUnit(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDICompileUnit(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(language, DwarfLangField, ); \ REQUIRED(language, DwarfLangField, ); \
REQUIRED(file, MDField, (/* AllowNull */ false)); \ REQUIRED(file, MDField, (/* AllowNull */ false)); \
@ -3568,7 +3568,7 @@ bool LLParser::ParseMDCompileUnit(MDNode *&Result, bool IsDistinct) {
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDCompileUnit, Result = GET_OR_DISTINCT(DICompileUnit,
(Context, language.Val, file.Val, producer.Val, (Context, language.Val, file.Val, producer.Val,
isOptimized.Val, flags.Val, runtimeVersion.Val, isOptimized.Val, flags.Val, runtimeVersion.Val,
splitDebugFilename.Val, emissionKind.Val, enums.Val, splitDebugFilename.Val, emissionKind.Val, enums.Val,
@ -3577,15 +3577,15 @@ bool LLParser::ParseMDCompileUnit(MDNode *&Result, bool IsDistinct) {
return false; return false;
} }
/// ParseMDSubprogram: /// ParseDISubprogram:
/// ::= !MDSubprogram(scope: !0, name: "foo", linkageName: "_Zfoo", /// ::= !DISubprogram(scope: !0, name: "foo", linkageName: "_Zfoo",
/// file: !1, line: 7, type: !2, isLocal: false, /// file: !1, line: 7, type: !2, isLocal: false,
/// isDefinition: true, scopeLine: 8, containingType: !3, /// isDefinition: true, scopeLine: 8, containingType: !3,
/// virtuality: DW_VIRTUALTIY_pure_virtual, /// virtuality: DW_VIRTUALTIY_pure_virtual,
/// virtualIndex: 10, flags: 11, /// virtualIndex: 10, flags: 11,
/// isOptimized: false, function: void ()* @_Z3foov, /// isOptimized: false, function: void ()* @_Z3foov,
/// templateParams: !4, declaration: !5, variables: !6) /// templateParams: !4, declaration: !5, variables: !6)
bool LLParser::ParseMDSubprogram(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDISubprogram(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
OPTIONAL(scope, MDField, ); \ OPTIONAL(scope, MDField, ); \
OPTIONAL(name, MDStringField, ); \ OPTIONAL(name, MDStringField, ); \
@ -3609,7 +3609,7 @@ bool LLParser::ParseMDSubprogram(MDNode *&Result, bool IsDistinct) {
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT( Result = GET_OR_DISTINCT(
MDSubprogram, (Context, scope.Val, name.Val, linkageName.Val, file.Val, DISubprogram, (Context, scope.Val, name.Val, linkageName.Val, file.Val,
line.Val, type.Val, isLocal.Val, isDefinition.Val, line.Val, type.Val, isLocal.Val, isDefinition.Val,
scopeLine.Val, containingType.Val, virtuality.Val, scopeLine.Val, containingType.Val, virtuality.Val,
virtualIndex.Val, flags.Val, isOptimized.Val, function.Val, virtualIndex.Val, flags.Val, isOptimized.Val, function.Val,
@ -3617,9 +3617,9 @@ bool LLParser::ParseMDSubprogram(MDNode *&Result, bool IsDistinct) {
return false; return false;
} }
/// ParseMDLexicalBlock: /// ParseDILexicalBlock:
/// ::= !MDLexicalBlock(scope: !0, file: !2, line: 7, column: 9) /// ::= !DILexicalBlock(scope: !0, file: !2, line: 7, column: 9)
bool LLParser::ParseMDLexicalBlock(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDILexicalBlock(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(scope, MDField, (/* AllowNull */ false)); \ REQUIRED(scope, MDField, (/* AllowNull */ false)); \
OPTIONAL(file, MDField, ); \ OPTIONAL(file, MDField, ); \
@ -3629,13 +3629,13 @@ bool LLParser::ParseMDLexicalBlock(MDNode *&Result, bool IsDistinct) {
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT( Result = GET_OR_DISTINCT(
MDLexicalBlock, (Context, scope.Val, file.Val, line.Val, column.Val)); DILexicalBlock, (Context, scope.Val, file.Val, line.Val, column.Val));
return false; return false;
} }
/// ParseMDLexicalBlockFile: /// ParseDILexicalBlockFile:
/// ::= !MDLexicalBlockFile(scope: !0, file: !2, discriminator: 9) /// ::= !DILexicalBlockFile(scope: !0, file: !2, discriminator: 9)
bool LLParser::ParseMDLexicalBlockFile(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDILexicalBlockFile(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(scope, MDField, (/* AllowNull */ false)); \ REQUIRED(scope, MDField, (/* AllowNull */ false)); \
OPTIONAL(file, MDField, ); \ OPTIONAL(file, MDField, ); \
@ -3643,14 +3643,14 @@ bool LLParser::ParseMDLexicalBlockFile(MDNode *&Result, bool IsDistinct) {
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDLexicalBlockFile, Result = GET_OR_DISTINCT(DILexicalBlockFile,
(Context, scope.Val, file.Val, discriminator.Val)); (Context, scope.Val, file.Val, discriminator.Val));
return false; return false;
} }
/// ParseMDNamespace: /// ParseDINamespace:
/// ::= !MDNamespace(scope: !0, file: !2, name: "SomeNamespace", line: 9) /// ::= !DINamespace(scope: !0, file: !2, name: "SomeNamespace", line: 9)
bool LLParser::ParseMDNamespace(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDINamespace(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(scope, MDField, ); \ REQUIRED(scope, MDField, ); \
OPTIONAL(file, MDField, ); \ OPTIONAL(file, MDField, ); \
@ -3659,14 +3659,14 @@ bool LLParser::ParseMDNamespace(MDNode *&Result, bool IsDistinct) {
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDNamespace, Result = GET_OR_DISTINCT(DINamespace,
(Context, scope.Val, file.Val, name.Val, line.Val)); (Context, scope.Val, file.Val, name.Val, line.Val));
return false; return false;
} }
/// ParseMDTemplateTypeParameter: /// ParseDITemplateTypeParameter:
/// ::= !MDTemplateTypeParameter(name: "Ty", type: !1) /// ::= !DITemplateTypeParameter(name: "Ty", type: !1)
bool LLParser::ParseMDTemplateTypeParameter(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDITemplateTypeParameter(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
OPTIONAL(name, MDStringField, ); \ OPTIONAL(name, MDStringField, ); \
REQUIRED(type, MDField, ); REQUIRED(type, MDField, );
@ -3674,14 +3674,14 @@ bool LLParser::ParseMDTemplateTypeParameter(MDNode *&Result, bool IsDistinct) {
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = Result =
GET_OR_DISTINCT(MDTemplateTypeParameter, (Context, name.Val, type.Val)); GET_OR_DISTINCT(DITemplateTypeParameter, (Context, name.Val, type.Val));
return false; return false;
} }
/// ParseMDTemplateValueParameter: /// ParseDITemplateValueParameter:
/// ::= !MDTemplateValueParameter(tag: DW_TAG_template_value_parameter, /// ::= !DITemplateValueParameter(tag: DW_TAG_template_value_parameter,
/// name: "V", type: !1, value: i32 7) /// name: "V", type: !1, value: i32 7)
bool LLParser::ParseMDTemplateValueParameter(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDITemplateValueParameter(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
OPTIONAL(tag, DwarfTagField, (dwarf::DW_TAG_template_value_parameter)); \ OPTIONAL(tag, DwarfTagField, (dwarf::DW_TAG_template_value_parameter)); \
OPTIONAL(name, MDStringField, ); \ OPTIONAL(name, MDStringField, ); \
@ -3690,17 +3690,17 @@ bool LLParser::ParseMDTemplateValueParameter(MDNode *&Result, bool IsDistinct) {
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDTemplateValueParameter, Result = GET_OR_DISTINCT(DITemplateValueParameter,
(Context, tag.Val, name.Val, type.Val, value.Val)); (Context, tag.Val, name.Val, type.Val, value.Val));
return false; return false;
} }
/// ParseMDGlobalVariable: /// ParseDIGlobalVariable:
/// ::= !MDGlobalVariable(scope: !0, name: "foo", linkageName: "foo", /// ::= !DIGlobalVariable(scope: !0, name: "foo", linkageName: "foo",
/// file: !1, line: 7, type: !2, isLocal: false, /// file: !1, line: 7, type: !2, isLocal: false,
/// isDefinition: true, variable: i32* @foo, /// isDefinition: true, variable: i32* @foo,
/// declaration: !3) /// declaration: !3)
bool LLParser::ParseMDGlobalVariable(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDIGlobalVariable(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(name, MDStringField, (/* AllowEmpty */ false)); \ REQUIRED(name, MDStringField, (/* AllowEmpty */ false)); \
OPTIONAL(scope, MDField, ); \ OPTIONAL(scope, MDField, ); \
@ -3715,17 +3715,17 @@ bool LLParser::ParseMDGlobalVariable(MDNode *&Result, bool IsDistinct) {
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDGlobalVariable, Result = GET_OR_DISTINCT(DIGlobalVariable,
(Context, scope.Val, name.Val, linkageName.Val, (Context, scope.Val, name.Val, linkageName.Val,
file.Val, line.Val, type.Val, isLocal.Val, file.Val, line.Val, type.Val, isLocal.Val,
isDefinition.Val, variable.Val, declaration.Val)); isDefinition.Val, variable.Val, declaration.Val));
return false; return false;
} }
/// ParseMDLocalVariable: /// ParseDILocalVariable:
/// ::= !MDLocalVariable(tag: DW_TAG_arg_variable, scope: !0, name: "foo", /// ::= !DILocalVariable(tag: DW_TAG_arg_variable, scope: !0, name: "foo",
/// file: !1, line: 7, type: !2, arg: 2, flags: 7) /// file: !1, line: 7, type: !2, arg: 2, flags: 7)
bool LLParser::ParseMDLocalVariable(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDILocalVariable(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(tag, DwarfTagField, ); \ REQUIRED(tag, DwarfTagField, ); \
REQUIRED(scope, MDField, (/* AllowNull */ false)); \ REQUIRED(scope, MDField, (/* AllowNull */ false)); \
@ -3738,15 +3738,15 @@ bool LLParser::ParseMDLocalVariable(MDNode *&Result, bool IsDistinct) {
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDLocalVariable, Result = GET_OR_DISTINCT(DILocalVariable,
(Context, tag.Val, scope.Val, name.Val, file.Val, (Context, tag.Val, scope.Val, name.Val, file.Val,
line.Val, type.Val, arg.Val, flags.Val)); line.Val, type.Val, arg.Val, flags.Val));
return false; return false;
} }
/// ParseMDExpression: /// ParseDIExpression:
/// ::= !MDExpression(0, 7, -1) /// ::= !DIExpression(0, 7, -1)
bool LLParser::ParseMDExpression(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDIExpression(MDNode *&Result, bool IsDistinct) {
assert(Lex.getKind() == lltok::MetadataVar && "Expected metadata type name"); assert(Lex.getKind() == lltok::MetadataVar && "Expected metadata type name");
Lex.Lex(); Lex.Lex();
@ -3778,14 +3778,14 @@ bool LLParser::ParseMDExpression(MDNode *&Result, bool IsDistinct) {
if (ParseToken(lltok::rparen, "expected ')' here")) if (ParseToken(lltok::rparen, "expected ')' here"))
return true; return true;
Result = GET_OR_DISTINCT(MDExpression, (Context, Elements)); Result = GET_OR_DISTINCT(DIExpression, (Context, Elements));
return false; return false;
} }
/// ParseMDObjCProperty: /// ParseDIObjCProperty:
/// ::= !MDObjCProperty(name: "foo", file: !1, line: 7, setter: "setFoo", /// ::= !DIObjCProperty(name: "foo", file: !1, line: 7, setter: "setFoo",
/// getter: "getFoo", attributes: 7, type: !2) /// getter: "getFoo", attributes: 7, type: !2)
bool LLParser::ParseMDObjCProperty(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDIObjCProperty(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
OPTIONAL(name, MDStringField, ); \ OPTIONAL(name, MDStringField, ); \
OPTIONAL(file, MDField, ); \ OPTIONAL(file, MDField, ); \
@ -3797,16 +3797,16 @@ bool LLParser::ParseMDObjCProperty(MDNode *&Result, bool IsDistinct) {
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDObjCProperty, Result = GET_OR_DISTINCT(DIObjCProperty,
(Context, name.Val, file.Val, line.Val, setter.Val, (Context, name.Val, file.Val, line.Val, setter.Val,
getter.Val, attributes.Val, type.Val)); getter.Val, attributes.Val, type.Val));
return false; return false;
} }
/// ParseMDImportedEntity: /// ParseDIImportedEntity:
/// ::= !MDImportedEntity(tag: DW_TAG_imported_module, scope: !0, entity: !1, /// ::= !DIImportedEntity(tag: DW_TAG_imported_module, scope: !0, entity: !1,
/// line: 7, name: "foo") /// line: 7, name: "foo")
bool LLParser::ParseMDImportedEntity(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDIImportedEntity(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(tag, DwarfTagField, ); \ REQUIRED(tag, DwarfTagField, ); \
REQUIRED(scope, MDField, ); \ REQUIRED(scope, MDField, ); \
@ -3816,7 +3816,7 @@ bool LLParser::ParseMDImportedEntity(MDNode *&Result, bool IsDistinct) {
PARSE_MD_FIELDS(); PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS #undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(MDImportedEntity, (Context, tag.Val, scope.Val, Result = GET_OR_DISTINCT(DIImportedEntity, (Context, tag.Val, scope.Val,
entity.Val, line.Val, name.Val)); entity.Val, line.Val, name.Val));
return false; return false;
} }
@ -3871,7 +3871,7 @@ bool LLParser::ParseValueAsMetadata(Metadata *&MD, const Twine &TypeMsg,
/// ::= !42 /// ::= !42
/// ::= !{...} /// ::= !{...}
/// ::= !"string" /// ::= !"string"
/// ::= !MDLocation(...) /// ::= !DILocation(...)
bool LLParser::ParseMetadata(Metadata *&MD, PerFunctionState *PFS) { bool LLParser::ParseMetadata(Metadata *&MD, PerFunctionState *PFS) {
if (Lex.getKind() == lltok::MetadataVar) { if (Lex.getKind() == lltok::MetadataVar) {
MDNode *N; MDNode *N;

View File

@ -1724,7 +1724,7 @@ std::error_code BitcodeReader::ParseMetadata() {
Metadata *InlinedAt = Metadata *InlinedAt =
Record[4] ? MDValueList.getValueFwdRef(Record[4] - 1) : nullptr; Record[4] ? MDValueList.getValueFwdRef(Record[4] - 1) : nullptr;
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDLocation, Record[0], GET_OR_DISTINCT(DILocation, Record[0],
(Context, Line, Column, Scope, InlinedAt)), (Context, Line, Column, Scope, InlinedAt)),
NextMDValueNo++); NextMDValueNo++);
break; break;
@ -1744,7 +1744,7 @@ std::error_code BitcodeReader::ParseMetadata() {
for (unsigned I = 4, E = Record.size(); I != E; ++I) for (unsigned I = 4, E = Record.size(); I != E; ++I)
DwarfOps.push_back(Record[I] ? MDValueList.getValueFwdRef(Record[I] - 1) DwarfOps.push_back(Record[I] ? MDValueList.getValueFwdRef(Record[I] - 1)
: nullptr); : nullptr);
MDValueList.AssignValue(GET_OR_DISTINCT(GenericDebugNode, Record[0], MDValueList.AssignValue(GET_OR_DISTINCT(GenericDINode, Record[0],
(Context, Tag, Header, DwarfOps)), (Context, Tag, Header, DwarfOps)),
NextMDValueNo++); NextMDValueNo++);
break; break;
@ -1754,7 +1754,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDSubrange, Record[0], GET_OR_DISTINCT(DISubrange, Record[0],
(Context, Record[1], unrotateSign(Record[2]))), (Context, Record[1], unrotateSign(Record[2]))),
NextMDValueNo++); NextMDValueNo++);
break; break;
@ -1763,7 +1763,7 @@ std::error_code BitcodeReader::ParseMetadata() {
if (Record.size() != 3) if (Record.size() != 3)
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue(GET_OR_DISTINCT(MDEnumerator, Record[0], MDValueList.AssignValue(GET_OR_DISTINCT(DIEnumerator, Record[0],
(Context, unrotateSign(Record[1]), (Context, unrotateSign(Record[1]),
getMDString(Record[2]))), getMDString(Record[2]))),
NextMDValueNo++); NextMDValueNo++);
@ -1774,7 +1774,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDBasicType, Record[0], GET_OR_DISTINCT(DIBasicType, Record[0],
(Context, Record[1], getMDString(Record[2]), (Context, Record[1], getMDString(Record[2]),
Record[3], Record[4], Record[5])), Record[3], Record[4], Record[5])),
NextMDValueNo++); NextMDValueNo++);
@ -1785,7 +1785,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDDerivedType, Record[0], GET_OR_DISTINCT(DIDerivedType, Record[0],
(Context, Record[1], getMDString(Record[2]), (Context, Record[1], getMDString(Record[2]),
getMDOrNull(Record[3]), Record[4], getMDOrNull(Record[3]), Record[4],
getMDOrNull(Record[5]), getMDOrNull(Record[6]), getMDOrNull(Record[5]), getMDOrNull(Record[6]),
@ -1799,7 +1799,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDCompositeType, Record[0], GET_OR_DISTINCT(DICompositeType, Record[0],
(Context, Record[1], getMDString(Record[2]), (Context, Record[1], getMDString(Record[2]),
getMDOrNull(Record[3]), Record[4], getMDOrNull(Record[3]), Record[4],
getMDOrNull(Record[5]), getMDOrNull(Record[6]), getMDOrNull(Record[5]), getMDOrNull(Record[6]),
@ -1815,7 +1815,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDSubroutineType, Record[0], GET_OR_DISTINCT(DISubroutineType, Record[0],
(Context, Record[1], getMDOrNull(Record[2]))), (Context, Record[1], getMDOrNull(Record[2]))),
NextMDValueNo++); NextMDValueNo++);
break; break;
@ -1825,7 +1825,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDFile, Record[0], (Context, getMDString(Record[1]), GET_OR_DISTINCT(DIFile, Record[0], (Context, getMDString(Record[1]),
getMDString(Record[2]))), getMDString(Record[2]))),
NextMDValueNo++); NextMDValueNo++);
break; break;
@ -1835,7 +1835,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDCompileUnit, Record[0], GET_OR_DISTINCT(DICompileUnit, Record[0],
(Context, Record[1], getMDOrNull(Record[2]), (Context, Record[1], getMDOrNull(Record[2]),
getMDString(Record[3]), Record[4], getMDString(Record[3]), Record[4],
getMDString(Record[5]), Record[6], getMDString(Record[5]), Record[6],
@ -1852,7 +1852,7 @@ std::error_code BitcodeReader::ParseMetadata() {
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT( GET_OR_DISTINCT(
MDSubprogram, Record[0], DISubprogram, Record[0],
(Context, getMDOrNull(Record[1]), getMDString(Record[2]), (Context, getMDOrNull(Record[1]), getMDString(Record[2]),
getMDString(Record[3]), getMDOrNull(Record[4]), Record[5], getMDString(Record[3]), getMDOrNull(Record[4]), Record[5],
getMDOrNull(Record[6]), Record[7], Record[8], Record[9], getMDOrNull(Record[6]), Record[7], Record[8], Record[9],
@ -1867,7 +1867,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDLexicalBlock, Record[0], GET_OR_DISTINCT(DILexicalBlock, Record[0],
(Context, getMDOrNull(Record[1]), (Context, getMDOrNull(Record[1]),
getMDOrNull(Record[2]), Record[3], Record[4])), getMDOrNull(Record[2]), Record[3], Record[4])),
NextMDValueNo++); NextMDValueNo++);
@ -1878,7 +1878,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDLexicalBlockFile, Record[0], GET_OR_DISTINCT(DILexicalBlockFile, Record[0],
(Context, getMDOrNull(Record[1]), (Context, getMDOrNull(Record[1]),
getMDOrNull(Record[2]), Record[3])), getMDOrNull(Record[2]), Record[3])),
NextMDValueNo++); NextMDValueNo++);
@ -1889,7 +1889,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDNamespace, Record[0], GET_OR_DISTINCT(DINamespace, Record[0],
(Context, getMDOrNull(Record[1]), (Context, getMDOrNull(Record[1]),
getMDOrNull(Record[2]), getMDString(Record[3]), getMDOrNull(Record[2]), getMDString(Record[3]),
Record[4])), Record[4])),
@ -1900,7 +1900,7 @@ std::error_code BitcodeReader::ParseMetadata() {
if (Record.size() != 3) if (Record.size() != 3)
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue(GET_OR_DISTINCT(MDTemplateTypeParameter, MDValueList.AssignValue(GET_OR_DISTINCT(DITemplateTypeParameter,
Record[0], Record[0],
(Context, getMDString(Record[1]), (Context, getMDString(Record[1]),
getMDOrNull(Record[2]))), getMDOrNull(Record[2]))),
@ -1912,7 +1912,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDTemplateValueParameter, Record[0], GET_OR_DISTINCT(DITemplateValueParameter, Record[0],
(Context, Record[1], getMDString(Record[2]), (Context, Record[1], getMDString(Record[2]),
getMDOrNull(Record[3]), getMDOrNull(Record[4]))), getMDOrNull(Record[3]), getMDOrNull(Record[4]))),
NextMDValueNo++); NextMDValueNo++);
@ -1923,7 +1923,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDGlobalVariable, Record[0], GET_OR_DISTINCT(DIGlobalVariable, Record[0],
(Context, getMDOrNull(Record[1]), (Context, getMDOrNull(Record[1]),
getMDString(Record[2]), getMDString(Record[3]), getMDString(Record[2]), getMDString(Record[3]),
getMDOrNull(Record[4]), Record[5], getMDOrNull(Record[4]), Record[5],
@ -1938,7 +1938,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDLocalVariable, Record[0], GET_OR_DISTINCT(DILocalVariable, Record[0],
(Context, Record[1], getMDOrNull(Record[2]), (Context, Record[1], getMDOrNull(Record[2]),
getMDString(Record[3]), getMDOrNull(Record[4]), getMDString(Record[3]), getMDOrNull(Record[4]),
Record[5], getMDOrNull(Record[6]), Record[7], Record[5], getMDOrNull(Record[6]), Record[7],
@ -1951,7 +1951,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDExpression, Record[0], GET_OR_DISTINCT(DIExpression, Record[0],
(Context, makeArrayRef(Record).slice(1))), (Context, makeArrayRef(Record).slice(1))),
NextMDValueNo++); NextMDValueNo++);
break; break;
@ -1961,7 +1961,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDObjCProperty, Record[0], GET_OR_DISTINCT(DIObjCProperty, Record[0],
(Context, getMDString(Record[1]), (Context, getMDString(Record[1]),
getMDOrNull(Record[2]), Record[3], getMDOrNull(Record[2]), Record[3],
getMDString(Record[4]), getMDString(Record[5]), getMDString(Record[4]), getMDString(Record[5]),
@ -1974,7 +1974,7 @@ std::error_code BitcodeReader::ParseMetadata() {
return Error("Invalid record"); return Error("Invalid record");
MDValueList.AssignValue( MDValueList.AssignValue(
GET_OR_DISTINCT(MDImportedEntity, Record[0], GET_OR_DISTINCT(DIImportedEntity, Record[0],
(Context, Record[1], getMDOrNull(Record[2]), (Context, Record[1], getMDOrNull(Record[2]),
getMDOrNull(Record[3]), Record[4], getMDOrNull(Record[3]), Record[4],
getMDString(Record[5]))), getMDString(Record[5]))),

View File

@ -784,7 +784,7 @@ static void WriteMDTuple(const MDTuple *N, const ValueEnumerator &VE,
Record.clear(); Record.clear();
} }
static void WriteMDLocation(const MDLocation *N, const ValueEnumerator &VE, static void WriteDILocation(const DILocation *N, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) { unsigned Abbrev) {
@ -798,11 +798,11 @@ static void WriteMDLocation(const MDLocation *N, const ValueEnumerator &VE,
Record.clear(); Record.clear();
} }
static void WriteGenericDebugNode(const GenericDebugNode *N, static void WriteGenericDINode(const GenericDINode *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) { unsigned Abbrev) {
Record.push_back(N->isDistinct()); Record.push_back(N->isDistinct());
Record.push_back(N->getTag()); Record.push_back(N->getTag());
Record.push_back(0); // Per-tag version field; unused for now. Record.push_back(0); // Per-tag version field; unused for now.
@ -819,7 +819,7 @@ static uint64_t rotateSign(int64_t I) {
return I < 0 ? ~(U << 1) : U << 1; return I < 0 ? ~(U << 1) : U << 1;
} }
static void WriteMDSubrange(const MDSubrange *N, const ValueEnumerator &, static void WriteDISubrange(const DISubrange *N, const ValueEnumerator &,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) { unsigned Abbrev) {
@ -831,7 +831,7 @@ static void WriteMDSubrange(const MDSubrange *N, const ValueEnumerator &,
Record.clear(); Record.clear();
} }
static void WriteMDEnumerator(const MDEnumerator *N, const ValueEnumerator &VE, static void WriteDIEnumerator(const DIEnumerator *N, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) { unsigned Abbrev) {
@ -843,7 +843,7 @@ static void WriteMDEnumerator(const MDEnumerator *N, const ValueEnumerator &VE,
Record.clear(); Record.clear();
} }
static void WriteMDBasicType(const MDBasicType *N, const ValueEnumerator &VE, static void WriteDIBasicType(const DIBasicType *N, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) { unsigned Abbrev) {
@ -858,7 +858,7 @@ static void WriteMDBasicType(const MDBasicType *N, const ValueEnumerator &VE,
Record.clear(); Record.clear();
} }
static void WriteMDDerivedType(const MDDerivedType *N, static void WriteDIDerivedType(const DIDerivedType *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
@ -880,7 +880,7 @@ static void WriteMDDerivedType(const MDDerivedType *N,
Record.clear(); Record.clear();
} }
static void WriteMDCompositeType(const MDCompositeType *N, static void WriteDICompositeType(const DICompositeType *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
@ -906,7 +906,7 @@ static void WriteMDCompositeType(const MDCompositeType *N,
Record.clear(); Record.clear();
} }
static void WriteMDSubroutineType(const MDSubroutineType *N, static void WriteDISubroutineType(const DISubroutineType *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
@ -919,7 +919,7 @@ static void WriteMDSubroutineType(const MDSubroutineType *N,
Record.clear(); Record.clear();
} }
static void WriteMDFile(const MDFile *N, const ValueEnumerator &VE, static void WriteDIFile(const DIFile *N, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, unsigned Abbrev) { SmallVectorImpl<uint64_t> &Record, unsigned Abbrev) {
Record.push_back(N->isDistinct()); Record.push_back(N->isDistinct());
@ -930,7 +930,7 @@ static void WriteMDFile(const MDFile *N, const ValueEnumerator &VE,
Record.clear(); Record.clear();
} }
static void WriteMDCompileUnit(const MDCompileUnit *N, static void WriteDICompileUnit(const DICompileUnit *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
@ -954,11 +954,10 @@ static void WriteMDCompileUnit(const MDCompileUnit *N,
Record.clear(); Record.clear();
} }
static void WriteMDSubprogram(const MDSubprogram *N, static void WriteDISubprogram(const DISubprogram *N, const ValueEnumerator &VE,
const ValueEnumerator &VE, BitstreamWriter &Stream,
BitstreamWriter &Stream, SmallVectorImpl<uint64_t> &Record,
SmallVectorImpl<uint64_t> &Record, unsigned Abbrev) {
unsigned Abbrev) {
Record.push_back(N->isDistinct()); Record.push_back(N->isDistinct());
Record.push_back(VE.getMetadataOrNullID(N->getScope())); Record.push_back(VE.getMetadataOrNullID(N->getScope()));
Record.push_back(VE.getMetadataOrNullID(N->getRawName())); Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
@ -983,11 +982,11 @@ static void WriteMDSubprogram(const MDSubprogram *N,
Record.clear(); Record.clear();
} }
static void WriteMDLexicalBlock(const MDLexicalBlock *N, static void WriteDILexicalBlock(const DILexicalBlock *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) { unsigned Abbrev) {
Record.push_back(N->isDistinct()); Record.push_back(N->isDistinct());
Record.push_back(VE.getMetadataOrNullID(N->getScope())); Record.push_back(VE.getMetadataOrNullID(N->getScope()));
Record.push_back(VE.getMetadataOrNullID(N->getFile())); Record.push_back(VE.getMetadataOrNullID(N->getFile()));
@ -998,7 +997,7 @@ static void WriteMDLexicalBlock(const MDLexicalBlock *N,
Record.clear(); Record.clear();
} }
static void WriteMDLexicalBlockFile(const MDLexicalBlockFile *N, static void WriteDILexicalBlockFile(const DILexicalBlockFile *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
@ -1012,7 +1011,7 @@ static void WriteMDLexicalBlockFile(const MDLexicalBlockFile *N,
Record.clear(); Record.clear();
} }
static void WriteMDNamespace(const MDNamespace *N, const ValueEnumerator &VE, static void WriteDINamespace(const DINamespace *N, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) { unsigned Abbrev) {
@ -1026,7 +1025,7 @@ static void WriteMDNamespace(const MDNamespace *N, const ValueEnumerator &VE,
Record.clear(); Record.clear();
} }
static void WriteMDTemplateTypeParameter(const MDTemplateTypeParameter *N, static void WriteDITemplateTypeParameter(const DITemplateTypeParameter *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
@ -1039,7 +1038,7 @@ static void WriteMDTemplateTypeParameter(const MDTemplateTypeParameter *N,
Record.clear(); Record.clear();
} }
static void WriteMDTemplateValueParameter(const MDTemplateValueParameter *N, static void WriteDITemplateValueParameter(const DITemplateValueParameter *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
@ -1054,7 +1053,7 @@ static void WriteMDTemplateValueParameter(const MDTemplateValueParameter *N,
Record.clear(); Record.clear();
} }
static void WriteMDGlobalVariable(const MDGlobalVariable *N, static void WriteDIGlobalVariable(const DIGlobalVariable *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
@ -1075,7 +1074,7 @@ static void WriteMDGlobalVariable(const MDGlobalVariable *N,
Record.clear(); Record.clear();
} }
static void WriteMDLocalVariable(const MDLocalVariable *N, static void WriteDILocalVariable(const DILocalVariable *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
@ -1094,7 +1093,7 @@ static void WriteMDLocalVariable(const MDLocalVariable *N,
Record.clear(); Record.clear();
} }
static void WriteMDExpression(const MDExpression *N, const ValueEnumerator &, static void WriteDIExpression(const DIExpression *N, const ValueEnumerator &,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) { unsigned Abbrev) {
@ -1107,11 +1106,11 @@ static void WriteMDExpression(const MDExpression *N, const ValueEnumerator &,
Record.clear(); Record.clear();
} }
static void WriteMDObjCProperty(const MDObjCProperty *N, static void WriteDIObjCProperty(const DIObjCProperty *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) { unsigned Abbrev) {
Record.push_back(N->isDistinct()); Record.push_back(N->isDistinct());
Record.push_back(VE.getMetadataOrNullID(N->getRawName())); Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
Record.push_back(VE.getMetadataOrNullID(N->getFile())); Record.push_back(VE.getMetadataOrNullID(N->getFile()));
@ -1125,7 +1124,7 @@ static void WriteMDObjCProperty(const MDObjCProperty *N,
Record.clear(); Record.clear();
} }
static void WriteMDImportedEntity(const MDImportedEntity *N, static void WriteDIImportedEntity(const DIImportedEntity *N,
const ValueEnumerator &VE, const ValueEnumerator &VE,
BitstreamWriter &Stream, BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, SmallVectorImpl<uint64_t> &Record,
@ -1164,7 +1163,7 @@ static void WriteModuleMetadata(const Module *M,
#define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0; #define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0;
#include "llvm/IR/Metadata.def" #include "llvm/IR/Metadata.def"
if (VE.hasMDLocation()) { if (VE.hasDILocation()) {
// Abbrev for METADATA_LOCATION. // Abbrev for METADATA_LOCATION.
// //
// Assume the column is usually under 128, and always output the inlined-at // Assume the column is usually under 128, and always output the inlined-at
@ -1176,10 +1175,10 @@ static void WriteModuleMetadata(const Module *M,
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
MDLocationAbbrev = Stream.EmitAbbrev(Abbv); DILocationAbbrev = Stream.EmitAbbrev(Abbv);
} }
if (VE.hasGenericDebugNode()) { if (VE.hasGenericDINode()) {
// Abbrev for METADATA_GENERIC_DEBUG. // Abbrev for METADATA_GENERIC_DEBUG.
// //
// Assume the column is usually under 128, and always output the inlined-at // Assume the column is usually under 128, and always output the inlined-at
@ -1192,7 +1191,7 @@ static void WriteModuleMetadata(const Module *M,
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
GenericDebugNodeAbbrev = Stream.EmitAbbrev(Abbv); GenericDINodeAbbrev = Stream.EmitAbbrev(Abbv);
} }
unsigned NameAbbrev = 0; unsigned NameAbbrev = 0;
@ -2105,7 +2104,7 @@ static void WriteFunction(const Function &F, ValueEnumerator &VE,
bool NeedsMetadataAttachment = F.hasMetadata(); bool NeedsMetadataAttachment = F.hasMetadata();
MDLocation *LastDL = nullptr; DILocation *LastDL = nullptr;
// Finally, emit all the instructions, in order. // Finally, emit all the instructions, in order.
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
@ -2120,7 +2119,7 @@ static void WriteFunction(const Function &F, ValueEnumerator &VE,
NeedsMetadataAttachment |= I->hasMetadataOtherThanDebugLoc(); NeedsMetadataAttachment |= I->hasMetadataOtherThanDebugLoc();
// If the instruction has a debug location, emit it. // If the instruction has a debug location, emit it.
MDLocation *DL = I->getDebugLoc(); DILocation *DL = I->getDebugLoc();
if (!DL) if (!DL)
continue; continue;

View File

@ -285,7 +285,7 @@ static bool isIntOrIntVectorValue(const std::pair<const Value*, unsigned> &V) {
ValueEnumerator::ValueEnumerator(const Module &M, ValueEnumerator::ValueEnumerator(const Module &M,
bool ShouldPreserveUseListOrder) bool ShouldPreserveUseListOrder)
: HasMDString(false), HasMDLocation(false), HasGenericDebugNode(false), : HasMDString(false), HasDILocation(false), HasGenericDINode(false),
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) { ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {
if (ShouldPreserveUseListOrder) if (ShouldPreserveUseListOrder)
UseListOrders = predictUseListOrder(M); UseListOrders = predictUseListOrder(M);
@ -382,7 +382,7 @@ ValueEnumerator::ValueEnumerator(const Module &M,
// Don't enumerate the location directly -- it has a special record // Don't enumerate the location directly -- it has a special record
// type -- but enumerate its operands. // type -- but enumerate its operands.
if (MDLocation *L = I.getDebugLoc()) if (DILocation *L = I.getDebugLoc())
EnumerateMDNodeOperands(L); EnumerateMDNodeOperands(L);
} }
} }
@ -548,8 +548,8 @@ void ValueEnumerator::EnumerateMetadata(const Metadata *MD) {
EnumerateValue(C->getValue()); EnumerateValue(C->getValue());
HasMDString |= isa<MDString>(MD); HasMDString |= isa<MDString>(MD);
HasMDLocation |= isa<MDLocation>(MD); HasDILocation |= isa<DILocation>(MD);
HasGenericDebugNode |= isa<GenericDebugNode>(MD); HasGenericDINode |= isa<GenericDINode>(MD);
// Replace the dummy ID inserted above with the correct one. MDValueMap may // Replace the dummy ID inserted above with the correct one. MDValueMap may
// have changed by inserting operands, so we need a fresh lookup here. // have changed by inserting operands, so we need a fresh lookup here.

View File

@ -65,8 +65,8 @@ private:
typedef DenseMap<const Metadata *, unsigned> MetadataMapType; typedef DenseMap<const Metadata *, unsigned> MetadataMapType;
MetadataMapType MDValueMap; MetadataMapType MDValueMap;
bool HasMDString; bool HasMDString;
bool HasMDLocation; bool HasDILocation;
bool HasGenericDebugNode; bool HasGenericDINode;
bool ShouldPreserveUseListOrder; bool ShouldPreserveUseListOrder;
typedef DenseMap<AttributeSet, unsigned> AttributeGroupMapType; typedef DenseMap<AttributeSet, unsigned> AttributeGroupMapType;
@ -121,8 +121,8 @@ public:
} }
bool hasMDString() const { return HasMDString; } bool hasMDString() const { return HasMDString; }
bool hasMDLocation() const { return HasMDLocation; } bool hasDILocation() const { return HasDILocation; }
bool hasGenericDebugNode() const { return HasGenericDebugNode; } bool hasGenericDINode() const { return HasGenericDINode; }
bool shouldPreserveUseListOrder() const { return ShouldPreserveUseListOrder; } bool shouldPreserveUseListOrder() const { return ShouldPreserveUseListOrder; }

View File

@ -668,15 +668,15 @@ static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) {
raw_svector_ostream OS(Str); raw_svector_ostream OS(Str);
OS << "DEBUG_VALUE: "; OS << "DEBUG_VALUE: ";
const MDLocalVariable *V = MI->getDebugVariable(); const DILocalVariable *V = MI->getDebugVariable();
if (auto *SP = dyn_cast<MDSubprogram>(V->getScope())) { if (auto *SP = dyn_cast<DISubprogram>(V->getScope())) {
StringRef Name = SP->getDisplayName(); StringRef Name = SP->getDisplayName();
if (!Name.empty()) if (!Name.empty())
OS << Name << ":"; OS << Name << ":";
} }
OS << V->getName(); OS << V->getName();
const MDExpression *Expr = MI->getDebugExpression(); const DIExpression *Expr = MI->getDebugExpression();
if (Expr->isBitPiece()) if (Expr->isBitPiece())
OS << " [bit_piece offset=" << Expr->getBitPieceOffset() OS << " [bit_piece offset=" << Expr->getBitPieceOffset()
<< " size=" << Expr->getBitPieceSize() << "]"; << " size=" << Expr->getBitPieceSize() << "]";

View File

@ -204,7 +204,7 @@ void llvm::calculateDbgValueHistory(const MachineFunction *MF,
// Use the base variable (without any DW_OP_piece expressions) // Use the base variable (without any DW_OP_piece expressions)
// as index into History. The full variables including the // as index into History. The full variables including the
// piece expressions are attached to the MI. // piece expressions are attached to the MI.
const MDLocalVariable *RawVar = MI.getDebugVariable(); const DILocalVariable *RawVar = MI.getDebugVariable();
assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) && assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) &&
"Expected inlined-at fields to agree"); "Expected inlined-at fields to agree");
InlinedVariable Var(RawVar, MI.getDebugLoc()->getInlinedAt()); InlinedVariable Var(RawVar, MI.getDebugLoc()->getInlinedAt());

View File

@ -17,8 +17,8 @@ namespace llvm {
class MachineFunction; class MachineFunction;
class MachineInstr; class MachineInstr;
class MDLocalVariable; class DILocalVariable;
class MDLocation; class DILocation;
class TargetRegisterInfo; class TargetRegisterInfo;
// For each user variable, keep a list of instruction ranges where this variable // For each user variable, keep a list of instruction ranges where this variable
@ -32,7 +32,7 @@ class DbgValueHistoryMap {
public: public:
typedef std::pair<const MachineInstr *, const MachineInstr *> InstrRange; typedef std::pair<const MachineInstr *, const MachineInstr *> InstrRange;
typedef SmallVector<InstrRange, 4> InstrRanges; typedef SmallVector<InstrRange, 4> InstrRanges;
typedef std::pair<const MDLocalVariable *, const MDLocation *> typedef std::pair<const DILocalVariable *, const DILocation *>
InlinedVariable; InlinedVariable;
typedef MapVector<InlinedVariable, InstrRanges> InstrRangesMap; typedef MapVector<InlinedVariable, InstrRanges> InstrRangesMap;

View File

@ -29,25 +29,25 @@ class DebugLocEntry {
public: public:
/// \brief A single location or constant. /// \brief A single location or constant.
struct Value { struct Value {
Value(const MDExpression *Expr, int64_t i) Value(const DIExpression *Expr, int64_t i)
: Expression(Expr), EntryKind(E_Integer) { : Expression(Expr), EntryKind(E_Integer) {
Constant.Int = i; Constant.Int = i;
} }
Value(const MDExpression *Expr, const ConstantFP *CFP) Value(const DIExpression *Expr, const ConstantFP *CFP)
: Expression(Expr), EntryKind(E_ConstantFP) { : Expression(Expr), EntryKind(E_ConstantFP) {
Constant.CFP = CFP; Constant.CFP = CFP;
} }
Value(const MDExpression *Expr, const ConstantInt *CIP) Value(const DIExpression *Expr, const ConstantInt *CIP)
: Expression(Expr), EntryKind(E_ConstantInt) { : Expression(Expr), EntryKind(E_ConstantInt) {
Constant.CIP = CIP; Constant.CIP = CIP;
} }
Value(const MDExpression *Expr, MachineLocation Loc) Value(const DIExpression *Expr, MachineLocation Loc)
: Expression(Expr), EntryKind(E_Location), Loc(Loc) { : Expression(Expr), EntryKind(E_Location), Loc(Loc) {
assert(cast<MDExpression>(Expr)->isValid()); assert(cast<DIExpression>(Expr)->isValid());
} }
/// Any complex address location expression for this Value. /// Any complex address location expression for this Value.
const MDExpression *Expression; const DIExpression *Expression;
/// Type of entry that this represents. /// Type of entry that this represents.
enum EntryType { E_Location, E_Integer, E_ConstantFP, E_ConstantInt }; enum EntryType { E_Location, E_Integer, E_ConstantFP, E_ConstantInt };
@ -72,7 +72,7 @@ public:
const ConstantInt *getConstantInt() const { return Constant.CIP; } const ConstantInt *getConstantInt() const { return Constant.CIP; }
MachineLocation getLoc() const { return Loc; } MachineLocation getLoc() const { return Loc; }
bool isBitPiece() const { return getExpression()->isBitPiece(); } bool isBitPiece() const { return getExpression()->isBitPiece(); }
const MDExpression *getExpression() const { return Expression; } const DIExpression *getExpression() const { return Expression; }
friend bool operator==(const Value &, const Value &); friend bool operator==(const Value &, const Value &);
friend bool operator<(const Value &, const Value &); friend bool operator<(const Value &, const Value &);
}; };
@ -94,8 +94,8 @@ public:
/// Return true if the merge was successful. /// Return true if the merge was successful.
bool MergeValues(const DebugLocEntry &Next) { bool MergeValues(const DebugLocEntry &Next) {
if (Begin == Next.Begin) { if (Begin == Next.Begin) {
auto *Expr = cast_or_null<MDExpression>(Values[0].Expression); auto *Expr = cast_or_null<DIExpression>(Values[0].Expression);
auto *NextExpr = cast_or_null<MDExpression>(Next.Values[0].Expression); auto *NextExpr = cast_or_null<DIExpression>(Next.Values[0].Expression);
if (Expr->isBitPiece() && NextExpr->isBitPiece()) { if (Expr->isBitPiece() && NextExpr->isBitPiece()) {
addValues(Next.Values); addValues(Next.Values);
End = Next.End; End = Next.End;
@ -143,7 +143,7 @@ public:
/// \brief Lower this entry into a DWARF expression. /// \brief Lower this entry into a DWARF expression.
void finalize(const AsmPrinter &AP, DebugLocStream &Locs, void finalize(const AsmPrinter &AP, DebugLocStream &Locs,
const MDBasicType *BT); const DIBasicType *BT);
}; };
/// \brief Compare two Values for equality. /// \brief Compare two Values for equality.

View File

@ -16,7 +16,7 @@
namespace llvm { namespace llvm {
DwarfCompileUnit::DwarfCompileUnit(unsigned UID, const MDCompileUnit *Node, DwarfCompileUnit::DwarfCompileUnit(unsigned UID, const DICompileUnit *Node,
AsmPrinter *A, DwarfDebug *DW, AsmPrinter *A, DwarfDebug *DW,
DwarfFile *DWU) DwarfFile *DWU)
: DwarfUnit(UID, dwarf::DW_TAG_compile_unit, Node, A, DW, DWU), : DwarfUnit(UID, dwarf::DW_TAG_compile_unit, Node, A, DW, DWU),
@ -98,7 +98,7 @@ static const ConstantExpr *getMergedGlobalExpr(const Value *V) {
/// getOrCreateGlobalVariableDIE - get or create global variable DIE. /// getOrCreateGlobalVariableDIE - get or create global variable DIE.
DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE( DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
const MDGlobalVariable *GV) { const DIGlobalVariable *GV) {
// Check for pre-existence. // Check for pre-existence.
if (DIE *Die = getDIE(GV)) if (DIE *Die = getDIE(GV))
return Die; return Die;
@ -114,7 +114,7 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
// Add to map. // Add to map.
DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV); DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV);
MDScope *DeclContext; DIScope *DeclContext;
if (auto *SDMDecl = GV->getStaticDataMemberDeclaration()) { if (auto *SDMDecl = GV->getStaticDataMemberDeclaration()) {
DeclContext = resolve(SDMDecl->getScope()); DeclContext = resolve(SDMDecl->getScope());
assert(SDMDecl->isStaticMember() && "Expected static member decl"); assert(SDMDecl->isStaticMember() && "Expected static member decl");
@ -277,7 +277,7 @@ void DwarfCompileUnit::attachLowHighPC(DIE &D, const MCSymbol *Begin,
// Find DIE for the given subprogram and attach appropriate DW_AT_low_pc // Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
// and DW_AT_high_pc attributes. If there are global variables in this // and DW_AT_high_pc attributes. If there are global variables in this
// scope then create and insert DIEs for these variables. // scope then create and insert DIEs for these variables.
DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const MDSubprogram *SP) { DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) {
DIE *SPDie = getOrCreateSubprogramDIE(SP, includeMinimalInlineScopes()); DIE *SPDie = getOrCreateSubprogramDIE(SP, includeMinimalInlineScopes());
attachLowHighPC(*SPDie, Asm->getFunctionBegin(), Asm->getFunctionEnd()); attachLowHighPC(*SPDie, Asm->getFunctionBegin(), Asm->getFunctionEnd());
@ -308,7 +308,7 @@ void DwarfCompileUnit::constructScopeDIE(
auto *DS = Scope->getScopeNode(); auto *DS = Scope->getScopeNode();
assert((Scope->getInlinedAt() || !isa<MDSubprogram>(DS)) && assert((Scope->getInlinedAt() || !isa<DISubprogram>(DS)) &&
"Only handle inlined subprograms here, use " "Only handle inlined subprograms here, use "
"constructSubprogramScopeDIE for non-inlined " "constructSubprogramScopeDIE for non-inlined "
"subprograms"); "subprograms");
@ -319,7 +319,7 @@ void DwarfCompileUnit::constructScopeDIE(
// avoid creating un-used children then removing them later when we find out // avoid creating un-used children then removing them later when we find out
// the scope DIE is null. // the scope DIE is null.
std::unique_ptr<DIE> ScopeDIE; std::unique_ptr<DIE> ScopeDIE;
if (Scope->getParent() && isa<MDSubprogram>(DS)) { if (Scope->getParent() && isa<DISubprogram>(DS)) {
ScopeDIE = constructInlinedScopeDIE(Scope); ScopeDIE = constructInlinedScopeDIE(Scope);
if (!ScopeDIE) if (!ScopeDIE)
return; return;
@ -341,7 +341,7 @@ void DwarfCompileUnit::constructScopeDIE(
// There is no need to emit empty lexical block DIE. // There is no need to emit empty lexical block DIE.
for (const auto &E : DD->findImportedEntitiesForScope(DS)) for (const auto &E : DD->findImportedEntitiesForScope(DS))
Children.push_back( Children.push_back(
constructImportedEntityDIE(cast<MDImportedEntity>(E.second))); constructImportedEntityDIE(cast<DIImportedEntity>(E.second)));
} }
// If there are only other scopes as children, put them directly in the // If there are only other scopes as children, put them directly in the
@ -432,7 +432,7 @@ DwarfCompileUnit::constructInlinedScopeDIE(LexicalScope *Scope) {
attachRangesOrLowHighPC(*ScopeDIE, Scope->getRanges()); attachRangesOrLowHighPC(*ScopeDIE, Scope->getRanges());
// Add the call site information to the DIE. // Add the call site information to the DIE.
const MDLocation *IA = Scope->getInlinedAt(); const DILocation *IA = Scope->getInlinedAt();
addUInt(*ScopeDIE, dwarf::DW_AT_call_file, None, addUInt(*ScopeDIE, dwarf::DW_AT_call_file, None,
getOrCreateSourceID(IA->getFilename(), IA->getDirectory())); getOrCreateSourceID(IA->getFilename(), IA->getDirectory()));
addUInt(*ScopeDIE, dwarf::DW_AT_call_line, None, IA->getLine()); addUInt(*ScopeDIE, dwarf::DW_AT_call_line, None, IA->getLine());
@ -563,14 +563,14 @@ void DwarfCompileUnit::constructSubprogramScopeDIE(LexicalScope *Scope) {
assert(Scope && Scope->getScopeNode()); assert(Scope && Scope->getScopeNode());
assert(!Scope->getInlinedAt()); assert(!Scope->getInlinedAt());
assert(!Scope->isAbstractScope()); assert(!Scope->isAbstractScope());
auto *Sub = cast<MDSubprogram>(Scope->getScopeNode()); auto *Sub = cast<DISubprogram>(Scope->getScopeNode());
DD->getProcessedSPNodes().insert(Sub); DD->getProcessedSPNodes().insert(Sub);
DIE &ScopeDIE = updateSubprogramScopeDIE(Sub); DIE &ScopeDIE = updateSubprogramScopeDIE(Sub);
// If this is a variadic function, add an unspecified parameter. // If this is a variadic function, add an unspecified parameter.
MDTypeRefArray FnArgs = Sub->getType()->getTypeArray(); DITypeRefArray FnArgs = Sub->getType()->getTypeArray();
// Collect lexical scope children first. // Collect lexical scope children first.
// ObjectPointer might be a local (non-argument) local variable if it's a // ObjectPointer might be a local (non-argument) local variable if it's a
@ -605,7 +605,7 @@ DwarfCompileUnit::constructAbstractSubprogramScopeDIE(LexicalScope *Scope) {
if (AbsDef) if (AbsDef)
return; return;
auto *SP = cast<MDSubprogram>(Scope->getScopeNode()); auto *SP = cast<DISubprogram>(Scope->getScopeNode());
DIE *ContextDIE; DIE *ContextDIE;
@ -633,18 +633,18 @@ DwarfCompileUnit::constructAbstractSubprogramScopeDIE(LexicalScope *Scope) {
} }
std::unique_ptr<DIE> std::unique_ptr<DIE>
DwarfCompileUnit::constructImportedEntityDIE(const MDImportedEntity *Module) { DwarfCompileUnit::constructImportedEntityDIE(const DIImportedEntity *Module) {
std::unique_ptr<DIE> IMDie = make_unique<DIE>((dwarf::Tag)Module->getTag()); std::unique_ptr<DIE> IMDie = make_unique<DIE>((dwarf::Tag)Module->getTag());
insertDIE(Module, IMDie.get()); insertDIE(Module, IMDie.get());
DIE *EntityDie; DIE *EntityDie;
auto *Entity = resolve(Module->getEntity()); auto *Entity = resolve(Module->getEntity());
if (auto *NS = dyn_cast<MDNamespace>(Entity)) if (auto *NS = dyn_cast<DINamespace>(Entity))
EntityDie = getOrCreateNameSpace(NS); EntityDie = getOrCreateNameSpace(NS);
else if (auto *SP = dyn_cast<MDSubprogram>(Entity)) else if (auto *SP = dyn_cast<DISubprogram>(Entity))
EntityDie = getOrCreateSubprogramDIE(SP); EntityDie = getOrCreateSubprogramDIE(SP);
else if (auto *T = dyn_cast<MDType>(Entity)) else if (auto *T = dyn_cast<DIType>(Entity))
EntityDie = getOrCreateTypeDIE(T); EntityDie = getOrCreateTypeDIE(T);
else if (auto *GV = dyn_cast<MDGlobalVariable>(Entity)) else if (auto *GV = dyn_cast<DIGlobalVariable>(Entity))
EntityDie = getOrCreateGlobalVariableDIE(GV); EntityDie = getOrCreateGlobalVariableDIE(GV);
else else
EntityDie = getDIE(Entity); EntityDie = getDIE(Entity);
@ -659,7 +659,7 @@ DwarfCompileUnit::constructImportedEntityDIE(const MDImportedEntity *Module) {
return IMDie; return IMDie;
} }
void DwarfCompileUnit::finishSubprogramDefinition(const MDSubprogram *SP) { void DwarfCompileUnit::finishSubprogramDefinition(const DISubprogram *SP) {
DIE *D = getDIE(SP); DIE *D = getDIE(SP);
if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP)) { if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP)) {
if (D) if (D)
@ -676,7 +676,7 @@ void DwarfCompileUnit::finishSubprogramDefinition(const MDSubprogram *SP) {
applySubprogramAttributesToDefinition(SP, *D); applySubprogramAttributesToDefinition(SP, *D);
} }
} }
void DwarfCompileUnit::collectDeadVariables(const MDSubprogram *SP) { void DwarfCompileUnit::collectDeadVariables(const DISubprogram *SP) {
assert(SP && "CU's subprogram list contains a non-subprogram"); assert(SP && "CU's subprogram list contains a non-subprogram");
assert(SP->isDefinition() && assert(SP->isDefinition() &&
"CU's subprogram list contains a subprogram declaration"); "CU's subprogram list contains a subprogram declaration");
@ -688,7 +688,7 @@ void DwarfCompileUnit::collectDeadVariables(const MDSubprogram *SP) {
if (!SPDIE) if (!SPDIE)
SPDIE = getDIE(SP); SPDIE = getDIE(SP);
assert(SPDIE); assert(SPDIE);
for (const MDLocalVariable *DV : Variables) { for (const DILocalVariable *DV : Variables) {
DbgVariable NewVar(DV, /* IA */ nullptr, /* Expr */ nullptr, DD); DbgVariable NewVar(DV, /* IA */ nullptr, /* Expr */ nullptr, DD);
auto VariableDie = constructVariableDIE(NewVar); auto VariableDie = constructVariableDIE(NewVar);
applyVariableAttributes(NewVar, *VariableDie); applyVariableAttributes(NewVar, *VariableDie);
@ -708,7 +708,7 @@ void DwarfCompileUnit::emitHeader(bool UseOffsets) {
/// addGlobalName - Add a new global name to the compile unit. /// addGlobalName - Add a new global name to the compile unit.
void DwarfCompileUnit::addGlobalName(StringRef Name, DIE &Die, void DwarfCompileUnit::addGlobalName(StringRef Name, DIE &Die,
const MDScope *Context) { const DIScope *Context) {
if (includeMinimalInlineScopes()) if (includeMinimalInlineScopes())
return; return;
std::string FullName = getParentContextString(Context) + Name.str(); std::string FullName = getParentContextString(Context) + Name.str();
@ -716,8 +716,8 @@ void DwarfCompileUnit::addGlobalName(StringRef Name, DIE &Die,
} }
/// Add a new global type to the unit. /// Add a new global type to the unit.
void DwarfCompileUnit::addGlobalType(const MDType *Ty, const DIE &Die, void DwarfCompileUnit::addGlobalType(const DIType *Ty, const DIE &Die,
const MDScope *Context) { const DIScope *Context) {
if (includeMinimalInlineScopes()) if (includeMinimalInlineScopes())
return; return;
std::string FullName = getParentContextString(Context) + Ty->getName().str(); std::string FullName = getParentContextString(Context) + Ty->getName().str();
@ -764,7 +764,7 @@ void DwarfCompileUnit::addComplexAddress(const DbgVariable &DV, DIE &Die,
DIELoc *Loc = new (DIEValueAllocator) DIELoc(); DIELoc *Loc = new (DIEValueAllocator) DIELoc();
DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc); DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
assert(DV.getExpression().size() == 1); assert(DV.getExpression().size() == 1);
const MDExpression *Expr = DV.getExpression().back(); const DIExpression *Expr = DV.getExpression().back();
bool ValidReg; bool ValidReg;
if (Location.getOffset()) { if (Location.getOffset()) {
ValidReg = DwarfExpr.AddMachineRegIndirect(Location.getReg(), ValidReg = DwarfExpr.AddMachineRegIndirect(Location.getReg(),
@ -807,7 +807,7 @@ void DwarfCompileUnit::addExpr(DIELoc &Die, dwarf::Form Form,
} }
void DwarfCompileUnit::applySubprogramAttributesToDefinition( void DwarfCompileUnit::applySubprogramAttributesToDefinition(
const MDSubprogram *SP, DIE &SPDie) { const DISubprogram *SP, DIE &SPDie) {
auto *SPDecl = SP->getDeclaration(); auto *SPDecl = SP->getDeclaration();
auto *Context = resolve(SPDecl ? SPDecl->getScope() : SP->getScope()); auto *Context = resolve(SPDecl ? SPDecl->getScope() : SP->getScope());
applySubprogramAttributes(SP, SPDie, includeMinimalInlineScopes()); applySubprogramAttributes(SP, SPDie, includeMinimalInlineScopes());

View File

@ -66,7 +66,7 @@ class DwarfCompileUnit : public DwarfUnit {
bool includeMinimalInlineScopes() const; bool includeMinimalInlineScopes() const;
public: public:
DwarfCompileUnit(unsigned UID, const MDCompileUnit *Node, AsmPrinter *A, DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A,
DwarfDebug *DW, DwarfFile *DWU); DwarfDebug *DW, DwarfFile *DWU);
DwarfCompileUnit *getSkeleton() const { DwarfCompileUnit *getSkeleton() const {
@ -79,7 +79,7 @@ public:
void applyStmtList(DIE &D); void applyStmtList(DIE &D);
/// getOrCreateGlobalVariableDIE - get or create global variable DIE. /// getOrCreateGlobalVariableDIE - get or create global variable DIE.
DIE *getOrCreateGlobalVariableDIE(const MDGlobalVariable *GV); DIE *getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV);
/// addLabelAddress - Add a dwarf label attribute data and value using /// addLabelAddress - Add a dwarf label attribute data and value using
/// either DW_FORM_addr or DW_FORM_GNU_addr_index. /// either DW_FORM_addr or DW_FORM_GNU_addr_index.
@ -113,7 +113,7 @@ public:
/// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
/// variables in this scope then create and insert DIEs for these /// variables in this scope then create and insert DIEs for these
/// variables. /// variables.
DIE &updateSubprogramScopeDIE(const MDSubprogram *SP); DIE &updateSubprogramScopeDIE(const DISubprogram *SP);
void constructScopeDIE(LexicalScope *Scope, void constructScopeDIE(LexicalScope *Scope,
SmallVectorImpl<std::unique_ptr<DIE>> &FinalChildren); SmallVectorImpl<std::unique_ptr<DIE>> &FinalChildren);
@ -156,11 +156,11 @@ public:
/// \brief Construct import_module DIE. /// \brief Construct import_module DIE.
std::unique_ptr<DIE> std::unique_ptr<DIE>
constructImportedEntityDIE(const MDImportedEntity *Module); constructImportedEntityDIE(const DIImportedEntity *Module);
void finishSubprogramDefinition(const MDSubprogram *SP); void finishSubprogramDefinition(const DISubprogram *SP);
void collectDeadVariables(const MDSubprogram *SP); void collectDeadVariables(const DISubprogram *SP);
/// Set the skeleton unit associated with this unit. /// Set the skeleton unit associated with this unit.
void setSkeleton(DwarfCompileUnit &Skel) { Skeleton = &Skel; } void setSkeleton(DwarfCompileUnit &Skel) { Skeleton = &Skel; }
@ -183,11 +183,11 @@ public:
} }
/// Add a new global name to the compile unit. /// Add a new global name to the compile unit.
void addGlobalName(StringRef Name, DIE &Die, const MDScope *Context) override; void addGlobalName(StringRef Name, DIE &Die, const DIScope *Context) override;
/// Add a new global type to the compile unit. /// Add a new global type to the compile unit.
void addGlobalType(const MDType *Ty, const DIE &Die, void addGlobalType(const DIType *Ty, const DIE &Die,
const MDScope *Context) override; const DIScope *Context) override;
const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; } const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; }
const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; } const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; }
@ -215,7 +215,7 @@ public:
/// Add a Dwarf expression attribute data and value. /// Add a Dwarf expression attribute data and value.
void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr); void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr);
void applySubprogramAttributesToDefinition(const MDSubprogram *SP, void applySubprogramAttributesToDefinition(const DISubprogram *SP,
DIE &SPDie); DIE &SPDie);
/// getRangeLists - Get the vector of range lists. /// getRangeLists - Get the vector of range lists.

View File

@ -130,7 +130,7 @@ bool DebugLocDwarfExpression::isFrameRegister(unsigned MachineReg) {
/// resolve - Look in the DwarfDebug map for the MDNode that /// resolve - Look in the DwarfDebug map for the MDNode that
/// corresponds to the reference. /// corresponds to the reference.
template <typename T> T *DbgVariable::resolve(TypedDebugNodeRef<T> Ref) const { template <typename T> T *DbgVariable::resolve(TypedDINodeRef<T> Ref) const {
return DD->resolve(Ref); return DD->resolve(Ref);
} }
@ -141,8 +141,8 @@ bool DbgVariable::isBlockByrefVariable() const {
->isBlockByrefStruct(); ->isBlockByrefStruct();
} }
const MDType *DbgVariable::getType() const { const DIType *DbgVariable::getType() const {
MDType *Ty = Var->getType().resolve(DD->getTypeIdentifierMap()); DIType *Ty = Var->getType().resolve(DD->getTypeIdentifierMap());
// FIXME: isBlockByrefVariable should be reformulated in terms of complex // FIXME: isBlockByrefVariable should be reformulated in terms of complex
// addresses instead. // addresses instead.
if (Ty->isBlockByrefStruct()) { if (Ty->isBlockByrefStruct()) {
@ -170,15 +170,15 @@ const MDType *DbgVariable::getType() const {
have a DW_AT_location that tells the debugger how to unwind through have a DW_AT_location that tells the debugger how to unwind through
the pointers and __Block_byref_x_VarName struct to find the actual the pointers and __Block_byref_x_VarName struct to find the actual
value of the variable. The function addBlockByrefType does this. */ value of the variable. The function addBlockByrefType does this. */
MDType *subType = Ty; DIType *subType = Ty;
uint16_t tag = Ty->getTag(); uint16_t tag = Ty->getTag();
if (tag == dwarf::DW_TAG_pointer_type) if (tag == dwarf::DW_TAG_pointer_type)
subType = resolve(cast<MDDerivedType>(Ty)->getBaseType()); subType = resolve(cast<DIDerivedType>(Ty)->getBaseType());
auto Elements = cast<MDCompositeTypeBase>(subType)->getElements(); auto Elements = cast<DICompositeTypeBase>(subType)->getElements();
for (unsigned i = 0, N = Elements.size(); i < N; ++i) { for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
auto *DT = cast<MDDerivedTypeBase>(Elements[i]); auto *DT = cast<DIDerivedTypeBase>(Elements[i]);
if (getName() == DT->getName()) if (getName() == DT->getName())
return resolve(DT->getBaseType()); return resolve(DT->getBaseType());
} }
@ -277,7 +277,7 @@ static StringRef getObjCMethodName(StringRef In) {
// TODO: Determine whether or not we should add names for programs // TODO: Determine whether or not we should add names for programs
// that do not have a DW_AT_name or DW_AT_linkage_name field - this // that do not have a DW_AT_name or DW_AT_linkage_name field - this
// is only slightly different than the lookup of non-standard ObjC names. // is only slightly different than the lookup of non-standard ObjC names.
void DwarfDebug::addSubprogramNames(const MDSubprogram *SP, DIE &Die) { void DwarfDebug::addSubprogramNames(const DISubprogram *SP, DIE &Die) {
if (!SP->isDefinition()) if (!SP->isDefinition())
return; return;
addAccelName(SP->getName(), Die); addAccelName(SP->getName(), Die);
@ -305,9 +305,9 @@ void DwarfDebug::addSubprogramNames(const MDSubprogram *SP, DIE &Die) {
bool DwarfDebug::isSubprogramContext(const MDNode *Context) { bool DwarfDebug::isSubprogramContext(const MDNode *Context) {
if (!Context) if (!Context)
return false; return false;
if (isa<MDSubprogram>(Context)) if (isa<DISubprogram>(Context))
return true; return true;
if (auto *T = dyn_cast<MDType>(Context)) if (auto *T = dyn_cast<DIType>(Context))
return isSubprogramContext(resolve(T->getScope())); return isSubprogramContext(resolve(T->getScope()));
return false; return false;
} }
@ -364,7 +364,7 @@ void DwarfDebug::addGnuPubAttributes(DwarfUnit &U, DIE &D) const {
// Create new DwarfCompileUnit for the given metadata node with tag // Create new DwarfCompileUnit for the given metadata node with tag
// DW_TAG_compile_unit. // DW_TAG_compile_unit.
DwarfCompileUnit & DwarfCompileUnit &
DwarfDebug::constructDwarfCompileUnit(const MDCompileUnit *DIUnit) { DwarfDebug::constructDwarfCompileUnit(const DICompileUnit *DIUnit) {
StringRef FN = DIUnit->getFilename(); StringRef FN = DIUnit->getFilename();
CompilationDir = DIUnit->getDirectory(); CompilationDir = DIUnit->getDirectory();
@ -422,7 +422,7 @@ DwarfDebug::constructDwarfCompileUnit(const MDCompileUnit *DIUnit) {
} }
void DwarfDebug::constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU, void DwarfDebug::constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
const MDImportedEntity *N) { const DIImportedEntity *N) {
if (DIE *D = TheCU.getOrCreateContextDIE(N->getScope())) if (DIE *D = TheCU.getOrCreateContextDIE(N->getScope()))
D->addChild(TheCU.constructImportedEntityDIE(N)); D->addChild(TheCU.constructImportedEntityDIE(N));
} }
@ -446,7 +446,7 @@ void DwarfDebug::beginModule() {
SingleCU = CU_Nodes->getNumOperands() == 1; SingleCU = CU_Nodes->getNumOperands() == 1;
for (MDNode *N : CU_Nodes->operands()) { for (MDNode *N : CU_Nodes->operands()) {
auto *CUNode = cast<MDCompileUnit>(N); auto *CUNode = cast<DICompileUnit>(N);
DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode); DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);
for (auto *IE : CUNode->getImportedEntities()) for (auto *IE : CUNode->getImportedEntities())
ScopesWithImportedEntities.push_back(std::make_pair(IE->getScope(), IE)); ScopesWithImportedEntities.push_back(std::make_pair(IE->getScope(), IE));
@ -462,12 +462,12 @@ void DwarfDebug::beginModule() {
for (auto *Ty : CUNode->getEnumTypes()) { for (auto *Ty : CUNode->getEnumTypes()) {
// The enum types array by design contains pointers to // The enum types array by design contains pointers to
// MDNodes rather than DIRefs. Unique them here. // MDNodes rather than DIRefs. Unique them here.
CU.getOrCreateTypeDIE(cast<MDType>(resolve(Ty->getRef()))); CU.getOrCreateTypeDIE(cast<DIType>(resolve(Ty->getRef())));
} }
for (auto *Ty : CUNode->getRetainedTypes()) { for (auto *Ty : CUNode->getRetainedTypes()) {
// The retained types array by design contains pointers to // The retained types array by design contains pointers to
// MDNodes rather than DIRefs. Unique them here. // MDNodes rather than DIRefs. Unique them here.
CU.getOrCreateTypeDIE(cast<MDType>(resolve(Ty->getRef()))); CU.getOrCreateTypeDIE(cast<DIType>(resolve(Ty->getRef())));
} }
// Emit imported_modules last so that the relevant context is already // Emit imported_modules last so that the relevant context is already
// available. // available.
@ -501,7 +501,7 @@ void DwarfDebug::finishVariableDefinitions() {
void DwarfDebug::finishSubprogramDefinitions() { void DwarfDebug::finishSubprogramDefinitions() {
for (const auto &P : SPMap) for (const auto &P : SPMap)
forBothCUs(*P.second, [&](DwarfCompileUnit &CU) { forBothCUs(*P.second, [&](DwarfCompileUnit &CU) {
CU.finishSubprogramDefinition(cast<MDSubprogram>(P.first)); CU.finishSubprogramDefinition(cast<DISubprogram>(P.first));
}); });
} }
@ -512,7 +512,7 @@ void DwarfDebug::collectDeadVariables() {
if (NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu")) { if (NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu")) {
for (MDNode *N : CU_Nodes->operands()) { for (MDNode *N : CU_Nodes->operands()) {
auto *TheCU = cast<MDCompileUnit>(N); auto *TheCU = cast<DICompileUnit>(N);
// Construct subprogram DIE and add variables DIEs. // Construct subprogram DIE and add variables DIEs.
DwarfCompileUnit *SPCU = DwarfCompileUnit *SPCU =
static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU)); static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU));
@ -662,7 +662,7 @@ void DwarfDebug::endModule() {
// Find abstract variable, if any, associated with Var. // Find abstract variable, if any, associated with Var.
DbgVariable * DbgVariable *
DwarfDebug::getExistingAbstractVariable(InlinedVariable IV, DwarfDebug::getExistingAbstractVariable(InlinedVariable IV,
const MDLocalVariable *&Cleansed) { const DILocalVariable *&Cleansed) {
// More then one inlined variable corresponds to one abstract variable. // More then one inlined variable corresponds to one abstract variable.
Cleansed = IV.first; Cleansed = IV.first;
auto I = AbstractVariables.find(Cleansed); auto I = AbstractVariables.find(Cleansed);
@ -672,11 +672,11 @@ DwarfDebug::getExistingAbstractVariable(InlinedVariable IV,
} }
DbgVariable *DwarfDebug::getExistingAbstractVariable(InlinedVariable IV) { DbgVariable *DwarfDebug::getExistingAbstractVariable(InlinedVariable IV) {
const MDLocalVariable *Cleansed; const DILocalVariable *Cleansed;
return getExistingAbstractVariable(IV, Cleansed); return getExistingAbstractVariable(IV, Cleansed);
} }
void DwarfDebug::createAbstractVariable(const MDLocalVariable *Var, void DwarfDebug::createAbstractVariable(const DILocalVariable *Var,
LexicalScope *Scope) { LexicalScope *Scope) {
auto AbsDbgVariable = auto AbsDbgVariable =
make_unique<DbgVariable>(Var, /* IA */ nullptr, /* Expr */ nullptr, this); make_unique<DbgVariable>(Var, /* IA */ nullptr, /* Expr */ nullptr, this);
@ -686,22 +686,22 @@ void DwarfDebug::createAbstractVariable(const MDLocalVariable *Var,
void DwarfDebug::ensureAbstractVariableIsCreated(InlinedVariable IV, void DwarfDebug::ensureAbstractVariableIsCreated(InlinedVariable IV,
const MDNode *ScopeNode) { const MDNode *ScopeNode) {
const MDLocalVariable *Cleansed = nullptr; const DILocalVariable *Cleansed = nullptr;
if (getExistingAbstractVariable(IV, Cleansed)) if (getExistingAbstractVariable(IV, Cleansed))
return; return;
createAbstractVariable(Cleansed, LScopes.getOrCreateAbstractScope( createAbstractVariable(Cleansed, LScopes.getOrCreateAbstractScope(
cast<MDLocalScope>(ScopeNode))); cast<DILocalScope>(ScopeNode)));
} }
void DwarfDebug::ensureAbstractVariableIsCreatedIfScoped( void DwarfDebug::ensureAbstractVariableIsCreatedIfScoped(
InlinedVariable IV, const MDNode *ScopeNode) { InlinedVariable IV, const MDNode *ScopeNode) {
const MDLocalVariable *Cleansed = nullptr; const DILocalVariable *Cleansed = nullptr;
if (getExistingAbstractVariable(IV, Cleansed)) if (getExistingAbstractVariable(IV, Cleansed))
return; return;
if (LexicalScope *Scope = if (LexicalScope *Scope =
LScopes.findAbstractScope(cast_or_null<MDLocalScope>(ScopeNode))) LScopes.findAbstractScope(cast_or_null<DILocalScope>(ScopeNode)))
createAbstractVariable(Cleansed, Scope); createAbstractVariable(Cleansed, Scope);
} }
@ -722,7 +722,7 @@ void DwarfDebug::collectVariableInfoFromMMITable(
if (!Scope) if (!Scope)
continue; continue;
const MDExpression *Expr = cast_or_null<MDExpression>(VI.Expr); const DIExpression *Expr = cast_or_null<DIExpression>(VI.Expr);
ensureAbstractVariableIsCreatedIfScoped(Var, Scope->getScopeNode()); ensureAbstractVariableIsCreatedIfScoped(Var, Scope->getScopeNode());
auto RegVar = auto RegVar =
make_unique<DbgVariable>(Var.first, Var.second, Expr, this, VI.Slot); make_unique<DbgVariable>(Var.first, Var.second, Expr, this, VI.Slot);
@ -733,7 +733,7 @@ void DwarfDebug::collectVariableInfoFromMMITable(
// Get .debug_loc entry for the instruction range starting at MI. // Get .debug_loc entry for the instruction range starting at MI.
static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) { static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) {
const MDExpression *Expr = MI->getDebugExpression(); const DIExpression *Expr = MI->getDebugExpression();
assert(MI->getNumOperands() == 4); assert(MI->getNumOperands() == 4);
if (MI->getOperand(0).isReg()) { if (MI->getOperand(0).isReg()) {
@ -757,7 +757,7 @@ static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) {
} }
/// Determine whether two variable pieces overlap. /// Determine whether two variable pieces overlap.
static bool piecesOverlap(const MDExpression *P1, const MDExpression *P2) { static bool piecesOverlap(const DIExpression *P1, const DIExpression *P2) {
if (!P1->isBitPiece() || !P2->isBitPiece()) if (!P1->isBitPiece() || !P2->isBitPiece())
return true; return true;
unsigned l1 = P1->getBitPieceOffset(); unsigned l1 = P1->getBitPieceOffset();
@ -809,7 +809,7 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
} }
// If this piece overlaps with any open ranges, truncate them. // If this piece overlaps with any open ranges, truncate them.
const MDExpression *DIExpr = Begin->getDebugExpression(); const DIExpression *DIExpr = Begin->getDebugExpression();
auto Last = std::remove_if(OpenRanges.begin(), OpenRanges.end(), auto Last = std::remove_if(OpenRanges.begin(), OpenRanges.end(),
[&](DebugLocEntry::Value R) { [&](DebugLocEntry::Value R) {
return piecesOverlap(DIExpr, R.getExpression()); return piecesOverlap(DIExpr, R.getExpression());
@ -874,7 +874,7 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
// Find variables for each lexical scope. // Find variables for each lexical scope.
void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU, void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU,
const MDSubprogram *SP, const DISubprogram *SP,
DenseSet<InlinedVariable> &Processed) { DenseSet<InlinedVariable> &Processed) {
// Grab the variable info that was squirreled away in the MMI side-table. // Grab the variable info that was squirreled away in the MMI side-table.
collectVariableInfoFromMMITable(Processed); collectVariableInfoFromMMITable(Processed);
@ -890,7 +890,7 @@ void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU,
continue; continue;
LexicalScope *Scope = nullptr; LexicalScope *Scope = nullptr;
if (const MDLocation *IA = IV.second) if (const DILocation *IA = IV.second)
Scope = LScopes.findInlinedScope(IV.first->getScope(), IA); Scope = LScopes.findInlinedScope(IV.first->getScope(), IA);
else else
Scope = LScopes.findLexicalScope(IV.first->getScope()); Scope = LScopes.findLexicalScope(IV.first->getScope());
@ -918,10 +918,10 @@ void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU,
SmallVector<DebugLocEntry, 8> Entries; SmallVector<DebugLocEntry, 8> Entries;
buildLocationList(Entries, Ranges); buildLocationList(Entries, Ranges);
// If the variable has an MDBasicType, extract it. Basic types cannot have // If the variable has an DIBasicType, extract it. Basic types cannot have
// unique identifiers, so don't bother resolving the type with the // unique identifiers, so don't bother resolving the type with the
// identifier map. // identifier map.
const MDBasicType *BT = dyn_cast<MDBasicType>( const DIBasicType *BT = dyn_cast<DIBasicType>(
static_cast<const Metadata *>(IV.first->getType())); static_cast<const Metadata *>(IV.first->getType()));
// Finalize the entry by lowering it into a DWARF bytestream. // Finalize the entry by lowering it into a DWARF bytestream.
@ -930,7 +930,7 @@ void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU,
} }
// Collect info for variables that were optimized out. // Collect info for variables that were optimized out.
for (const MDLocalVariable *DV : SP->getVariables()) { for (const DILocalVariable *DV : SP->getVariables()) {
if (!Processed.insert(InlinedVariable(DV, nullptr)).second) if (!Processed.insert(InlinedVariable(DV, nullptr)).second)
continue; continue;
if (LexicalScope *Scope = LScopes.findLexicalScope(DV->getScope())) { if (LexicalScope *Scope = LScopes.findLexicalScope(DV->getScope())) {
@ -1128,14 +1128,14 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
// The first mention of a function argument gets the CurrentFnBegin // The first mention of a function argument gets the CurrentFnBegin
// label, so arguments are visible when breaking at function entry. // label, so arguments are visible when breaking at function entry.
const MDLocalVariable *DIVar = Ranges.front().first->getDebugVariable(); const DILocalVariable *DIVar = Ranges.front().first->getDebugVariable();
if (DIVar->getTag() == dwarf::DW_TAG_arg_variable && if (DIVar->getTag() == dwarf::DW_TAG_arg_variable &&
getDISubprogram(DIVar->getScope())->describes(MF->getFunction())) { getDISubprogram(DIVar->getScope())->describes(MF->getFunction())) {
LabelsBeforeInsn[Ranges.front().first] = Asm->getFunctionBegin(); LabelsBeforeInsn[Ranges.front().first] = Asm->getFunctionBegin();
if (Ranges.front().first->getDebugExpression()->isBitPiece()) { if (Ranges.front().first->getDebugExpression()->isBitPiece()) {
// Mark all non-overlapping initial pieces. // Mark all non-overlapping initial pieces.
for (auto I = Ranges.begin(); I != Ranges.end(); ++I) { for (auto I = Ranges.begin(); I != Ranges.end(); ++I) {
const MDExpression *Piece = I->first->getDebugExpression(); const DIExpression *Piece = I->first->getDebugExpression();
if (std::all_of(Ranges.begin(), I, if (std::all_of(Ranges.begin(), I,
[&](DbgValueHistoryMap::InstrRange Pred) { [&](DbgValueHistoryMap::InstrRange Pred) {
return !piecesOverlap(Piece, Pred.first->getDebugExpression()); return !piecesOverlap(Piece, Pred.first->getDebugExpression());
@ -1159,7 +1159,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
// Record beginning of function. // Record beginning of function.
PrologEndLoc = findPrologueEndLoc(MF); PrologEndLoc = findPrologueEndLoc(MF);
if (MDLocation *L = PrologEndLoc) { if (DILocation *L = PrologEndLoc) {
// We'd like to list the prologue as "not statements" but GDB behaves // We'd like to list the prologue as "not statements" but GDB behaves
// poorly if we do that. Revisit this with caution/GDB (7.5+) testing. // poorly if we do that. Revisit this with caution/GDB (7.5+) testing.
auto *SP = L->getInlinedAtScope()->getSubprogram(); auto *SP = L->getInlinedAtScope()->getSubprogram();
@ -1186,7 +1186,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
Asm->OutStreamer->getContext().setDwarfCompileUnitID(0); Asm->OutStreamer->getContext().setDwarfCompileUnitID(0);
LexicalScope *FnScope = LScopes.getCurrentFunctionScope(); LexicalScope *FnScope = LScopes.getCurrentFunctionScope();
auto *SP = cast<MDSubprogram>(FnScope->getScopeNode()); auto *SP = cast<DISubprogram>(FnScope->getScopeNode());
DwarfCompileUnit &TheCU = *SPMap.lookup(SP); DwarfCompileUnit &TheCU = *SPMap.lookup(SP);
DenseSet<InlinedVariable> ProcessedVars; DenseSet<InlinedVariable> ProcessedVars;
@ -1216,9 +1216,9 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
#endif #endif
// Construct abstract scopes. // Construct abstract scopes.
for (LexicalScope *AScope : LScopes.getAbstractScopesList()) { for (LexicalScope *AScope : LScopes.getAbstractScopesList()) {
auto *SP = cast<MDSubprogram>(AScope->getScopeNode()); auto *SP = cast<DISubprogram>(AScope->getScopeNode());
// Collect info for variables that were optimized out. // Collect info for variables that were optimized out.
for (const MDLocalVariable *DV : SP->getVariables()) { for (const DILocalVariable *DV : SP->getVariables()) {
if (!ProcessedVars.insert(InlinedVariable(DV, nullptr)).second) if (!ProcessedVars.insert(InlinedVariable(DV, nullptr)).second)
continue; continue;
ensureAbstractVariableIsCreated(InlinedVariable(DV, nullptr), ensureAbstractVariableIsCreated(InlinedVariable(DV, nullptr),
@ -1254,10 +1254,10 @@ void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S,
StringRef Dir; StringRef Dir;
unsigned Src = 1; unsigned Src = 1;
unsigned Discriminator = 0; unsigned Discriminator = 0;
if (auto *Scope = cast_or_null<MDScope>(S)) { if (auto *Scope = cast_or_null<DIScope>(S)) {
Fn = Scope->getFilename(); Fn = Scope->getFilename();
Dir = Scope->getDirectory(); Dir = Scope->getDirectory();
if (auto *LBF = dyn_cast<MDLexicalBlockFile>(Scope)) if (auto *LBF = dyn_cast<DILexicalBlockFile>(Scope))
Discriminator = LBF->getDiscriminator(); Discriminator = LBF->getDiscriminator();
unsigned CUID = Asm->OutStreamer->getContext().getDwarfCompileUnitID(); unsigned CUID = Asm->OutStreamer->getContext().getDwarfCompileUnitID();
@ -1471,7 +1471,7 @@ void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer,
Streamer.EmitInt8(Byte, Comment != End ? *(Comment++) : ""); Streamer.EmitInt8(Byte, Comment != End ? *(Comment++) : "");
} }
static void emitDebugLocValue(const AsmPrinter &AP, const MDBasicType *BT, static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT,
ByteStreamer &Streamer, ByteStreamer &Streamer,
const DebugLocEntry::Value &Value, const DebugLocEntry::Value &Value,
unsigned PieceOffsetInBits) { unsigned PieceOffsetInBits) {
@ -1487,7 +1487,7 @@ static void emitDebugLocValue(const AsmPrinter &AP, const MDBasicType *BT,
DwarfExpr.AddUnsignedConstant(Value.getInt()); DwarfExpr.AddUnsignedConstant(Value.getInt());
} else if (Value.isLocation()) { } else if (Value.isLocation()) {
MachineLocation Loc = Value.getLoc(); MachineLocation Loc = Value.getLoc();
const MDExpression *Expr = Value.getExpression(); const DIExpression *Expr = Value.getExpression();
if (!Expr || !Expr->getNumElements()) if (!Expr || !Expr->getNumElements())
// Regular entry. // Regular entry.
AP.EmitDwarfRegOp(Streamer, Loc); AP.EmitDwarfRegOp(Streamer, Loc);
@ -1508,7 +1508,7 @@ static void emitDebugLocValue(const AsmPrinter &AP, const MDBasicType *BT,
} }
void DebugLocEntry::finalize(const AsmPrinter &AP, DebugLocStream &Locs, void DebugLocEntry::finalize(const AsmPrinter &AP, DebugLocStream &Locs,
const MDBasicType *BT) { const DIBasicType *BT) {
Locs.startEntry(Begin, End); Locs.startEntry(Begin, End);
BufferByteStreamer Streamer = Locs.getStreamer(); BufferByteStreamer Streamer = Locs.getStreamer();
const DebugLocEntry::Value &Value = Values[0]; const DebugLocEntry::Value &Value = Values[0];
@ -1522,7 +1522,7 @@ void DebugLocEntry::finalize(const AsmPrinter &AP, DebugLocStream &Locs,
unsigned Offset = 0; unsigned Offset = 0;
for (auto Piece : Values) { for (auto Piece : Values) {
const MDExpression *Expr = Piece.getExpression(); const DIExpression *Expr = Piece.getExpression();
unsigned PieceOffset = Expr->getBitPieceOffset(); unsigned PieceOffset = Expr->getBitPieceOffset();
unsigned PieceSize = Expr->getBitPieceSize(); unsigned PieceSize = Expr->getBitPieceSize();
assert(Offset <= PieceOffset && "overlapping or duplicate pieces"); assert(Offset <= PieceOffset && "overlapping or duplicate pieces");
@ -1903,7 +1903,7 @@ static uint64_t makeTypeSignature(StringRef Identifier) {
void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU, void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
StringRef Identifier, DIE &RefDie, StringRef Identifier, DIE &RefDie,
const MDCompositeType *CTy) { const DICompositeType *CTy) {
// Fast path if we're building some type units and one has already used the // Fast path if we're building some type units and one has already used the
// address pool we know we're going to throw away all this work anyway, so // address pool we know we're going to throw away all this work anyway, so
// don't bother building dependent types. // don't bother building dependent types.
@ -1962,7 +1962,7 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
// This is inefficient because all the dependent types will be rebuilt // This is inefficient because all the dependent types will be rebuilt
// from scratch, including building them in type units, discovering that // from scratch, including building them in type units, discovering that
// they depend on addresses, throwing them out and rebuilding them. // they depend on addresses, throwing them out and rebuilding them.
CU.constructTypeDIE(RefDie, cast<MDCompositeType>(CTy)); CU.constructTypeDIE(RefDie, cast<DICompositeType>(CTy));
return; return;
} }

View File

@ -75,9 +75,9 @@ public:
/// - Variables that are described by multiple MMI table entries have multiple /// - Variables that are described by multiple MMI table entries have multiple
/// expressions and frame indices. /// expressions and frame indices.
class DbgVariable { class DbgVariable {
const MDLocalVariable *Var; /// Variable Descriptor. const DILocalVariable *Var; /// Variable Descriptor.
const MDLocation *IA; /// Inlined at location. const DILocation *IA; /// Inlined at location.
SmallVector<const MDExpression *, 1> SmallVector<const DIExpression *, 1>
Expr; /// Complex address location expression. Expr; /// Complex address location expression.
DIE *TheDIE; /// Variable DIE. DIE *TheDIE; /// Variable DIE.
unsigned DebugLocListIndex; /// Offset in DebugLocs. unsigned DebugLocListIndex; /// Offset in DebugLocs.
@ -87,8 +87,8 @@ class DbgVariable {
public: public:
/// Construct a DbgVariable from a variable. /// Construct a DbgVariable from a variable.
DbgVariable(const MDLocalVariable *V, const MDLocation *IA, DbgVariable(const DILocalVariable *V, const DILocation *IA,
const MDExpression *E, DwarfDebug *DD, int FI = ~0) const DIExpression *E, DwarfDebug *DD, int FI = ~0)
: Var(V), IA(IA), Expr(1, E), TheDIE(nullptr), DebugLocListIndex(~0U), : Var(V), IA(IA), Expr(1, E), TheDIE(nullptr), DebugLocListIndex(~0U),
MInsn(nullptr), DD(DD) { MInsn(nullptr), DD(DD) {
FrameIndex.push_back(FI); FrameIndex.push_back(FI);
@ -106,9 +106,9 @@ public:
} }
// Accessors. // Accessors.
const MDLocalVariable *getVariable() const { return Var; } const DILocalVariable *getVariable() const { return Var; }
const MDLocation *getInlinedAt() const { return IA; } const DILocation *getInlinedAt() const { return IA; }
const ArrayRef<const MDExpression *> getExpression() const { return Expr; } const ArrayRef<const DIExpression *> getExpression() const { return Expr; }
void setDIE(DIE &D) { TheDIE = &D; } void setDIE(DIE &D) { TheDIE = &D; }
DIE *getDIE() const { return TheDIE; } DIE *getDIE() const { return TheDIE; }
void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; } void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
@ -130,7 +130,7 @@ public:
FrameIndex.append(FI.begin(), FI.end()); FrameIndex.append(FI.begin(), FI.end());
} }
assert(Expr.size() > 1 ? std::all_of(Expr.begin(), Expr.end(), assert(Expr.size() > 1 ? std::all_of(Expr.begin(), Expr.end(),
[](const MDExpression *E) { [](const DIExpression *E) {
return E->isBitPiece(); return E->isBitPiece();
}) })
: (true && "conflicting locations for variable")); : (true && "conflicting locations for variable"));
@ -167,12 +167,12 @@ public:
return Expr.back()->getNumElements() > 0; return Expr.back()->getNumElements() > 0;
} }
bool isBlockByrefVariable() const; bool isBlockByrefVariable() const;
const MDType *getType() const; const DIType *getType() const;
private: private:
/// resolve - Look in the DwarfDebug map for the MDNode that /// resolve - Look in the DwarfDebug map for the MDNode that
/// corresponds to the reference. /// corresponds to the reference.
template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const; template <typename T> T *resolve(TypedDINodeRef<T> Ref) const;
}; };
@ -271,7 +271,7 @@ class DwarfDebug : public AsmPrinterHandler {
DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits; DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
SmallVector< SmallVector<
std::pair<std::unique_ptr<DwarfTypeUnit>, const MDCompositeType *>, 1> std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1>
TypeUnitsUnderConstruction; TypeUnitsUnderConstruction;
// Whether to emit the pubnames/pubtypes sections. // Whether to emit the pubnames/pubtypes sections.
@ -324,7 +324,7 @@ class DwarfDebug : public AsmPrinterHandler {
DwarfAccelTable AccelNamespace; DwarfAccelTable AccelNamespace;
DwarfAccelTable AccelTypes; DwarfAccelTable AccelTypes;
DenseMap<const Function *, MDSubprogram *> FunctionDIs; DenseMap<const Function *, DISubprogram *> FunctionDIs;
MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &); MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
@ -336,9 +336,9 @@ class DwarfDebug : public AsmPrinterHandler {
/// \brief Find abstract variable associated with Var. /// \brief Find abstract variable associated with Var.
DbgVariable *getExistingAbstractVariable(InlinedVariable IV, DbgVariable *getExistingAbstractVariable(InlinedVariable IV,
const MDLocalVariable *&Cleansed); const DILocalVariable *&Cleansed);
DbgVariable *getExistingAbstractVariable(InlinedVariable IV); DbgVariable *getExistingAbstractVariable(InlinedVariable IV);
void createAbstractVariable(const MDLocalVariable *DV, LexicalScope *Scope); void createAbstractVariable(const DILocalVariable *DV, LexicalScope *Scope);
void ensureAbstractVariableIsCreated(InlinedVariable Var, void ensureAbstractVariableIsCreated(InlinedVariable Var,
const MDNode *Scope); const MDNode *Scope);
void ensureAbstractVariableIsCreatedIfScoped(InlinedVariable Var, void ensureAbstractVariableIsCreatedIfScoped(InlinedVariable Var,
@ -453,11 +453,11 @@ class DwarfDebug : public AsmPrinterHandler {
/// \brief Create new DwarfCompileUnit for the given metadata node with tag /// \brief Create new DwarfCompileUnit for the given metadata node with tag
/// DW_TAG_compile_unit. /// DW_TAG_compile_unit.
DwarfCompileUnit &constructDwarfCompileUnit(const MDCompileUnit *DIUnit); DwarfCompileUnit &constructDwarfCompileUnit(const DICompileUnit *DIUnit);
/// \brief Construct imported_module or imported_declaration DIE. /// \brief Construct imported_module or imported_declaration DIE.
void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU, void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
const MDImportedEntity *N); const DIImportedEntity *N);
/// \brief Register a source line with debug info. Returns the unique /// \brief Register a source line with debug info. Returns the unique
/// label that was emitted and which provides correspondence to the /// label that was emitted and which provides correspondence to the
@ -470,7 +470,7 @@ class DwarfDebug : public AsmPrinterHandler {
void identifyScopeMarkers(); void identifyScopeMarkers();
/// \brief Populate LexicalScope entries with variables' info. /// \brief Populate LexicalScope entries with variables' info.
void collectVariableInfo(DwarfCompileUnit &TheCU, const MDSubprogram *SP, void collectVariableInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
DenseSet<InlinedVariable> &ProcessedVars); DenseSet<InlinedVariable> &ProcessedVars);
/// \brief Build the location list for all DBG_VALUEs in the /// \brief Build the location list for all DBG_VALUEs in the
@ -522,7 +522,7 @@ public:
/// \brief Add a DIE to the set of types that we're going to pull into /// \brief Add a DIE to the set of types that we're going to pull into
/// type units. /// type units.
void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
DIE &Die, const MDCompositeType *CTy); DIE &Die, const DICompositeType *CTy);
/// \brief Add a label so that arange data can be generated for it. /// \brief Add a label so that arange data can be generated for it.
void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); } void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
@ -566,7 +566,7 @@ public:
void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry); void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry);
/// Find the MDNode for the given reference. /// Find the MDNode for the given reference.
template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const { template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
return Ref.resolve(TypeIdentifierMap); return Ref.resolve(TypeIdentifierMap);
} }
@ -583,7 +583,7 @@ public:
/// or another context nested inside a subprogram. /// or another context nested inside a subprogram.
bool isSubprogramContext(const MDNode *Context); bool isSubprogramContext(const MDNode *Context);
void addSubprogramNames(const MDSubprogram *SP, DIE &Die); void addSubprogramNames(const DISubprogram *SP, DIE &Die);
AddressPool &getAddressPool() { return AddrPool; } AddressPool &getAddressPool() { return AddrPool; }

View File

@ -192,7 +192,7 @@ static unsigned getOffsetOrZero(unsigned OffsetInBits,
return OffsetInBits; return OffsetInBits;
} }
bool DwarfExpression::AddMachineRegExpression(const MDExpression *Expr, bool DwarfExpression::AddMachineRegExpression(const DIExpression *Expr,
unsigned MachineReg, unsigned MachineReg,
unsigned PieceOffsetInBits) { unsigned PieceOffsetInBits) {
auto I = Expr->expr_op_begin(); auto I = Expr->expr_op_begin();
@ -240,8 +240,8 @@ bool DwarfExpression::AddMachineRegExpression(const MDExpression *Expr,
return true; return true;
} }
void DwarfExpression::AddExpression(MDExpression::expr_op_iterator I, void DwarfExpression::AddExpression(DIExpression::expr_op_iterator I,
MDExpression::expr_op_iterator E, DIExpression::expr_op_iterator E,
unsigned PieceOffsetInBits) { unsigned PieceOffsetInBits) {
for (; I != E; ++I) { for (; I != E; ++I) {
switch (I->getOp()) { switch (I->getOp()) {

View File

@ -93,13 +93,13 @@ public:
/// \param PieceOffsetInBits If this is one piece out of a fragmented /// \param PieceOffsetInBits If this is one piece out of a fragmented
/// location, this is the offset of the piece inside the entire variable. /// location, this is the offset of the piece inside the entire variable.
/// \return false if no DWARF register exists for MachineReg. /// \return false if no DWARF register exists for MachineReg.
bool AddMachineRegExpression(const MDExpression *Expr, unsigned MachineReg, bool AddMachineRegExpression(const DIExpression *Expr, unsigned MachineReg,
unsigned PieceOffsetInBits = 0); unsigned PieceOffsetInBits = 0);
/// Emit a the operations remaining the DIExpressionIterator I. /// Emit a the operations remaining the DIExpressionIterator I.
/// \param PieceOffsetInBits If this is one piece out of a fragmented /// \param PieceOffsetInBits If this is one piece out of a fragmented
/// location, this is the offset of the piece inside the entire variable. /// location, this is the offset of the piece inside the entire variable.
void AddExpression(MDExpression::expr_op_iterator I, void AddExpression(DIExpression::expr_op_iterator I,
MDExpression::expr_op_iterator E, DIExpression::expr_op_iterator E,
unsigned PieceOffsetInBits = 0); unsigned PieceOffsetInBits = 0);
}; };

View File

@ -137,7 +137,7 @@ void DwarfFile::emitStrings(const MCSection *StrSection,
bool DwarfFile::addScopeVariable(LexicalScope *LS, DbgVariable *Var) { bool DwarfFile::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
SmallVectorImpl<DbgVariable *> &Vars = ScopeVariables[LS]; SmallVectorImpl<DbgVariable *> &Vars = ScopeVariables[LS];
const MDLocalVariable *DV = Var->getVariable(); const DILocalVariable *DV = Var->getVariable();
// Variables with positive arg numbers are parameters. // Variables with positive arg numbers are parameters.
if (unsigned ArgNum = DV->getArg()) { if (unsigned ArgNum = DV->getArg()) {
// Keep all parameters in order at the start of the variable list to ensure // Keep all parameters in order at the start of the variable list to ensure

View File

@ -56,7 +56,7 @@ class DwarfFile {
/// Maps MDNodes for type system with the corresponding DIEs. These DIEs can /// Maps MDNodes for type system with the corresponding DIEs. These DIEs can
/// be shared across CUs, that is why we keep the map here instead /// be shared across CUs, that is why we keep the map here instead
/// of in DwarfCompileUnit. /// of in DwarfCompileUnit.
DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap; DenseMap<const MDNode *, DIE *> DITypeNodeToDieMap;
public: public:
DwarfFile(AsmPrinter *AP, StringRef Pref, BumpPtrAllocator &DA); DwarfFile(AsmPrinter *AP, StringRef Pref, BumpPtrAllocator &DA);
@ -103,10 +103,10 @@ public:
} }
void insertDIE(const MDNode *TypeMD, DIE *Die) { void insertDIE(const MDNode *TypeMD, DIE *Die) {
MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die)); DITypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
} }
DIE *getDIE(const MDNode *TypeMD) { DIE *getDIE(const MDNode *TypeMD) {
return MDTypeNodeToDieMap.lookup(TypeMD); return DITypeNodeToDieMap.lookup(TypeMD);
} }
}; };
} }

View File

@ -64,7 +64,7 @@ bool DIEDwarfExpression::isFrameRegister(unsigned MachineReg) {
} }
DwarfUnit::DwarfUnit(unsigned UID, dwarf::Tag UnitTag, DwarfUnit::DwarfUnit(unsigned UID, dwarf::Tag UnitTag,
const MDCompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW,
DwarfFile *DWU) DwarfFile *DWU)
: UniqueID(UID), CUNode(Node), UnitDie(UnitTag), DebugInfoOffset(0), Asm(A), : UniqueID(UID), CUNode(Node), UnitDie(UnitTag), DebugInfoOffset(0), Asm(A),
DD(DW), DU(DWU), IndexTyDie(nullptr), Section(nullptr) { DD(DW), DU(DWU), IndexTyDie(nullptr), Section(nullptr) {
@ -161,7 +161,7 @@ int64_t DwarfUnit::getDefaultLowerBound() const {
} }
/// Check whether the DIE for this MDNode can be shared across CUs. /// Check whether the DIE for this MDNode can be shared across CUs.
static bool isShareableAcrossCUs(const DebugNode *D) { static bool isShareableAcrossCUs(const DINode *D) {
// When the MDNode can be part of the type system, the DIE can be shared // When the MDNode can be part of the type system, the DIE can be shared
// across CUs. // across CUs.
// Combining type units and cross-CU DIE sharing is lower value (since // Combining type units and cross-CU DIE sharing is lower value (since
@ -169,18 +169,18 @@ static bool isShareableAcrossCUs(const DebugNode *D) {
// level already) but may be implementable for some value in projects // level already) but may be implementable for some value in projects
// building multiple independent libraries with LTO and then linking those // building multiple independent libraries with LTO and then linking those
// together. // together.
return (isa<MDType>(D) || return (isa<DIType>(D) ||
(isa<MDSubprogram>(D) && !cast<MDSubprogram>(D)->isDefinition())) && (isa<DISubprogram>(D) && !cast<DISubprogram>(D)->isDefinition())) &&
!GenerateDwarfTypeUnits; !GenerateDwarfTypeUnits;
} }
DIE *DwarfUnit::getDIE(const DebugNode *D) const { DIE *DwarfUnit::getDIE(const DINode *D) const {
if (isShareableAcrossCUs(D)) if (isShareableAcrossCUs(D))
return DU->getDIE(D); return DU->getDIE(D);
return MDNodeToDieMap.lookup(D); return MDNodeToDieMap.lookup(D);
} }
void DwarfUnit::insertDIE(const DebugNode *Desc, DIE *D) { void DwarfUnit::insertDIE(const DINode *Desc, DIE *D) {
if (isShareableAcrossCUs(Desc)) { if (isShareableAcrossCUs(Desc)) {
DU->insertDIE(Desc, D); DU->insertDIE(Desc, D);
return; return;
@ -320,7 +320,7 @@ void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute,
Entry); Entry);
} }
DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DebugNode *N) { DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) {
assert(Tag != dwarf::DW_TAG_auto_variable && assert(Tag != dwarf::DW_TAG_auto_variable &&
Tag != dwarf::DW_TAG_arg_variable); Tag != dwarf::DW_TAG_arg_variable);
Parent.addChild(make_unique<DIE>((dwarf::Tag)Tag)); Parent.addChild(make_unique<DIE>((dwarf::Tag)Tag));
@ -354,38 +354,38 @@ void DwarfUnit::addSourceLine(DIE &Die, unsigned Line, StringRef File,
addUInt(Die, dwarf::DW_AT_decl_line, None, Line); addUInt(Die, dwarf::DW_AT_decl_line, None, Line);
} }
void DwarfUnit::addSourceLine(DIE &Die, const MDLocalVariable *V) { void DwarfUnit::addSourceLine(DIE &Die, const DILocalVariable *V) {
assert(V); assert(V);
addSourceLine(Die, V->getLine(), V->getScope()->getFilename(), addSourceLine(Die, V->getLine(), V->getScope()->getFilename(),
V->getScope()->getDirectory()); V->getScope()->getDirectory());
} }
void DwarfUnit::addSourceLine(DIE &Die, const MDGlobalVariable *G) { void DwarfUnit::addSourceLine(DIE &Die, const DIGlobalVariable *G) {
assert(G); assert(G);
addSourceLine(Die, G->getLine(), G->getFilename(), G->getDirectory()); addSourceLine(Die, G->getLine(), G->getFilename(), G->getDirectory());
} }
void DwarfUnit::addSourceLine(DIE &Die, const MDSubprogram *SP) { void DwarfUnit::addSourceLine(DIE &Die, const DISubprogram *SP) {
assert(SP); assert(SP);
addSourceLine(Die, SP->getLine(), SP->getFilename(), SP->getDirectory()); addSourceLine(Die, SP->getLine(), SP->getFilename(), SP->getDirectory());
} }
void DwarfUnit::addSourceLine(DIE &Die, const MDType *Ty) { void DwarfUnit::addSourceLine(DIE &Die, const DIType *Ty) {
assert(Ty); assert(Ty);
addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory()); addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory());
} }
void DwarfUnit::addSourceLine(DIE &Die, const MDObjCProperty *Ty) { void DwarfUnit::addSourceLine(DIE &Die, const DIObjCProperty *Ty) {
assert(Ty); assert(Ty);
addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory()); addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory());
} }
void DwarfUnit::addSourceLine(DIE &Die, const MDNamespace *NS) { void DwarfUnit::addSourceLine(DIE &Die, const DINamespace *NS) {
addSourceLine(Die, NS->getLine(), NS->getFilename(), NS->getDirectory()); addSourceLine(Die, NS->getLine(), NS->getFilename(), NS->getDirectory());
} }
@ -459,27 +459,27 @@ bool DwarfUnit::addRegisterOffset(DIELoc &TheDie, unsigned Reg,
void DwarfUnit::addBlockByrefAddress(const DbgVariable &DV, DIE &Die, void DwarfUnit::addBlockByrefAddress(const DbgVariable &DV, DIE &Die,
dwarf::Attribute Attribute, dwarf::Attribute Attribute,
const MachineLocation &Location) { const MachineLocation &Location) {
const MDType *Ty = DV.getType(); const DIType *Ty = DV.getType();
const MDType *TmpTy = Ty; const DIType *TmpTy = Ty;
uint16_t Tag = Ty->getTag(); uint16_t Tag = Ty->getTag();
bool isPointer = false; bool isPointer = false;
StringRef varName = DV.getName(); StringRef varName = DV.getName();
if (Tag == dwarf::DW_TAG_pointer_type) { if (Tag == dwarf::DW_TAG_pointer_type) {
auto *DTy = cast<MDDerivedType>(Ty); auto *DTy = cast<DIDerivedType>(Ty);
TmpTy = resolve(DTy->getBaseType()); TmpTy = resolve(DTy->getBaseType());
isPointer = true; isPointer = true;
} }
// Find the __forwarding field and the variable field in the __Block_byref // Find the __forwarding field and the variable field in the __Block_byref
// struct. // struct.
DebugNodeArray Fields = cast<MDCompositeTypeBase>(TmpTy)->getElements(); DINodeArray Fields = cast<DICompositeTypeBase>(TmpTy)->getElements();
const MDDerivedType *varField = nullptr; const DIDerivedType *varField = nullptr;
const MDDerivedType *forwardingField = nullptr; const DIDerivedType *forwardingField = nullptr;
for (unsigned i = 0, N = Fields.size(); i < N; ++i) { for (unsigned i = 0, N = Fields.size(); i < N; ++i) {
auto *DT = cast<MDDerivedType>(Fields[i]); auto *DT = cast<DIDerivedType>(Fields[i]);
StringRef fieldName = DT->getName(); StringRef fieldName = DT->getName();
if (fieldName == "__forwarding") if (fieldName == "__forwarding")
forwardingField = DT; forwardingField = DT;
@ -534,8 +534,8 @@ void DwarfUnit::addBlockByrefAddress(const DbgVariable &DV, DIE &Die,
} }
/// Return true if type encoding is unsigned. /// Return true if type encoding is unsigned.
static bool isUnsignedDIType(DwarfDebug *DD, const MDType *Ty) { static bool isUnsignedDIType(DwarfDebug *DD, const DIType *Ty) {
if (auto *DTy = dyn_cast<MDDerivedTypeBase>(Ty)) { if (auto *DTy = dyn_cast<DIDerivedTypeBase>(Ty)) {
dwarf::Tag T = (dwarf::Tag)Ty->getTag(); dwarf::Tag T = (dwarf::Tag)Ty->getTag();
// Encode pointer constants as unsigned bytes. This is used at least for // Encode pointer constants as unsigned bytes. This is used at least for
// null pointer constant emission. // null pointer constant emission.
@ -557,7 +557,7 @@ static bool isUnsignedDIType(DwarfDebug *DD, const MDType *Ty) {
T == dwarf::DW_TAG_volatile_type || T == dwarf::DW_TAG_volatile_type ||
T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_restrict_type ||
T == dwarf::DW_TAG_enumeration_type); T == dwarf::DW_TAG_enumeration_type);
if (MDTypeRef Deriv = DTy->getBaseType()) if (DITypeRef Deriv = DTy->getBaseType())
return isUnsignedDIType(DD, DD->resolve(Deriv)); return isUnsignedDIType(DD, DD->resolve(Deriv));
// FIXME: Enums without a fixed underlying type have unknown signedness // FIXME: Enums without a fixed underlying type have unknown signedness
// here, leading to incorrectly emitted constants. // here, leading to incorrectly emitted constants.
@ -565,7 +565,7 @@ static bool isUnsignedDIType(DwarfDebug *DD, const MDType *Ty) {
return false; return false;
} }
auto *BTy = cast<MDBasicType>(Ty); auto *BTy = cast<DIBasicType>(Ty);
unsigned Encoding = BTy->getEncoding(); unsigned Encoding = BTy->getEncoding();
assert((Encoding == dwarf::DW_ATE_unsigned || assert((Encoding == dwarf::DW_ATE_unsigned ||
Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf::DW_ATE_unsigned_char ||
@ -583,7 +583,7 @@ static bool isUnsignedDIType(DwarfDebug *DD, const MDType *Ty) {
} }
/// If this type is derived from a base type then return base type size. /// If this type is derived from a base type then return base type size.
static uint64_t getBaseTypeSize(DwarfDebug *DD, const MDDerivedType *Ty) { static uint64_t getBaseTypeSize(DwarfDebug *DD, const DIDerivedType *Ty) {
unsigned Tag = Ty->getTag(); unsigned Tag = Ty->getTag();
if (Tag != dwarf::DW_TAG_member && Tag != dwarf::DW_TAG_typedef && if (Tag != dwarf::DW_TAG_member && Tag != dwarf::DW_TAG_typedef &&
@ -602,7 +602,7 @@ static uint64_t getBaseTypeSize(DwarfDebug *DD, const MDDerivedType *Ty) {
BaseType->getTag() == dwarf::DW_TAG_rvalue_reference_type) BaseType->getTag() == dwarf::DW_TAG_rvalue_reference_type)
return Ty->getSizeInBits(); return Ty->getSizeInBits();
if (auto *DT = dyn_cast<MDDerivedType>(BaseType)) if (auto *DT = dyn_cast<DIDerivedType>(BaseType))
return getBaseTypeSize(DD, DT); return getBaseTypeSize(DD, DT);
return BaseType->getSizeInBits(); return BaseType->getSizeInBits();
@ -636,12 +636,12 @@ void DwarfUnit::addConstantFPValue(DIE &Die, const ConstantFP *CFP) {
} }
void DwarfUnit::addConstantValue(DIE &Die, const ConstantInt *CI, void DwarfUnit::addConstantValue(DIE &Die, const ConstantInt *CI,
const MDType *Ty) { const DIType *Ty) {
addConstantValue(Die, CI->getValue(), Ty); addConstantValue(Die, CI->getValue(), Ty);
} }
void DwarfUnit::addConstantValue(DIE &Die, const MachineOperand &MO, void DwarfUnit::addConstantValue(DIE &Die, const MachineOperand &MO,
const MDType *Ty) { const DIType *Ty) {
assert(MO.isImm() && "Invalid machine operand!"); assert(MO.isImm() && "Invalid machine operand!");
addConstantValue(Die, isUnsignedDIType(DD, Ty), MO.getImm()); addConstantValue(Die, isUnsignedDIType(DD, Ty), MO.getImm());
@ -654,7 +654,7 @@ void DwarfUnit::addConstantValue(DIE &Die, bool Unsigned, uint64_t Val) {
Unsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata, Val); Unsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata, Val);
} }
void DwarfUnit::addConstantValue(DIE &Die, const APInt &Val, const MDType *Ty) { void DwarfUnit::addConstantValue(DIE &Die, const APInt &Val, const DIType *Ty) {
addConstantValue(Die, Val, isUnsignedDIType(DD, Ty)); addConstantValue(Die, Val, isUnsignedDIType(DD, Ty));
} }
@ -695,29 +695,29 @@ void DwarfUnit::addLinkageName(DIE &Die, StringRef LinkageName) {
GlobalValue::getRealLinkageName(LinkageName)); GlobalValue::getRealLinkageName(LinkageName));
} }
void DwarfUnit::addTemplateParams(DIE &Buffer, DebugNodeArray TParams) { void DwarfUnit::addTemplateParams(DIE &Buffer, DINodeArray TParams) {
// Add template parameters. // Add template parameters.
for (const auto *Element : TParams) { for (const auto *Element : TParams) {
if (auto *TTP = dyn_cast<MDTemplateTypeParameter>(Element)) if (auto *TTP = dyn_cast<DITemplateTypeParameter>(Element))
constructTemplateTypeParameterDIE(Buffer, TTP); constructTemplateTypeParameterDIE(Buffer, TTP);
else if (auto *TVP = dyn_cast<MDTemplateValueParameter>(Element)) else if (auto *TVP = dyn_cast<DITemplateValueParameter>(Element))
constructTemplateValueParameterDIE(Buffer, TVP); constructTemplateValueParameterDIE(Buffer, TVP);
} }
} }
DIE *DwarfUnit::getOrCreateContextDIE(const MDScope *Context) { DIE *DwarfUnit::getOrCreateContextDIE(const DIScope *Context) {
if (!Context || isa<MDFile>(Context)) if (!Context || isa<DIFile>(Context))
return &getUnitDie(); return &getUnitDie();
if (auto *T = dyn_cast<MDType>(Context)) if (auto *T = dyn_cast<DIType>(Context))
return getOrCreateTypeDIE(T); return getOrCreateTypeDIE(T);
if (auto *NS = dyn_cast<MDNamespace>(Context)) if (auto *NS = dyn_cast<DINamespace>(Context))
return getOrCreateNameSpace(NS); return getOrCreateNameSpace(NS);
if (auto *SP = dyn_cast<MDSubprogram>(Context)) if (auto *SP = dyn_cast<DISubprogram>(Context))
return getOrCreateSubprogramDIE(SP); return getOrCreateSubprogramDIE(SP);
return getDIE(Context); return getDIE(Context);
} }
DIE *DwarfUnit::createTypeDIE(const MDCompositeType *Ty) { DIE *DwarfUnit::createTypeDIE(const DICompositeType *Ty) {
auto *Context = resolve(Ty->getScope()); auto *Context = resolve(Ty->getScope());
DIE *ContextDIE = getOrCreateContextDIE(Context); DIE *ContextDIE = getOrCreateContextDIE(Context);
@ -727,7 +727,7 @@ DIE *DwarfUnit::createTypeDIE(const MDCompositeType *Ty) {
// Create new type. // Create new type.
DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty); DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);
constructTypeDIE(TyDIE, cast<MDCompositeType>(Ty)); constructTypeDIE(TyDIE, cast<DICompositeType>(Ty));
updateAcceleratorTables(Context, Ty, TyDIE); updateAcceleratorTables(Context, Ty, TyDIE);
return &TyDIE; return &TyDIE;
@ -737,14 +737,13 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
if (!TyNode) if (!TyNode)
return nullptr; return nullptr;
auto *Ty = cast<MDType>(TyNode); auto *Ty = cast<DIType>(TyNode);
assert(Ty == resolve(Ty->getRef()) && assert(Ty == resolve(Ty->getRef()) &&
"type was not uniqued, possible ODR violation."); "type was not uniqued, possible ODR violation.");
// DW_TAG_restrict_type is not supported in DWARF2 // DW_TAG_restrict_type is not supported in DWARF2
if (Ty->getTag() == dwarf::DW_TAG_restrict_type && DD->getDwarfVersion() <= 2) if (Ty->getTag() == dwarf::DW_TAG_restrict_type && DD->getDwarfVersion() <= 2)
return getOrCreateTypeDIE( return getOrCreateTypeDIE(resolve(cast<DIDerivedType>(Ty)->getBaseType()));
resolve(cast<MDDerivedType>(Ty)->getBaseType()));
// Construct the context before querying for the existence of the DIE in case // Construct the context before querying for the existence of the DIE in case
// such construction creates the DIE. // such construction creates the DIE.
@ -760,11 +759,11 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
updateAcceleratorTables(Context, Ty, TyDIE); updateAcceleratorTables(Context, Ty, TyDIE);
if (auto *BT = dyn_cast<MDBasicType>(Ty)) if (auto *BT = dyn_cast<DIBasicType>(Ty))
constructTypeDIE(TyDIE, BT); constructTypeDIE(TyDIE, BT);
else if (auto *STy = dyn_cast<MDSubroutineType>(Ty)) else if (auto *STy = dyn_cast<DISubroutineType>(Ty))
constructTypeDIE(TyDIE, STy); constructTypeDIE(TyDIE, STy);
else if (auto *CTy = dyn_cast<MDCompositeType>(Ty)) { else if (auto *CTy = dyn_cast<DICompositeType>(Ty)) {
if (GenerateDwarfTypeUnits && !Ty->isForwardDecl()) if (GenerateDwarfTypeUnits && !Ty->isForwardDecl())
if (MDString *TypeId = CTy->getRawIdentifier()) { if (MDString *TypeId = CTy->getRawIdentifier()) {
DD->addDwarfTypeUnitType(getCU(), TypeId->getString(), TyDIE, CTy); DD->addDwarfTypeUnitType(getCU(), TypeId->getString(), TyDIE, CTy);
@ -773,17 +772,17 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
} }
constructTypeDIE(TyDIE, CTy); constructTypeDIE(TyDIE, CTy);
} else { } else {
constructTypeDIE(TyDIE, cast<MDDerivedType>(Ty)); constructTypeDIE(TyDIE, cast<DIDerivedType>(Ty));
} }
return &TyDIE; return &TyDIE;
} }
void DwarfUnit::updateAcceleratorTables(const MDScope *Context, void DwarfUnit::updateAcceleratorTables(const DIScope *Context,
const MDType *Ty, const DIE &TyDIE) { const DIType *Ty, const DIE &TyDIE) {
if (!Ty->getName().empty() && !Ty->isForwardDecl()) { if (!Ty->getName().empty() && !Ty->isForwardDecl()) {
bool IsImplementation = 0; bool IsImplementation = 0;
if (auto *CT = dyn_cast<MDCompositeTypeBase>(Ty)) { if (auto *CT = dyn_cast<DICompositeTypeBase>(Ty)) {
// A runtime language of 0 actually means C/C++ and that any // A runtime language of 0 actually means C/C++ and that any
// non-negative value is some version of Objective-C/C++. // non-negative value is some version of Objective-C/C++.
IsImplementation = CT->getRuntimeLang() == 0 || CT->isObjcClassComplete(); IsImplementation = CT->getRuntimeLang() == 0 || CT->isObjcClassComplete();
@ -791,13 +790,13 @@ void DwarfUnit::updateAcceleratorTables(const MDScope *Context,
unsigned Flags = IsImplementation ? dwarf::DW_FLAG_type_implementation : 0; unsigned Flags = IsImplementation ? dwarf::DW_FLAG_type_implementation : 0;
DD->addAccelType(Ty->getName(), TyDIE, Flags); DD->addAccelType(Ty->getName(), TyDIE, Flags);
if (!Context || isa<MDCompileUnit>(Context) || isa<MDFile>(Context) || if (!Context || isa<DICompileUnit>(Context) || isa<DIFile>(Context) ||
isa<MDNamespace>(Context)) isa<DINamespace>(Context))
addGlobalType(Ty, TyDIE, Context); addGlobalType(Ty, TyDIE, Context);
} }
} }
void DwarfUnit::addType(DIE &Entity, const MDType *Ty, void DwarfUnit::addType(DIE &Entity, const DIType *Ty,
dwarf::Attribute Attribute) { dwarf::Attribute Attribute) {
assert(Ty && "Trying to add a type that doesn't exist?"); assert(Ty && "Trying to add a type that doesn't exist?");
@ -818,7 +817,7 @@ void DwarfUnit::addType(DIE &Entity, const MDType *Ty,
addDIEEntry(Entity, Attribute, Entry); addDIEEntry(Entity, Attribute, Entry);
} }
std::string DwarfUnit::getParentContextString(const MDScope *Context) const { std::string DwarfUnit::getParentContextString(const DIScope *Context) const {
if (!Context) if (!Context)
return ""; return "";
@ -827,8 +826,8 @@ std::string DwarfUnit::getParentContextString(const MDScope *Context) const {
return ""; return "";
std::string CS; std::string CS;
SmallVector<const MDScope *, 1> Parents; SmallVector<const DIScope *, 1> Parents;
while (!isa<MDCompileUnit>(Context)) { while (!isa<DICompileUnit>(Context)) {
Parents.push_back(Context); Parents.push_back(Context);
if (Context->getScope()) if (Context->getScope())
Context = resolve(Context->getScope()); Context = resolve(Context->getScope());
@ -841,9 +840,9 @@ std::string DwarfUnit::getParentContextString(const MDScope *Context) const {
// Reverse iterate over our list to go from the outermost construct to the // Reverse iterate over our list to go from the outermost construct to the
// innermost. // innermost.
for (auto I = Parents.rbegin(), E = Parents.rend(); I != E; ++I) { for (auto I = Parents.rbegin(), E = Parents.rend(); I != E; ++I) {
const MDScope *Ctx = *I; const DIScope *Ctx = *I;
StringRef Name = Ctx->getName(); StringRef Name = Ctx->getName();
if (Name.empty() && isa<MDNamespace>(Ctx)) if (Name.empty() && isa<DINamespace>(Ctx))
Name = "(anonymous namespace)"; Name = "(anonymous namespace)";
if (!Name.empty()) { if (!Name.empty()) {
CS += Name; CS += Name;
@ -853,7 +852,7 @@ std::string DwarfUnit::getParentContextString(const MDScope *Context) const {
return CS; return CS;
} }
void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDBasicType *BTy) { void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIBasicType *BTy) {
// Get core information. // Get core information.
StringRef Name = BTy->getName(); StringRef Name = BTy->getName();
// Add name if not anonymous or intermediate type. // Add name if not anonymous or intermediate type.
@ -871,14 +870,14 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDBasicType *BTy) {
addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size); addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size);
} }
void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDDerivedType *DTy) { void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy) {
// Get core information. // Get core information.
StringRef Name = DTy->getName(); StringRef Name = DTy->getName();
uint64_t Size = DTy->getSizeInBits() >> 3; uint64_t Size = DTy->getSizeInBits() >> 3;
uint16_t Tag = Buffer.getTag(); uint16_t Tag = Buffer.getTag();
// Map to main type, void will not have a type. // Map to main type, void will not have a type.
const MDType *FromTy = resolve(DTy->getBaseType()); const DIType *FromTy = resolve(DTy->getBaseType());
if (FromTy) if (FromTy)
addType(Buffer, FromTy); addType(Buffer, FromTy);
@ -894,15 +893,15 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDDerivedType *DTy) {
if (Tag == dwarf::DW_TAG_ptr_to_member_type) if (Tag == dwarf::DW_TAG_ptr_to_member_type)
addDIEEntry( addDIEEntry(
Buffer, dwarf::DW_AT_containing_type, Buffer, dwarf::DW_AT_containing_type,
*getOrCreateTypeDIE(resolve(cast<MDDerivedType>(DTy)->getClassType()))); *getOrCreateTypeDIE(resolve(cast<DIDerivedType>(DTy)->getClassType())));
// Add source line info if available and TyDesc is not a forward declaration. // Add source line info if available and TyDesc is not a forward declaration.
if (!DTy->isForwardDecl()) if (!DTy->isForwardDecl())
addSourceLine(Buffer, DTy); addSourceLine(Buffer, DTy);
} }
void DwarfUnit::constructSubprogramArguments(DIE &Buffer, MDTypeRefArray Args) { void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args) {
for (unsigned i = 1, N = Args.size(); i < N; ++i) { for (unsigned i = 1, N = Args.size(); i < N; ++i) {
const MDType *Ty = resolve(Args[i]); const DIType *Ty = resolve(Args[i]);
if (!Ty) { if (!Ty) {
assert(i == N-1 && "Unspecified parameter must be the last argument"); assert(i == N-1 && "Unspecified parameter must be the last argument");
createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer); createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
@ -915,9 +914,9 @@ void DwarfUnit::constructSubprogramArguments(DIE &Buffer, MDTypeRefArray Args) {
} }
} }
void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDSubroutineType *CTy) { void DwarfUnit::constructTypeDIE(DIE &Buffer, const DISubroutineType *CTy) {
// Add return type. A void return won't have a type. // Add return type. A void return won't have a type.
auto Elements = cast<MDSubroutineType>(CTy)->getTypeArray(); auto Elements = cast<DISubroutineType>(CTy)->getTypeArray();
if (Elements.size()) if (Elements.size())
if (auto RTy = resolve(Elements[0])) if (auto RTy = resolve(Elements[0]))
addType(Buffer, RTy); addType(Buffer, RTy);
@ -943,7 +942,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDSubroutineType *CTy) {
addFlag(Buffer, dwarf::DW_AT_rvalue_reference); addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
} }
void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) { void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
// Add name if not anonymous or intermediate type. // Add name if not anonymous or intermediate type.
StringRef Name = CTy->getName(); StringRef Name = CTy->getName();
@ -961,13 +960,13 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
case dwarf::DW_TAG_union_type: case dwarf::DW_TAG_union_type:
case dwarf::DW_TAG_class_type: { case dwarf::DW_TAG_class_type: {
// Add elements to structure type. // Add elements to structure type.
DebugNodeArray Elements = CTy->getElements(); DINodeArray Elements = CTy->getElements();
for (const auto *Element : Elements) { for (const auto *Element : Elements) {
if (!Element) if (!Element)
continue; continue;
if (auto *SP = dyn_cast<MDSubprogram>(Element)) if (auto *SP = dyn_cast<DISubprogram>(Element))
getOrCreateSubprogramDIE(SP); getOrCreateSubprogramDIE(SP);
else if (auto *DDTy = dyn_cast<MDDerivedType>(Element)) { else if (auto *DDTy = dyn_cast<DIDerivedType>(Element)) {
if (DDTy->getTag() == dwarf::DW_TAG_friend) { if (DDTy->getTag() == dwarf::DW_TAG_friend) {
DIE &ElemDie = createAndAddDIE(dwarf::DW_TAG_friend, Buffer); DIE &ElemDie = createAndAddDIE(dwarf::DW_TAG_friend, Buffer);
addType(ElemDie, resolve(DDTy->getBaseType()), dwarf::DW_AT_friend); addType(ElemDie, resolve(DDTy->getBaseType()), dwarf::DW_AT_friend);
@ -976,7 +975,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
} else { } else {
constructMemberDIE(Buffer, DDTy); constructMemberDIE(Buffer, DDTy);
} }
} else if (auto *Property = dyn_cast<MDObjCProperty>(Element)) { } else if (auto *Property = dyn_cast<DIObjCProperty>(Element)) {
DIE &ElemDie = createAndAddDIE(Property->getTag(), Buffer); DIE &ElemDie = createAndAddDIE(Property->getTag(), Buffer);
StringRef PropertyName = Property->getName(); StringRef PropertyName = Property->getName();
addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName); addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
@ -1007,7 +1006,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
// This is outside the DWARF spec, but GDB expects a DW_AT_containing_type // This is outside the DWARF spec, but GDB expects a DW_AT_containing_type
// inside C++ composite types to point to the base class with the vtable. // inside C++ composite types to point to the base class with the vtable.
if (auto *ContainingType = if (auto *ContainingType =
dyn_cast_or_null<MDCompositeType>(resolve(CTy->getVTableHolder()))) dyn_cast_or_null<DICompositeType>(resolve(CTy->getVTableHolder())))
addDIEEntry(Buffer, dwarf::DW_AT_containing_type, addDIEEntry(Buffer, dwarf::DW_AT_containing_type,
*getOrCreateTypeDIE(ContainingType)); *getOrCreateTypeDIE(ContainingType));
@ -1058,7 +1057,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
} }
void DwarfUnit::constructTemplateTypeParameterDIE( void DwarfUnit::constructTemplateTypeParameterDIE(
DIE &Buffer, const MDTemplateTypeParameter *TP) { DIE &Buffer, const DITemplateTypeParameter *TP) {
DIE &ParamDIE = DIE &ParamDIE =
createAndAddDIE(dwarf::DW_TAG_template_type_parameter, Buffer); createAndAddDIE(dwarf::DW_TAG_template_type_parameter, Buffer);
// Add the type if it exists, it could be void and therefore no type. // Add the type if it exists, it could be void and therefore no type.
@ -1069,7 +1068,7 @@ void DwarfUnit::constructTemplateTypeParameterDIE(
} }
void DwarfUnit::constructTemplateValueParameterDIE( void DwarfUnit::constructTemplateValueParameterDIE(
DIE &Buffer, const MDTemplateValueParameter *VP) { DIE &Buffer, const DITemplateValueParameter *VP) {
DIE &ParamDIE = createAndAddDIE(VP->getTag(), Buffer); DIE &ParamDIE = createAndAddDIE(VP->getTag(), Buffer);
// Add the type if there is one, template template and template parameter // Add the type if there is one, template template and template parameter
@ -1100,7 +1099,7 @@ void DwarfUnit::constructTemplateValueParameterDIE(
} }
} }
DIE *DwarfUnit::getOrCreateNameSpace(const MDNamespace *NS) { DIE *DwarfUnit::getOrCreateNameSpace(const DINamespace *NS) {
// Construct the context before querying for the existence of the DIE in case // Construct the context before querying for the existence of the DIE in case
// such construction creates the DIE. // such construction creates the DIE.
DIE *ContextDIE = getOrCreateContextDIE(NS->getScope()); DIE *ContextDIE = getOrCreateContextDIE(NS->getScope());
@ -1120,7 +1119,7 @@ DIE *DwarfUnit::getOrCreateNameSpace(const MDNamespace *NS) {
return &NDie; return &NDie;
} }
DIE *DwarfUnit::getOrCreateSubprogramDIE(const MDSubprogram *SP, bool Minimal) { DIE *DwarfUnit::getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal) {
// Construct the context before querying for the existence of the DIE in case // Construct the context before querying for the existence of the DIE in case
// such construction creates the DIE (as is the case for member function // such construction creates the DIE (as is the case for member function
// declarations). // declarations).
@ -1151,7 +1150,7 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(const MDSubprogram *SP, bool Minimal) {
return &SPDie; return &SPDie;
} }
bool DwarfUnit::applySubprogramDefinitionAttributes(const MDSubprogram *SP, bool DwarfUnit::applySubprogramDefinitionAttributes(const DISubprogram *SP,
DIE &SPDie) { DIE &SPDie) {
DIE *DeclDie = nullptr; DIE *DeclDie = nullptr;
StringRef DeclLinkageName; StringRef DeclLinkageName;
@ -1183,7 +1182,7 @@ bool DwarfUnit::applySubprogramDefinitionAttributes(const MDSubprogram *SP,
return true; return true;
} }
void DwarfUnit::applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie, void DwarfUnit::applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie,
bool Minimal) { bool Minimal) {
if (!Minimal) if (!Minimal)
if (applySubprogramDefinitionAttributes(SP, SPDie)) if (applySubprogramDefinitionAttributes(SP, SPDie))
@ -1207,7 +1206,7 @@ void DwarfUnit::applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie,
Language == dwarf::DW_LANG_ObjC)) Language == dwarf::DW_LANG_ObjC))
addFlag(SPDie, dwarf::DW_AT_prototyped); addFlag(SPDie, dwarf::DW_AT_prototyped);
const MDSubroutineType *SPTy = SP->getType(); const DISubroutineType *SPTy = SP->getType();
assert(SPTy->getTag() == dwarf::DW_TAG_subroutine_type && assert(SPTy->getTag() == dwarf::DW_TAG_subroutine_type &&
"the type of a subprogram should be a subroutine"); "the type of a subprogram should be a subroutine");
@ -1269,7 +1268,7 @@ void DwarfUnit::applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie,
addFlag(SPDie, dwarf::DW_AT_explicit); addFlag(SPDie, dwarf::DW_AT_explicit);
} }
void DwarfUnit::constructSubrangeDIE(DIE &Buffer, const MDSubrange *SR, void DwarfUnit::constructSubrangeDIE(DIE &Buffer, const DISubrange *SR,
DIE *IndexTy) { DIE *IndexTy) {
DIE &DW_Subrange = createAndAddDIE(dwarf::DW_TAG_subrange_type, Buffer); DIE &DW_Subrange = createAndAddDIE(dwarf::DW_TAG_subrange_type, Buffer);
addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IndexTy); addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IndexTy);
@ -1303,7 +1302,7 @@ DIE *DwarfUnit::getIndexTyDie() {
return IndexTyDie; return IndexTyDie;
} }
void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const MDCompositeType *CTy) { void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
if (CTy->isVector()) if (CTy->isVector())
addFlag(Buffer, dwarf::DW_AT_GNU_vector); addFlag(Buffer, dwarf::DW_AT_GNU_vector);
@ -1316,21 +1315,21 @@ void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
DIE *IdxTy = getIndexTyDie(); DIE *IdxTy = getIndexTyDie();
// Add subranges to array type. // Add subranges to array type.
DebugNodeArray Elements = CTy->getElements(); DINodeArray Elements = CTy->getElements();
for (unsigned i = 0, N = Elements.size(); i < N; ++i) { for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
// FIXME: Should this really be such a loose cast? // FIXME: Should this really be such a loose cast?
if (auto *Element = dyn_cast_or_null<DebugNode>(Elements[i])) if (auto *Element = dyn_cast_or_null<DINode>(Elements[i]))
if (Element->getTag() == dwarf::DW_TAG_subrange_type) if (Element->getTag() == dwarf::DW_TAG_subrange_type)
constructSubrangeDIE(Buffer, cast<MDSubrange>(Element), IdxTy); constructSubrangeDIE(Buffer, cast<DISubrange>(Element), IdxTy);
} }
} }
void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const MDCompositeType *CTy) { void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
DebugNodeArray Elements = CTy->getElements(); DINodeArray Elements = CTy->getElements();
// Add enumerators to enumeration type. // Add enumerators to enumeration type.
for (unsigned i = 0, N = Elements.size(); i < N; ++i) { for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
auto *Enum = dyn_cast_or_null<MDEnumerator>(Elements[i]); auto *Enum = dyn_cast_or_null<DIEnumerator>(Elements[i]);
if (Enum) { if (Enum) {
DIE &Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer); DIE &Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer);
StringRef Name = Enum->getName(); StringRef Name = Enum->getName();
@ -1340,7 +1339,7 @@ void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
Value); Value);
} }
} }
const MDType *DTy = resolve(CTy->getBaseType()); const DIType *DTy = resolve(CTy->getBaseType());
if (DTy) { if (DTy) {
addType(Buffer, DTy); addType(Buffer, DTy);
addFlag(Buffer, dwarf::DW_AT_enum_class); addFlag(Buffer, dwarf::DW_AT_enum_class);
@ -1351,7 +1350,7 @@ void DwarfUnit::constructContainingTypeDIEs() {
for (auto CI = ContainingTypeMap.begin(), CE = ContainingTypeMap.end(); for (auto CI = ContainingTypeMap.begin(), CE = ContainingTypeMap.end();
CI != CE; ++CI) { CI != CE; ++CI) {
DIE &SPDie = *CI->first; DIE &SPDie = *CI->first;
const DebugNode *D = CI->second; const DINode *D = CI->second;
if (!D) if (!D)
continue; continue;
DIE *NDie = getDIE(D); DIE *NDie = getDIE(D);
@ -1361,7 +1360,7 @@ void DwarfUnit::constructContainingTypeDIEs() {
} }
} }
void DwarfUnit::constructMemberDIE(DIE &Buffer, const MDDerivedType *DT) { void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) {
DIE &MemberDie = createAndAddDIE(DT->getTag(), Buffer); DIE &MemberDie = createAndAddDIE(DT->getTag(), Buffer);
StringRef Name = DT->getName(); StringRef Name = DT->getName();
if (!Name.empty()) if (!Name.empty())
@ -1449,7 +1448,7 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, const MDDerivedType *DT) {
addFlag(MemberDie, dwarf::DW_AT_artificial); addFlag(MemberDie, dwarf::DW_AT_artificial);
} }
DIE *DwarfUnit::getOrCreateStaticMemberDIE(const MDDerivedType *DT) { DIE *DwarfUnit::getOrCreateStaticMemberDIE(const DIDerivedType *DT) {
if (!DT) if (!DT)
return nullptr; return nullptr;
@ -1464,7 +1463,7 @@ DIE *DwarfUnit::getOrCreateStaticMemberDIE(const MDDerivedType *DT) {
DIE &StaticMemberDIE = createAndAddDIE(DT->getTag(), *ContextDIE, DT); DIE &StaticMemberDIE = createAndAddDIE(DT->getTag(), *ContextDIE, DT);
const MDType *Ty = resolve(DT->getBaseType()); const DIType *Ty = resolve(DT->getBaseType());
addString(StaticMemberDIE, dwarf::DW_AT_name, DT->getName()); addString(StaticMemberDIE, dwarf::DW_AT_name, DT->getName());
addType(StaticMemberDIE, Ty); addType(StaticMemberDIE, Ty);

View File

@ -71,7 +71,7 @@ protected:
unsigned UniqueID; unsigned UniqueID;
/// MDNode for the compile unit. /// MDNode for the compile unit.
const MDCompileUnit *CUNode; const DICompileUnit *CUNode;
/// Unit debug information entry. /// Unit debug information entry.
DIE UnitDie; DIE UnitDie;
@ -106,7 +106,7 @@ protected:
/// This map is used to keep track of subprogram DIEs that need /// This map is used to keep track of subprogram DIEs that need
/// DW_AT_containing_type attribute. This attribute points to a DIE that /// DW_AT_containing_type attribute. This attribute points to a DIE that
/// corresponds to the MDNode mapped with the subprogram DIE. /// corresponds to the MDNode mapped with the subprogram DIE.
DenseMap<DIE *, const DebugNode *> ContainingTypeMap; DenseMap<DIE *, const DINode *> ContainingTypeMap;
// All DIEValues are allocated through this allocator. // All DIEValues are allocated through this allocator.
BumpPtrAllocator DIEValueAllocator; BumpPtrAllocator DIEValueAllocator;
@ -117,7 +117,7 @@ protected:
/// The section this unit will be emitted in. /// The section this unit will be emitted in.
const MCSection *Section; const MCSection *Section;
DwarfUnit(unsigned UID, dwarf::Tag, const MDCompileUnit *CU, AsmPrinter *A, DwarfUnit(unsigned UID, dwarf::Tag, const DICompileUnit *CU, AsmPrinter *A,
DwarfDebug *DW, DwarfFile *DWU); DwarfDebug *DW, DwarfFile *DWU);
/// \brief Add a string attribute data and value. /// \brief Add a string attribute data and value.
@ -127,7 +127,7 @@ protected:
void addIndexedString(DIE &Die, dwarf::Attribute Attribute, StringRef Str); void addIndexedString(DIE &Die, dwarf::Attribute Attribute, StringRef Str);
bool applySubprogramDefinitionAttributes(const MDSubprogram *SP, DIE &SPDie); bool applySubprogramDefinitionAttributes(const DISubprogram *SP, DIE &SPDie);
public: public:
virtual ~DwarfUnit(); virtual ~DwarfUnit();
@ -143,7 +143,7 @@ public:
AsmPrinter* getAsmPrinter() const { return Asm; } AsmPrinter* getAsmPrinter() const { return Asm; }
unsigned getUniqueID() const { return UniqueID; } unsigned getUniqueID() const { return UniqueID; }
uint16_t getLanguage() const { return CUNode->getSourceLanguage(); } uint16_t getLanguage() const { return CUNode->getSourceLanguage(); }
const MDCompileUnit *getCUNode() const { return CUNode; } const DICompileUnit *getCUNode() const { return CUNode; }
DIE &getUnitDie() { return UnitDie; } DIE &getUnitDie() { return UnitDie; }
unsigned getDebugInfoOffset() const { return DebugInfoOffset; } unsigned getDebugInfoOffset() const { return DebugInfoOffset; }
@ -159,15 +159,15 @@ public:
/// metadata level because DIEs may not currently have been added to the /// metadata level because DIEs may not currently have been added to the
/// parent context and walking the DIEs looking for names is more expensive /// parent context and walking the DIEs looking for names is more expensive
/// than walking the metadata. /// than walking the metadata.
std::string getParentContextString(const MDScope *Context) const; std::string getParentContextString(const DIScope *Context) const;
/// Add a new global name to the compile unit. /// Add a new global name to the compile unit.
virtual void addGlobalName(StringRef Name, DIE &Die, const MDScope *Context) { virtual void addGlobalName(StringRef Name, DIE &Die, const DIScope *Context) {
} }
/// Add a new global type to the compile unit. /// Add a new global type to the compile unit.
virtual void addGlobalType(const MDType *Ty, const DIE &Die, virtual void addGlobalType(const DIType *Ty, const DIE &Die,
const MDScope *Context) {} const DIScope *Context) {}
/// \brief Add a new name to the namespace accelerator table. /// \brief Add a new name to the namespace accelerator table.
void addAccelNamespace(StringRef Name, const DIE &Die); void addAccelNamespace(StringRef Name, const DIE &Die);
@ -177,7 +177,7 @@ public:
/// We delegate the request to DwarfDebug when the MDNode can be part of the /// We delegate the request to DwarfDebug when the MDNode can be part of the
/// type system, since DIEs for the type system can be shared across CUs and /// type system, since DIEs for the type system can be shared across CUs and
/// the mappings are kept in DwarfDebug. /// the mappings are kept in DwarfDebug.
DIE *getDIE(const DebugNode *D) const; DIE *getDIE(const DINode *D) const;
/// \brief Returns a fresh newly allocated DIELoc. /// \brief Returns a fresh newly allocated DIELoc.
DIELoc *getDIELoc() { return new (DIEValueAllocator) DIELoc(); } DIELoc *getDIELoc() { return new (DIEValueAllocator) DIELoc(); }
@ -187,7 +187,7 @@ public:
/// We delegate the request to DwarfDebug when the MDNode can be part of the /// We delegate the request to DwarfDebug when the MDNode can be part of the
/// type system, since DIEs for the type system can be shared across CUs and /// type system, since DIEs for the type system can be shared across CUs and
/// the mappings are kept in DwarfDebug. /// the mappings are kept in DwarfDebug.
void insertDIE(const DebugNode *Desc, DIE *D); void insertDIE(const DINode *Desc, DIE *D);
/// \brief Add a flag that is true to the DIE. /// \brief Add a flag that is true to the DIE.
void addFlag(DIE &Die, dwarf::Attribute Attribute); void addFlag(DIE &Die, dwarf::Attribute Attribute);
@ -246,17 +246,17 @@ public:
/// \brief Add location information to specified debug information entry. /// \brief Add location information to specified debug information entry.
void addSourceLine(DIE &Die, unsigned Line, StringRef File, void addSourceLine(DIE &Die, unsigned Line, StringRef File,
StringRef Directory); StringRef Directory);
void addSourceLine(DIE &Die, const MDLocalVariable *V); void addSourceLine(DIE &Die, const DILocalVariable *V);
void addSourceLine(DIE &Die, const MDGlobalVariable *G); void addSourceLine(DIE &Die, const DIGlobalVariable *G);
void addSourceLine(DIE &Die, const MDSubprogram *SP); void addSourceLine(DIE &Die, const DISubprogram *SP);
void addSourceLine(DIE &Die, const MDType *Ty); void addSourceLine(DIE &Die, const DIType *Ty);
void addSourceLine(DIE &Die, const MDNamespace *NS); void addSourceLine(DIE &Die, const DINamespace *NS);
void addSourceLine(DIE &Die, const MDObjCProperty *Ty); void addSourceLine(DIE &Die, const DIObjCProperty *Ty);
/// \brief Add constant value entry in variable DIE. /// \brief Add constant value entry in variable DIE.
void addConstantValue(DIE &Die, const MachineOperand &MO, const MDType *Ty); void addConstantValue(DIE &Die, const MachineOperand &MO, const DIType *Ty);
void addConstantValue(DIE &Die, const ConstantInt *CI, const MDType *Ty); void addConstantValue(DIE &Die, const ConstantInt *CI, const DIType *Ty);
void addConstantValue(DIE &Die, const APInt &Val, const MDType *Ty); void addConstantValue(DIE &Die, const APInt &Val, const DIType *Ty);
void addConstantValue(DIE &Die, const APInt &Val, bool Unsigned); void addConstantValue(DIE &Die, const APInt &Val, bool Unsigned);
void addConstantValue(DIE &Die, bool Unsigned, uint64_t Val); void addConstantValue(DIE &Die, bool Unsigned, uint64_t Val);
@ -268,7 +268,7 @@ public:
void addLinkageName(DIE &Die, StringRef LinkageName); void addLinkageName(DIE &Die, StringRef LinkageName);
/// \brief Add template parameters in buffer. /// \brief Add template parameters in buffer.
void addTemplateParams(DIE &Buffer, DebugNodeArray TParams); void addTemplateParams(DIE &Buffer, DINodeArray TParams);
/// \brief Add register operand. /// \brief Add register operand.
/// \returns false if the register does not exist, e.g., because it was never /// \returns false if the register does not exist, e.g., because it was never
@ -294,33 +294,33 @@ public:
/// ///
/// This takes and attribute parameter because DW_AT_friend attributes are /// This takes and attribute parameter because DW_AT_friend attributes are
/// also type references. /// also type references.
void addType(DIE &Entity, const MDType *Ty, void addType(DIE &Entity, const DIType *Ty,
dwarf::Attribute Attribute = dwarf::DW_AT_type); dwarf::Attribute Attribute = dwarf::DW_AT_type);
DIE *getOrCreateNameSpace(const MDNamespace *NS); DIE *getOrCreateNameSpace(const DINamespace *NS);
DIE *getOrCreateSubprogramDIE(const MDSubprogram *SP, bool Minimal = false); DIE *getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal = false);
void applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie, void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie,
bool Minimal = false); bool Minimal = false);
/// \brief Find existing DIE or create new DIE for the given type. /// \brief Find existing DIE or create new DIE for the given type.
DIE *getOrCreateTypeDIE(const MDNode *N); DIE *getOrCreateTypeDIE(const MDNode *N);
/// \brief Get context owner's DIE. /// \brief Get context owner's DIE.
DIE *createTypeDIE(const MDCompositeType *Ty); DIE *createTypeDIE(const DICompositeType *Ty);
/// \brief Get context owner's DIE. /// \brief Get context owner's DIE.
DIE *getOrCreateContextDIE(const MDScope *Context); DIE *getOrCreateContextDIE(const DIScope *Context);
/// \brief Construct DIEs for types that contain vtables. /// \brief Construct DIEs for types that contain vtables.
void constructContainingTypeDIEs(); void constructContainingTypeDIEs();
/// \brief Construct function argument DIEs. /// \brief Construct function argument DIEs.
void constructSubprogramArguments(DIE &Buffer, MDTypeRefArray Args); void constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args);
/// Create a DIE with the given Tag, add the DIE to its parent, and /// Create a DIE with the given Tag, add the DIE to its parent, and
/// call insertDIE if MD is not null. /// call insertDIE if MD is not null.
DIE &createAndAddDIE(unsigned Tag, DIE &Parent, const DebugNode *N = nullptr); DIE &createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N = nullptr);
/// Compute the size of a header for this unit, not including the initial /// Compute the size of a header for this unit, not including the initial
/// length field. /// length field.
@ -335,11 +335,11 @@ public:
virtual DwarfCompileUnit &getCU() = 0; virtual DwarfCompileUnit &getCU() = 0;
void constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy); void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy);
protected: protected:
/// \brief Create new static data member DIE. /// \brief Create new static data member DIE.
DIE *getOrCreateStaticMemberDIE(const MDDerivedType *DT); DIE *getOrCreateStaticMemberDIE(const DIDerivedType *DT);
/// Look up the source ID with the given directory and source file names. If /// Look up the source ID with the given directory and source file names. If
/// none currently exists, create a new ID and insert it in the line table. /// none currently exists, create a new ID and insert it in the line table.
@ -347,22 +347,22 @@ protected:
/// \brief Look in the DwarfDebug map for the MDNode that corresponds to the /// \brief Look in the DwarfDebug map for the MDNode that corresponds to the
/// reference. /// reference.
template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const { template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
return DD->resolve(Ref); return DD->resolve(Ref);
} }
private: private:
void constructTypeDIE(DIE &Buffer, const MDBasicType *BTy); void constructTypeDIE(DIE &Buffer, const DIBasicType *BTy);
void constructTypeDIE(DIE &Buffer, const MDDerivedType *DTy); void constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy);
void constructTypeDIE(DIE &Buffer, const MDSubroutineType *DTy); void constructTypeDIE(DIE &Buffer, const DISubroutineType *DTy);
void constructSubrangeDIE(DIE &Buffer, const MDSubrange *SR, DIE *IndexTy); void constructSubrangeDIE(DIE &Buffer, const DISubrange *SR, DIE *IndexTy);
void constructArrayTypeDIE(DIE &Buffer, const MDCompositeType *CTy); void constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy);
void constructEnumTypeDIE(DIE &Buffer, const MDCompositeType *CTy); void constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy);
void constructMemberDIE(DIE &Buffer, const MDDerivedType *DT); void constructMemberDIE(DIE &Buffer, const DIDerivedType *DT);
void constructTemplateTypeParameterDIE(DIE &Buffer, void constructTemplateTypeParameterDIE(DIE &Buffer,
const MDTemplateTypeParameter *TP); const DITemplateTypeParameter *TP);
void constructTemplateValueParameterDIE(DIE &Buffer, void constructTemplateValueParameterDIE(DIE &Buffer,
const MDTemplateValueParameter *TVP); const DITemplateValueParameter *TVP);
/// \brief Return the default lower bound for an array. /// \brief Return the default lower bound for an array.
/// ///
@ -391,7 +391,7 @@ private:
/// If this is a named finished type then include it in the list of types for /// If this is a named finished type then include it in the list of types for
/// the accelerator tables. /// the accelerator tables.
void updateAcceleratorTables(const MDScope *Context, const MDType *Ty, void updateAcceleratorTables(const DIScope *Context, const DIType *Ty,
const DIE &TyDIE); const DIE &TyDIE);
virtual bool isDwoUnit() const = 0; virtual bool isDwoUnit() const = 0;

View File

@ -20,11 +20,11 @@ namespace llvm {
StringRef WinCodeViewLineTables::getFullFilepath(const MDNode *S) { StringRef WinCodeViewLineTables::getFullFilepath(const MDNode *S) {
assert(S); assert(S);
assert((isa<MDCompileUnit>(S) || isa<MDFile>(S) || isa<MDSubprogram>(S) || assert((isa<DICompileUnit>(S) || isa<DIFile>(S) || isa<DISubprogram>(S) ||
isa<MDLexicalBlockBase>(S)) && isa<DILexicalBlockBase>(S)) &&
"Unexpected scope info"); "Unexpected scope info");
auto *Scope = cast<MDScope>(S); auto *Scope = cast<DIScope>(S);
StringRef Dir = Scope->getDirectory(), StringRef Dir = Scope->getDirectory(),
Filename = Scope->getFilename(); Filename = Scope->getFilename();
char *&Result = DirAndFilenameToFilepathMap[std::make_pair(Dir, Filename)]; char *&Result = DirAndFilenameToFilepathMap[std::make_pair(Dir, Filename)];

View File

@ -1232,7 +1232,7 @@ void InlineSpiller::spillAroundUses(unsigned Reg) {
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
DEBUG(dbgs() << "Modifying debug info due to spill:" << "\t" << *MI); DEBUG(dbgs() << "Modifying debug info due to spill:" << "\t" << *MI);
MachineBasicBlock *MBB = MI->getParent(); MachineBasicBlock *MBB = MI->getParent();
assert(cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) && assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree"); "Expected inlined-at fields to agree");
BuildMI(*MBB, MBB->erase(MI), DL, TII.get(TargetOpcode::DBG_VALUE)) BuildMI(*MBB, MBB->erase(MI), DL, TII.get(TargetOpcode::DBG_VALUE))
.addFrameIndex(StackSlot) .addFrameIndex(StackSlot)

View File

@ -59,10 +59,10 @@ void LexicalScopes::extractLexicalScopes(
for (const auto &MBB : *MF) { for (const auto &MBB : *MF) {
const MachineInstr *RangeBeginMI = nullptr; const MachineInstr *RangeBeginMI = nullptr;
const MachineInstr *PrevMI = nullptr; const MachineInstr *PrevMI = nullptr;
const MDLocation *PrevDL = nullptr; const DILocation *PrevDL = nullptr;
for (const auto &MInsn : MBB) { for (const auto &MInsn : MBB) {
// Check if instruction has valid location information. // Check if instruction has valid location information.
const MDLocation *MIDL = MInsn.getDebugLoc(); const DILocation *MIDL = MInsn.getDebugLoc();
if (!MIDL) { if (!MIDL) {
PrevMI = &MInsn; PrevMI = &MInsn;
continue; continue;
@ -106,14 +106,14 @@ void LexicalScopes::extractLexicalScopes(
/// findLexicalScope - Find lexical scope, either regular or inlined, for the /// findLexicalScope - Find lexical scope, either regular or inlined, for the
/// given DebugLoc. Return NULL if not found. /// given DebugLoc. Return NULL if not found.
LexicalScope *LexicalScopes::findLexicalScope(const MDLocation *DL) { LexicalScope *LexicalScopes::findLexicalScope(const DILocation *DL) {
MDLocalScope *Scope = DL->getScope(); DILocalScope *Scope = DL->getScope();
if (!Scope) if (!Scope)
return nullptr; return nullptr;
// The scope that we were created with could have an extra file - which // The scope that we were created with could have an extra file - which
// isn't what we care about in this case. // isn't what we care about in this case.
if (auto *File = dyn_cast<MDLexicalBlockFile>(Scope)) if (auto *File = dyn_cast<DILexicalBlockFile>(Scope))
Scope = File->getScope(); Scope = File->getScope();
if (auto *IA = DL->getInlinedAt()) { if (auto *IA = DL->getInlinedAt()) {
@ -125,8 +125,8 @@ LexicalScope *LexicalScopes::findLexicalScope(const MDLocation *DL) {
/// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If /// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
/// not available then create new lexical scope. /// not available then create new lexical scope.
LexicalScope *LexicalScopes::getOrCreateLexicalScope(const MDLocalScope *Scope, LexicalScope *LexicalScopes::getOrCreateLexicalScope(const DILocalScope *Scope,
const MDLocation *IA) { const DILocation *IA) {
if (IA) { if (IA) {
// Create an abstract scope for inlined function. // Create an abstract scope for inlined function.
getOrCreateAbstractScope(Scope); getOrCreateAbstractScope(Scope);
@ -139,17 +139,17 @@ LexicalScope *LexicalScopes::getOrCreateLexicalScope(const MDLocalScope *Scope,
/// getOrCreateRegularScope - Find or create a regular lexical scope. /// getOrCreateRegularScope - Find or create a regular lexical scope.
LexicalScope * LexicalScope *
LexicalScopes::getOrCreateRegularScope(const MDLocalScope *Scope) { LexicalScopes::getOrCreateRegularScope(const DILocalScope *Scope) {
if (auto *File = dyn_cast<MDLexicalBlockFile>(Scope)) if (auto *File = dyn_cast<DILexicalBlockFile>(Scope))
Scope = File->getScope(); Scope = File->getScope();
auto I = LexicalScopeMap.find(Scope); auto I = LexicalScopeMap.find(Scope);
if (I != LexicalScopeMap.end()) if (I != LexicalScopeMap.end())
return &I->second; return &I->second;
// FIXME: Should the following dyn_cast be MDLexicalBlock? // FIXME: Should the following dyn_cast be DILexicalBlock?
LexicalScope *Parent = nullptr; LexicalScope *Parent = nullptr;
if (auto *Block = dyn_cast<MDLexicalBlockBase>(Scope)) if (auto *Block = dyn_cast<DILexicalBlockBase>(Scope))
Parent = getOrCreateLexicalScope(Block->getScope()); Parent = getOrCreateLexicalScope(Block->getScope());
I = LexicalScopeMap.emplace(std::piecewise_construct, I = LexicalScopeMap.emplace(std::piecewise_construct,
std::forward_as_tuple(Scope), std::forward_as_tuple(Scope),
@ -157,7 +157,7 @@ LexicalScopes::getOrCreateRegularScope(const MDLocalScope *Scope) {
false)).first; false)).first;
if (!Parent) { if (!Parent) {
assert(cast<MDSubprogram>(Scope)->describes(MF->getFunction())); assert(cast<DISubprogram>(Scope)->describes(MF->getFunction()));
assert(!CurrentFnLexicalScope); assert(!CurrentFnLexicalScope);
CurrentFnLexicalScope = &I->second; CurrentFnLexicalScope = &I->second;
} }
@ -167,15 +167,15 @@ LexicalScopes::getOrCreateRegularScope(const MDLocalScope *Scope) {
/// getOrCreateInlinedScope - Find or create an inlined lexical scope. /// getOrCreateInlinedScope - Find or create an inlined lexical scope.
LexicalScope * LexicalScope *
LexicalScopes::getOrCreateInlinedScope(const MDLocalScope *Scope, LexicalScopes::getOrCreateInlinedScope(const DILocalScope *Scope,
const MDLocation *InlinedAt) { const DILocation *InlinedAt) {
std::pair<const MDLocalScope *, const MDLocation *> P(Scope, InlinedAt); std::pair<const DILocalScope *, const DILocation *> P(Scope, InlinedAt);
auto I = InlinedLexicalScopeMap.find(P); auto I = InlinedLexicalScopeMap.find(P);
if (I != InlinedLexicalScopeMap.end()) if (I != InlinedLexicalScopeMap.end())
return &I->second; return &I->second;
LexicalScope *Parent; LexicalScope *Parent;
if (auto *Block = dyn_cast<MDLexicalBlockBase>(Scope)) if (auto *Block = dyn_cast<DILexicalBlockBase>(Scope))
Parent = getOrCreateInlinedScope(Block->getScope(), InlinedAt); Parent = getOrCreateInlinedScope(Block->getScope(), InlinedAt);
else else
Parent = getOrCreateLexicalScope(InlinedAt); Parent = getOrCreateLexicalScope(InlinedAt);
@ -190,25 +190,25 @@ LexicalScopes::getOrCreateInlinedScope(const MDLocalScope *Scope,
/// getOrCreateAbstractScope - Find or create an abstract lexical scope. /// getOrCreateAbstractScope - Find or create an abstract lexical scope.
LexicalScope * LexicalScope *
LexicalScopes::getOrCreateAbstractScope(const MDLocalScope *Scope) { LexicalScopes::getOrCreateAbstractScope(const DILocalScope *Scope) {
assert(Scope && "Invalid Scope encoding!"); assert(Scope && "Invalid Scope encoding!");
if (auto *File = dyn_cast<MDLexicalBlockFile>(Scope)) if (auto *File = dyn_cast<DILexicalBlockFile>(Scope))
Scope = File->getScope(); Scope = File->getScope();
auto I = AbstractScopeMap.find(Scope); auto I = AbstractScopeMap.find(Scope);
if (I != AbstractScopeMap.end()) if (I != AbstractScopeMap.end())
return &I->second; return &I->second;
// FIXME: Should the following isa be MDLexicalBlock? // FIXME: Should the following isa be DILexicalBlock?
LexicalScope *Parent = nullptr; LexicalScope *Parent = nullptr;
if (auto *Block = dyn_cast<MDLexicalBlockBase>(Scope)) if (auto *Block = dyn_cast<DILexicalBlockBase>(Scope))
Parent = getOrCreateAbstractScope(Block->getScope()); Parent = getOrCreateAbstractScope(Block->getScope());
I = AbstractScopeMap.emplace(std::piecewise_construct, I = AbstractScopeMap.emplace(std::piecewise_construct,
std::forward_as_tuple(Scope), std::forward_as_tuple(Scope),
std::forward_as_tuple(Parent, Scope, std::forward_as_tuple(Parent, Scope,
nullptr, true)).first; nullptr, true)).first;
if (isa<MDSubprogram>(Scope)) if (isa<DISubprogram>(Scope))
AbstractScopesList.push_back(&I->second); AbstractScopesList.push_back(&I->second);
return &I->second; return &I->second;
} }
@ -269,7 +269,7 @@ void LexicalScopes::assignInstructionRanges(
/// have machine instructions that belong to lexical scope identified by /// have machine instructions that belong to lexical scope identified by
/// DebugLoc. /// DebugLoc.
void LexicalScopes::getMachineBasicBlocks( void LexicalScopes::getMachineBasicBlocks(
const MDLocation *DL, SmallPtrSetImpl<const MachineBasicBlock *> &MBBs) { const DILocation *DL, SmallPtrSetImpl<const MachineBasicBlock *> &MBBs) {
MBBs.clear(); MBBs.clear();
LexicalScope *Scope = getOrCreateLexicalScope(DL); LexicalScope *Scope = getOrCreateLexicalScope(DL);
if (!Scope) if (!Scope)
@ -292,7 +292,7 @@ void LexicalScopes::getMachineBasicBlocks(
/// dominates - Return true if DebugLoc's lexical scope dominates at least one /// dominates - Return true if DebugLoc's lexical scope dominates at least one
/// machine instruction's lexical scope in a given machine basic block. /// machine instruction's lexical scope in a given machine basic block.
bool LexicalScopes::dominates(const MDLocation *DL, MachineBasicBlock *MBB) { bool LexicalScopes::dominates(const DILocation *DL, MachineBasicBlock *MBB) {
LexicalScope *Scope = getOrCreateLexicalScope(DL); LexicalScope *Scope = getOrCreateLexicalScope(DL);
if (!Scope) if (!Scope)
return false; return false;
@ -304,7 +304,7 @@ bool LexicalScopes::dominates(const MDLocation *DL, MachineBasicBlock *MBB) {
bool Result = false; bool Result = false;
for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E; for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E;
++I) { ++I) {
if (const MDLocation *IDL = I->getDebugLoc()) if (const DILocation *IDL = I->getDebugLoc())
if (LexicalScope *IScope = getOrCreateLexicalScope(IDL)) if (LexicalScope *IScope = getOrCreateLexicalScope(IDL))
if (Scope->dominates(IScope)) if (Scope->dominates(IScope))
return true; return true;

View File

@ -158,7 +158,7 @@ public:
UserValue *getNext() const { return next; } UserValue *getNext() const { return next; }
/// match - Does this UserValue match the parameters? /// match - Does this UserValue match the parameters?
bool match(const MDNode *Var, const MDNode *Expr, const MDLocation *IA, bool match(const MDNode *Var, const MDNode *Expr, const DILocation *IA,
unsigned Offset, bool indirect) const { unsigned Offset, bool indirect) const {
return Var == Variable && Expr == Expression && dl->getInlinedAt() == IA && return Var == Variable && Expr == Expression && dl->getInlinedAt() == IA &&
Offset == offset && indirect == IsIndirect; Offset == offset && indirect == IsIndirect;
@ -362,7 +362,7 @@ static void printDebugLoc(DebugLoc DL, raw_ostream &CommentOS,
if (!DL) if (!DL)
return; return;
auto *Scope = cast<MDScope>(DL.getScope()); auto *Scope = cast<DIScope>(DL.getScope());
// Omit the directory, because it's likely to be long and uninteresting. // Omit the directory, because it's likely to be long and uninteresting.
CommentOS << Scope->getFilename(); CommentOS << Scope->getFilename();
CommentOS << ':' << DL.getLine(); CommentOS << ':' << DL.getLine();
@ -378,8 +378,8 @@ static void printDebugLoc(DebugLoc DL, raw_ostream &CommentOS,
CommentOS << " ]"; CommentOS << " ]";
} }
static void printExtendedName(raw_ostream &OS, const MDLocalVariable *V, static void printExtendedName(raw_ostream &OS, const DILocalVariable *V,
const MDLocation *DL) { const DILocation *DL) {
const LLVMContext &Ctx = V->getContext(); const LLVMContext &Ctx = V->getContext();
StringRef Res = V->getName(); StringRef Res = V->getName();
if (!Res.empty()) if (!Res.empty())
@ -394,7 +394,7 @@ static void printExtendedName(raw_ostream &OS, const MDLocalVariable *V,
} }
void UserValue::print(raw_ostream &OS, const TargetRegisterInfo *TRI) { void UserValue::print(raw_ostream &OS, const TargetRegisterInfo *TRI) {
auto *DV = cast<MDLocalVariable>(Variable); auto *DV = cast<DILocalVariable>(Variable);
OS << "!\""; OS << "!\"";
printExtendedName(OS, DV, dl); printExtendedName(OS, DV, dl);
@ -981,7 +981,7 @@ void UserValue::insertDebugValue(MachineBasicBlock *MBB, SlotIndex Idx,
MachineOperand &Loc = locations[LocNo]; MachineOperand &Loc = locations[LocNo];
++NumInsertedDebugValues; ++NumInsertedDebugValues;
assert(cast<MDLocalVariable>(Variable) assert(cast<DILocalVariable>(Variable)
->isValidLocationForIntrinsic(getDebugLoc()) && ->isValidLocationForIntrinsic(getDebugLoc()) &&
"Expected inlined-at fields to agree"); "Expected inlined-at fields to agree");
if (Loc.isReg()) if (Loc.isReg())

View File

@ -33,7 +33,7 @@ class VirtRegMap;
class LiveDebugVariables : public MachineFunctionPass { class LiveDebugVariables : public MachineFunctionPass {
void *pImpl; void *pImpl;
DenseMap<const Function *, MDSubprogram *> FunctionDIs; DenseMap<const Function *, DISubprogram *> FunctionDIs;
public: public:
static char ID; // Pass identification, replacement for typeid static char ID; // Pass identification, replacement for typeid

View File

@ -1619,7 +1619,7 @@ void MachineInstr::print(raw_ostream &OS, bool SkipOpers) const {
} }
if (isDebugValue() && MO.isMetadata()) { if (isDebugValue() && MO.isMetadata()) {
// Pretty print DBG_VALUE instructions. // Pretty print DBG_VALUE instructions.
auto *DIV = dyn_cast<MDLocalVariable>(MO.getMetadata()); auto *DIV = dyn_cast<DILocalVariable>(MO.getMetadata());
if (DIV && !DIV->getName().empty()) if (DIV && !DIV->getName().empty())
OS << "!\"" << DIV->getName() << '\"'; OS << "!\"" << DIV->getName() << '\"';
else else
@ -1710,7 +1710,7 @@ void MachineInstr::print(raw_ostream &OS, bool SkipOpers) const {
// Print debug location information. // Print debug location information.
if (isDebugValue() && getOperand(e - 2).isMetadata()) { if (isDebugValue() && getOperand(e - 2).isMetadata()) {
if (!HaveSemi) OS << ";"; if (!HaveSemi) OS << ";";
auto *DV = cast<MDLocalVariable>(getOperand(e - 2).getMetadata()); auto *DV = cast<DILocalVariable>(getOperand(e - 2).getMetadata());
OS << " line no:" << DV->getLine(); OS << " line no:" << DV->getLine();
if (auto *InlinedAt = debugLoc->getInlinedAt()) { if (auto *InlinedAt = debugLoc->getInlinedAt()) {
DebugLoc InlinedAtDL(InlinedAt); DebugLoc InlinedAtDL(InlinedAt);

View File

@ -302,7 +302,7 @@ void RAFast::spillVirtReg(MachineBasicBlock::iterator MI,
bool IsIndirect = DBG->isIndirectDebugValue(); bool IsIndirect = DBG->isIndirectDebugValue();
uint64_t Offset = IsIndirect ? DBG->getOperand(1).getImm() : 0; uint64_t Offset = IsIndirect ? DBG->getOperand(1).getImm() : 0;
DebugLoc DL = DBG->getDebugLoc(); DebugLoc DL = DBG->getDebugLoc();
assert(cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) && assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree"); "Expected inlined-at fields to agree");
MachineInstr *NewDV = MachineInstr *NewDV =
BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::DBG_VALUE)) BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::DBG_VALUE))
@ -874,7 +874,7 @@ void RAFast::AllocateBasicBlock() {
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
MachineBasicBlock *MBB = MI->getParent(); MachineBasicBlock *MBB = MI->getParent();
assert( assert(
cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) && cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree"); "Expected inlined-at fields to agree");
MachineInstr *NewDV = BuildMI(*MBB, MBB->erase(MI), DL, MachineInstr *NewDV = BuildMI(*MBB, MBB->erase(MI), DL,
TII->get(TargetOpcode::DBG_VALUE)) TII->get(TargetOpcode::DBG_VALUE))

View File

@ -650,7 +650,7 @@ InstrEmitter::EmitDbgValue(SDDbgValue *SD,
MDNode *Var = SD->getVariable(); MDNode *Var = SD->getVariable();
MDNode *Expr = SD->getExpression(); MDNode *Expr = SD->getExpression();
DebugLoc DL = SD->getDebugLoc(); DebugLoc DL = SD->getDebugLoc();
assert(cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) && assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree"); "Expected inlined-at fields to agree");
if (SD->getKind() == SDDbgValue::FRAMEIX) { if (SD->getKind() == SDDbgValue::FRAMEIX) {

View File

@ -5978,7 +5978,7 @@ SDNode *SelectionDAG::getNodeIfExists(unsigned Opcode, SDVTList VTList,
SDDbgValue *SelectionDAG::getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, SDDbgValue *SelectionDAG::getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N,
unsigned R, bool IsIndirect, uint64_t Off, unsigned R, bool IsIndirect, uint64_t Off,
DebugLoc DL, unsigned O) { DebugLoc DL, unsigned O) {
assert(cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) && assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree"); "Expected inlined-at fields to agree");
return new (Allocator) SDDbgValue(Var, Expr, N, R, IsIndirect, Off, DL, O); return new (Allocator) SDDbgValue(Var, Expr, N, R, IsIndirect, Off, DL, O);
} }
@ -5987,7 +5987,7 @@ SDDbgValue *SelectionDAG::getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N,
SDDbgValue *SelectionDAG::getConstantDbgValue(MDNode *Var, MDNode *Expr, SDDbgValue *SelectionDAG::getConstantDbgValue(MDNode *Var, MDNode *Expr,
const Value *C, uint64_t Off, const Value *C, uint64_t Off,
DebugLoc DL, unsigned O) { DebugLoc DL, unsigned O) {
assert(cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) && assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree"); "Expected inlined-at fields to agree");
return new (Allocator) SDDbgValue(Var, Expr, C, Off, DL, O); return new (Allocator) SDDbgValue(Var, Expr, C, Off, DL, O);
} }
@ -5996,7 +5996,7 @@ SDDbgValue *SelectionDAG::getConstantDbgValue(MDNode *Var, MDNode *Expr,
SDDbgValue *SelectionDAG::getFrameIndexDbgValue(MDNode *Var, MDNode *Expr, SDDbgValue *SelectionDAG::getFrameIndexDbgValue(MDNode *Var, MDNode *Expr,
unsigned FI, uint64_t Off, unsigned FI, uint64_t Off,
DebugLoc DL, unsigned O) { DebugLoc DL, unsigned O) {
assert(cast<MDLocalVariable>(Var)->isValidLocationForIntrinsic(DL) && assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree"); "Expected inlined-at fields to agree");
return new (Allocator) SDDbgValue(Var, Expr, FI, Off, DL, O); return new (Allocator) SDDbgValue(Var, Expr, FI, Off, DL, O);
} }

View File

@ -999,8 +999,8 @@ void SelectionDAGBuilder::resolveDanglingDebugInfo(const Value *V,
const DbgValueInst *DI = DDI.getDI(); const DbgValueInst *DI = DDI.getDI();
DebugLoc dl = DDI.getdl(); DebugLoc dl = DDI.getdl();
unsigned DbgSDNodeOrder = DDI.getSDNodeOrder(); unsigned DbgSDNodeOrder = DDI.getSDNodeOrder();
MDLocalVariable *Variable = DI->getVariable(); DILocalVariable *Variable = DI->getVariable();
MDExpression *Expr = DI->getExpression(); DIExpression *Expr = DI->getExpression();
assert(Variable->isValidLocationForIntrinsic(dl) && assert(Variable->isValidLocationForIntrinsic(dl) &&
"Expected inlined-at fields to agree"); "Expected inlined-at fields to agree");
uint64_t Offset = DI->getOffset(); uint64_t Offset = DI->getOffset();
@ -3980,8 +3980,8 @@ static unsigned getTruncatedArgReg(const SDValue &N) {
/// argument, create the corresponding DBG_VALUE machine instruction for it now. /// argument, create the corresponding DBG_VALUE machine instruction for it now.
/// At the end of instruction selection, they will be inserted to the entry BB. /// At the end of instruction selection, they will be inserted to the entry BB.
bool SelectionDAGBuilder::EmitFuncArgumentDbgValue( bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
const Value *V, MDLocalVariable *Variable, MDExpression *Expr, const Value *V, DILocalVariable *Variable, DIExpression *Expr,
MDLocation *DL, int64_t Offset, bool IsIndirect, const SDValue &N) { DILocation *DL, int64_t Offset, bool IsIndirect, const SDValue &N) {
const Argument *Arg = dyn_cast<Argument>(V); const Argument *Arg = dyn_cast<Argument>(V);
if (!Arg) if (!Arg)
return false; return false;
@ -4175,8 +4175,8 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
} }
case Intrinsic::dbg_declare: { case Intrinsic::dbg_declare: {
const DbgDeclareInst &DI = cast<DbgDeclareInst>(I); const DbgDeclareInst &DI = cast<DbgDeclareInst>(I);
MDLocalVariable *Variable = DI.getVariable(); DILocalVariable *Variable = DI.getVariable();
MDExpression *Expression = DI.getExpression(); DIExpression *Expression = DI.getExpression();
const Value *Address = DI.getAddress(); const Value *Address = DI.getAddress();
assert(Variable && "Missing variable"); assert(Variable && "Missing variable");
if (!Address) { if (!Address) {
@ -4257,8 +4257,8 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
const DbgValueInst &DI = cast<DbgValueInst>(I); const DbgValueInst &DI = cast<DbgValueInst>(I);
assert(DI.getVariable() && "Missing variable"); assert(DI.getVariable() && "Missing variable");
MDLocalVariable *Variable = DI.getVariable(); DILocalVariable *Variable = DI.getVariable();
MDExpression *Expression = DI.getExpression(); DIExpression *Expression = DI.getExpression();
uint64_t Offset = DI.getOffset(); uint64_t Offset = DI.getOffset();
const Value *V = DI.getValue(); const Value *V = DI.getValue();
if (!V) if (!V)

View File

@ -866,8 +866,8 @@ private:
/// EmitFuncArgumentDbgValue - If V is an function argument then create /// EmitFuncArgumentDbgValue - If V is an function argument then create
/// corresponding DBG_VALUE machine instruction for it now. At the end of /// corresponding DBG_VALUE machine instruction for it now. At the end of
/// instruction selection, they will be inserted to the entry BB. /// instruction selection, they will be inserted to the entry BB.
bool EmitFuncArgumentDbgValue(const Value *V, MDLocalVariable *Variable, bool EmitFuncArgumentDbgValue(const Value *V, DILocalVariable *Variable,
MDExpression *Expr, MDLocation *DL, DIExpression *Expr, DILocation *DL,
int64_t Offset, bool IsIndirect, int64_t Offset, bool IsIndirect,
const SDValue &N); const SDValue &N);

View File

@ -523,7 +523,7 @@ void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {
if (!G) if (!G)
return; return;
MDLocation *L = getDebugLoc(); DILocation *L = getDebugLoc();
if (!L) if (!L)
return; return;

View File

@ -504,7 +504,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
bool IsIndirect = MI->isIndirectDebugValue(); bool IsIndirect = MI->isIndirectDebugValue();
unsigned Offset = IsIndirect ? MI->getOperand(1).getImm() : 0; unsigned Offset = IsIndirect ? MI->getOperand(1).getImm() : 0;
assert(cast<MDLocalVariable>(Variable)->isValidLocationForIntrinsic(DL) && assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree"); "Expected inlined-at fields to agree");
// Def is never a terminator here, so it is ok to increment InsertPos. // Def is never a terminator here, so it is ok to increment InsertPos.
BuildMI(*EntryMBB, ++InsertPos, DL, TII->get(TargetOpcode::DBG_VALUE), BuildMI(*EntryMBB, ++InsertPos, DL, TII->get(TargetOpcode::DBG_VALUE),

View File

@ -464,7 +464,7 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
continue; continue;
if (SlotRemap.count(VI.Slot)) { if (SlotRemap.count(VI.Slot)) {
DEBUG(dbgs() << "Remapping debug info for [" DEBUG(dbgs() << "Remapping debug info for ["
<< cast<MDLocalVariable>(VI.Var)->getName() << "].\n"); << cast<DILocalVariable>(VI.Var)->getName() << "].\n");
VI.Slot = SlotRemap[VI.Slot]; VI.Slot = SlotRemap[VI.Slot];
FixedDbg++; FixedDbg++;
} }

View File

@ -1375,7 +1375,7 @@ struct MDFieldPrinter {
SlotTracker *Machine, const Module *Context) SlotTracker *Machine, const Module *Context)
: Out(Out), TypePrinter(TypePrinter), Machine(Machine), Context(Context) { : Out(Out), TypePrinter(TypePrinter), Machine(Machine), Context(Context) {
} }
void printTag(const DebugNode *N); void printTag(const DINode *N);
void printString(StringRef Name, StringRef Value, void printString(StringRef Name, StringRef Value,
bool ShouldSkipEmpty = true); bool ShouldSkipEmpty = true);
void printMetadata(StringRef Name, const Metadata *MD, void printMetadata(StringRef Name, const Metadata *MD,
@ -1390,7 +1390,7 @@ struct MDFieldPrinter {
}; };
} // end namespace } // end namespace
void MDFieldPrinter::printTag(const DebugNode *N) { void MDFieldPrinter::printTag(const DINode *N) {
Out << FS << "tag: "; Out << FS << "tag: ";
if (const char *Tag = dwarf::TagString(N->getTag())) if (const char *Tag = dwarf::TagString(N->getTag()))
Out << Tag; Out << Tag;
@ -1447,11 +1447,11 @@ void MDFieldPrinter::printDIFlags(StringRef Name, unsigned Flags) {
Out << FS << Name << ": "; Out << FS << Name << ": ";
SmallVector<unsigned, 8> SplitFlags; SmallVector<unsigned, 8> SplitFlags;
unsigned Extra = DebugNode::splitFlags(Flags, SplitFlags); unsigned Extra = DINode::splitFlags(Flags, SplitFlags);
FieldSeparator FlagsFS(" | "); FieldSeparator FlagsFS(" | ");
for (unsigned F : SplitFlags) { for (unsigned F : SplitFlags) {
const char *StringF = DebugNode::getFlagString(F); const char *StringF = DINode::getFlagString(F);
assert(StringF && "Expected valid flag"); assert(StringF && "Expected valid flag");
Out << FlagsFS << StringF; Out << FlagsFS << StringF;
} }
@ -1472,10 +1472,10 @@ void MDFieldPrinter::printDwarfEnum(StringRef Name, IntTy Value,
Out << Value; Out << Value;
} }
static void writeGenericDebugNode(raw_ostream &Out, const GenericDebugNode *N, static void writeGenericDINode(raw_ostream &Out, const GenericDINode *N,
TypePrinting *TypePrinter, TypePrinting *TypePrinter, SlotTracker *Machine,
SlotTracker *Machine, const Module *Context) { const Module *Context) {
Out << "!GenericDebugNode("; Out << "!GenericDINode(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printTag(N); Printer.printTag(N);
Printer.printString("header", N->getHeader()); Printer.printString("header", N->getHeader());
@ -1491,10 +1491,10 @@ static void writeGenericDebugNode(raw_ostream &Out, const GenericDebugNode *N,
Out << ")"; Out << ")";
} }
static void writeMDLocation(raw_ostream &Out, const MDLocation *DL, static void writeDILocation(raw_ostream &Out, const DILocation *DL,
TypePrinting *TypePrinter, SlotTracker *Machine, TypePrinting *TypePrinter, SlotTracker *Machine,
const Module *Context) { const Module *Context) {
Out << "!MDLocation("; Out << "!DILocation(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
// Always output the line, since 0 is a relevant and important value for it. // Always output the line, since 0 is a relevant and important value for it.
Printer.printInt("line", DL->getLine(), /* ShouldSkipZero */ false); Printer.printInt("line", DL->getLine(), /* ShouldSkipZero */ false);
@ -1504,27 +1504,27 @@ static void writeMDLocation(raw_ostream &Out, const MDLocation *DL,
Out << ")"; Out << ")";
} }
static void writeMDSubrange(raw_ostream &Out, const MDSubrange *N, static void writeDISubrange(raw_ostream &Out, const DISubrange *N,
TypePrinting *, SlotTracker *, const Module *) { TypePrinting *, SlotTracker *, const Module *) {
Out << "!MDSubrange("; Out << "!DISubrange(";
MDFieldPrinter Printer(Out); MDFieldPrinter Printer(Out);
Printer.printInt("count", N->getCount(), /* ShouldSkipZero */ false); Printer.printInt("count", N->getCount(), /* ShouldSkipZero */ false);
Printer.printInt("lowerBound", N->getLowerBound()); Printer.printInt("lowerBound", N->getLowerBound());
Out << ")"; Out << ")";
} }
static void writeMDEnumerator(raw_ostream &Out, const MDEnumerator *N, static void writeDIEnumerator(raw_ostream &Out, const DIEnumerator *N,
TypePrinting *, SlotTracker *, const Module *) { TypePrinting *, SlotTracker *, const Module *) {
Out << "!MDEnumerator("; Out << "!DIEnumerator(";
MDFieldPrinter Printer(Out); MDFieldPrinter Printer(Out);
Printer.printString("name", N->getName(), /* ShouldSkipEmpty */ false); Printer.printString("name", N->getName(), /* ShouldSkipEmpty */ false);
Printer.printInt("value", N->getValue(), /* ShouldSkipZero */ false); Printer.printInt("value", N->getValue(), /* ShouldSkipZero */ false);
Out << ")"; Out << ")";
} }
static void writeMDBasicType(raw_ostream &Out, const MDBasicType *N, static void writeDIBasicType(raw_ostream &Out, const DIBasicType *N,
TypePrinting *, SlotTracker *, const Module *) { TypePrinting *, SlotTracker *, const Module *) {
Out << "!MDBasicType("; Out << "!DIBasicType(";
MDFieldPrinter Printer(Out); MDFieldPrinter Printer(Out);
if (N->getTag() != dwarf::DW_TAG_base_type) if (N->getTag() != dwarf::DW_TAG_base_type)
Printer.printTag(N); Printer.printTag(N);
@ -1536,10 +1536,10 @@ static void writeMDBasicType(raw_ostream &Out, const MDBasicType *N,
Out << ")"; Out << ")";
} }
static void writeMDDerivedType(raw_ostream &Out, const MDDerivedType *N, static void writeDIDerivedType(raw_ostream &Out, const DIDerivedType *N,
TypePrinting *TypePrinter, SlotTracker *Machine, TypePrinting *TypePrinter, SlotTracker *Machine,
const Module *Context) { const Module *Context) {
Out << "!MDDerivedType("; Out << "!DIDerivedType(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printTag(N); Printer.printTag(N);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());
@ -1556,10 +1556,10 @@ static void writeMDDerivedType(raw_ostream &Out, const MDDerivedType *N,
Out << ")"; Out << ")";
} }
static void writeMDCompositeType(raw_ostream &Out, const MDCompositeType *N, static void writeDICompositeType(raw_ostream &Out, const DICompositeType *N,
TypePrinting *TypePrinter, TypePrinting *TypePrinter,
SlotTracker *Machine, const Module *Context) { SlotTracker *Machine, const Module *Context) {
Out << "!MDCompositeType("; Out << "!DICompositeType(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printTag(N); Printer.printTag(N);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());
@ -1580,10 +1580,10 @@ static void writeMDCompositeType(raw_ostream &Out, const MDCompositeType *N,
Out << ")"; Out << ")";
} }
static void writeMDSubroutineType(raw_ostream &Out, const MDSubroutineType *N, static void writeDISubroutineType(raw_ostream &Out, const DISubroutineType *N,
TypePrinting *TypePrinter, TypePrinting *TypePrinter,
SlotTracker *Machine, const Module *Context) { SlotTracker *Machine, const Module *Context) {
Out << "!MDSubroutineType("; Out << "!DISubroutineType(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printDIFlags("flags", N->getFlags()); Printer.printDIFlags("flags", N->getFlags());
Printer.printMetadata("types", N->getRawTypeArray(), Printer.printMetadata("types", N->getRawTypeArray(),
@ -1591,9 +1591,9 @@ static void writeMDSubroutineType(raw_ostream &Out, const MDSubroutineType *N,
Out << ")"; Out << ")";
} }
static void writeMDFile(raw_ostream &Out, const MDFile *N, TypePrinting *, static void writeDIFile(raw_ostream &Out, const DIFile *N, TypePrinting *,
SlotTracker *, const Module *) { SlotTracker *, const Module *) {
Out << "!MDFile("; Out << "!DIFile(";
MDFieldPrinter Printer(Out); MDFieldPrinter Printer(Out);
Printer.printString("filename", N->getFilename(), Printer.printString("filename", N->getFilename(),
/* ShouldSkipEmpty */ false); /* ShouldSkipEmpty */ false);
@ -1602,10 +1602,10 @@ static void writeMDFile(raw_ostream &Out, const MDFile *N, TypePrinting *,
Out << ")"; Out << ")";
} }
static void writeMDCompileUnit(raw_ostream &Out, const MDCompileUnit *N, static void writeDICompileUnit(raw_ostream &Out, const DICompileUnit *N,
TypePrinting *TypePrinter, SlotTracker *Machine, TypePrinting *TypePrinter, SlotTracker *Machine,
const Module *Context) { const Module *Context) {
Out << "!MDCompileUnit("; Out << "!DICompileUnit(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printDwarfEnum("language", N->getSourceLanguage(), Printer.printDwarfEnum("language", N->getSourceLanguage(),
dwarf::LanguageString, /* ShouldSkipZero */ false); dwarf::LanguageString, /* ShouldSkipZero */ false);
@ -1626,10 +1626,10 @@ static void writeMDCompileUnit(raw_ostream &Out, const MDCompileUnit *N,
Out << ")"; Out << ")";
} }
static void writeMDSubprogram(raw_ostream &Out, const MDSubprogram *N, static void writeDISubprogram(raw_ostream &Out, const DISubprogram *N,
TypePrinting *TypePrinter, SlotTracker *Machine, TypePrinting *TypePrinter, SlotTracker *Machine,
const Module *Context) { const Module *Context) {
Out << "!MDSubprogram("; Out << "!DISubprogram(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());
Printer.printString("linkageName", N->getLinkageName()); Printer.printString("linkageName", N->getLinkageName());
@ -1653,10 +1653,10 @@ static void writeMDSubprogram(raw_ostream &Out, const MDSubprogram *N,
Out << ")"; Out << ")";
} }
static void writeMDLexicalBlock(raw_ostream &Out, const MDLexicalBlock *N, static void writeDILexicalBlock(raw_ostream &Out, const DILexicalBlock *N,
TypePrinting *TypePrinter, SlotTracker *Machine, TypePrinting *TypePrinter, SlotTracker *Machine,
const Module *Context) { const Module *Context) {
Out << "!MDLexicalBlock("; Out << "!DILexicalBlock(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false); Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false);
Printer.printMetadata("file", N->getRawFile()); Printer.printMetadata("file", N->getRawFile());
@ -1665,12 +1665,12 @@ static void writeMDLexicalBlock(raw_ostream &Out, const MDLexicalBlock *N,
Out << ")"; Out << ")";
} }
static void writeMDLexicalBlockFile(raw_ostream &Out, static void writeDILexicalBlockFile(raw_ostream &Out,
const MDLexicalBlockFile *N, const DILexicalBlockFile *N,
TypePrinting *TypePrinter, TypePrinting *TypePrinter,
SlotTracker *Machine, SlotTracker *Machine,
const Module *Context) { const Module *Context) {
Out << "!MDLexicalBlockFile("; Out << "!DILexicalBlockFile(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false); Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false);
Printer.printMetadata("file", N->getRawFile()); Printer.printMetadata("file", N->getRawFile());
@ -1679,10 +1679,10 @@ static void writeMDLexicalBlockFile(raw_ostream &Out,
Out << ")"; Out << ")";
} }
static void writeMDNamespace(raw_ostream &Out, const MDNamespace *N, static void writeDINamespace(raw_ostream &Out, const DINamespace *N,
TypePrinting *TypePrinter, SlotTracker *Machine, TypePrinting *TypePrinter, SlotTracker *Machine,
const Module *Context) { const Module *Context) {
Out << "!MDNamespace("; Out << "!DINamespace(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());
Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false); Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false);
@ -1691,24 +1691,24 @@ static void writeMDNamespace(raw_ostream &Out, const MDNamespace *N,
Out << ")"; Out << ")";
} }
static void writeMDTemplateTypeParameter(raw_ostream &Out, static void writeDITemplateTypeParameter(raw_ostream &Out,
const MDTemplateTypeParameter *N, const DITemplateTypeParameter *N,
TypePrinting *TypePrinter, TypePrinting *TypePrinter,
SlotTracker *Machine, SlotTracker *Machine,
const Module *Context) { const Module *Context) {
Out << "!MDTemplateTypeParameter("; Out << "!DITemplateTypeParameter(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());
Printer.printMetadata("type", N->getRawType(), /* ShouldSkipNull */ false); Printer.printMetadata("type", N->getRawType(), /* ShouldSkipNull */ false);
Out << ")"; Out << ")";
} }
static void writeMDTemplateValueParameter(raw_ostream &Out, static void writeDITemplateValueParameter(raw_ostream &Out,
const MDTemplateValueParameter *N, const DITemplateValueParameter *N,
TypePrinting *TypePrinter, TypePrinting *TypePrinter,
SlotTracker *Machine, SlotTracker *Machine,
const Module *Context) { const Module *Context) {
Out << "!MDTemplateValueParameter("; Out << "!DITemplateValueParameter(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
if (N->getTag() != dwarf::DW_TAG_template_value_parameter) if (N->getTag() != dwarf::DW_TAG_template_value_parameter)
Printer.printTag(N); Printer.printTag(N);
@ -1718,10 +1718,10 @@ static void writeMDTemplateValueParameter(raw_ostream &Out,
Out << ")"; Out << ")";
} }
static void writeMDGlobalVariable(raw_ostream &Out, const MDGlobalVariable *N, static void writeDIGlobalVariable(raw_ostream &Out, const DIGlobalVariable *N,
TypePrinting *TypePrinter, TypePrinting *TypePrinter,
SlotTracker *Machine, const Module *Context) { SlotTracker *Machine, const Module *Context) {
Out << "!MDGlobalVariable("; Out << "!DIGlobalVariable(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());
Printer.printString("linkageName", N->getLinkageName()); Printer.printString("linkageName", N->getLinkageName());
@ -1736,10 +1736,10 @@ static void writeMDGlobalVariable(raw_ostream &Out, const MDGlobalVariable *N,
Out << ")"; Out << ")";
} }
static void writeMDLocalVariable(raw_ostream &Out, const MDLocalVariable *N, static void writeDILocalVariable(raw_ostream &Out, const DILocalVariable *N,
TypePrinting *TypePrinter, TypePrinting *TypePrinter,
SlotTracker *Machine, const Module *Context) { SlotTracker *Machine, const Module *Context) {
Out << "!MDLocalVariable("; Out << "!DILocalVariable(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printTag(N); Printer.printTag(N);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());
@ -1754,10 +1754,10 @@ static void writeMDLocalVariable(raw_ostream &Out, const MDLocalVariable *N,
Out << ")"; Out << ")";
} }
static void writeMDExpression(raw_ostream &Out, const MDExpression *N, static void writeDIExpression(raw_ostream &Out, const DIExpression *N,
TypePrinting *TypePrinter, SlotTracker *Machine, TypePrinting *TypePrinter, SlotTracker *Machine,
const Module *Context) { const Module *Context) {
Out << "!MDExpression("; Out << "!DIExpression(";
FieldSeparator FS; FieldSeparator FS;
if (N->isValid()) { if (N->isValid()) {
for (auto I = N->expr_op_begin(), E = N->expr_op_end(); I != E; ++I) { for (auto I = N->expr_op_begin(), E = N->expr_op_end(); I != E; ++I) {
@ -1775,10 +1775,10 @@ static void writeMDExpression(raw_ostream &Out, const MDExpression *N,
Out << ")"; Out << ")";
} }
static void writeMDObjCProperty(raw_ostream &Out, const MDObjCProperty *N, static void writeDIObjCProperty(raw_ostream &Out, const DIObjCProperty *N,
TypePrinting *TypePrinter, SlotTracker *Machine, TypePrinting *TypePrinter, SlotTracker *Machine,
const Module *Context) { const Module *Context) {
Out << "!MDObjCProperty("; Out << "!DIObjCProperty(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());
Printer.printMetadata("file", N->getRawFile()); Printer.printMetadata("file", N->getRawFile());
@ -1790,10 +1790,10 @@ static void writeMDObjCProperty(raw_ostream &Out, const MDObjCProperty *N,
Out << ")"; Out << ")";
} }
static void writeMDImportedEntity(raw_ostream &Out, const MDImportedEntity *N, static void writeDIImportedEntity(raw_ostream &Out, const DIImportedEntity *N,
TypePrinting *TypePrinter, TypePrinting *TypePrinter,
SlotTracker *Machine, const Module *Context) { SlotTracker *Machine, const Module *Context) {
Out << "!MDImportedEntity("; Out << "!DIImportedEntity(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printTag(N); Printer.printTag(N);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());

View File

@ -87,13 +87,13 @@ void DIBuilder::finalize() {
RetainValues.push_back(AllRetainTypes[I]); RetainValues.push_back(AllRetainTypes[I]);
TempRetainTypes->replaceAllUsesWith(MDTuple::get(VMContext, RetainValues)); TempRetainTypes->replaceAllUsesWith(MDTuple::get(VMContext, RetainValues));
MDSubprogramArray SPs = MDTuple::get(VMContext, AllSubprograms); DISubprogramArray SPs = MDTuple::get(VMContext, AllSubprograms);
TempSubprograms->replaceAllUsesWith(SPs.get()); TempSubprograms->replaceAllUsesWith(SPs.get());
for (auto *SP : SPs) { for (auto *SP : SPs) {
if (MDTuple *Temp = SP->getVariables().get()) { if (MDTuple *Temp = SP->getVariables().get()) {
const auto &PV = PreservedVariables.lookup(SP); const auto &PV = PreservedVariables.lookup(SP);
SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end()); SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end());
DebugNodeArray AV = getOrCreateArray(Variables); DINodeArray AV = getOrCreateArray(Variables);
TempMDTuple(Temp)->replaceAllUsesWith(AV.get()); TempMDTuple(Temp)->replaceAllUsesWith(AV.get());
} }
} }
@ -116,13 +116,13 @@ void DIBuilder::finalize() {
} }
/// If N is compile unit return NULL otherwise return N. /// If N is compile unit return NULL otherwise return N.
static MDScope *getNonCompileUnitScope(MDScope *N) { static DIScope *getNonCompileUnitScope(DIScope *N) {
if (!N || isa<MDCompileUnit>(N)) if (!N || isa<DICompileUnit>(N))
return nullptr; return nullptr;
return cast<MDScope>(N); return cast<DIScope>(N);
} }
MDCompileUnit *DIBuilder::createCompileUnit( DICompileUnit *DIBuilder::createCompileUnit(
unsigned Lang, StringRef Filename, StringRef Directory, StringRef Producer, unsigned Lang, StringRef Filename, StringRef Directory, StringRef Producer,
bool isOptimized, StringRef Flags, unsigned RunTimeVer, StringRef SplitName, bool isOptimized, StringRef Flags, unsigned RunTimeVer, StringRef SplitName,
DebugEmissionKind Kind, bool EmitDebugInfo) { DebugEmissionKind Kind, bool EmitDebugInfo) {
@ -133,7 +133,7 @@ MDCompileUnit *DIBuilder::createCompileUnit(
assert(!Filename.empty() && assert(!Filename.empty() &&
"Unable to create compile unit without filename"); "Unable to create compile unit without filename");
// TODO: Once we make MDCompileUnit distinct, stop using temporaries here // TODO: Once we make DICompileUnit distinct, stop using temporaries here
// (just start with operands assigned to nullptr). // (just start with operands assigned to nullptr).
TempEnumTypes = MDTuple::getTemporary(VMContext, None); TempEnumTypes = MDTuple::getTemporary(VMContext, None);
TempRetainTypes = MDTuple::getTemporary(VMContext, None); TempRetainTypes = MDTuple::getTemporary(VMContext, None);
@ -143,8 +143,8 @@ MDCompileUnit *DIBuilder::createCompileUnit(
// TODO: Switch to getDistinct(). We never want to merge compile units based // TODO: Switch to getDistinct(). We never want to merge compile units based
// on contents. // on contents.
MDCompileUnit *CUNode = MDCompileUnit::get( DICompileUnit *CUNode = DICompileUnit::get(
VMContext, Lang, MDFile::get(VMContext, Filename, Directory), Producer, VMContext, Lang, DIFile::get(VMContext, Filename, Directory), Producer,
isOptimized, Flags, RunTimeVer, SplitName, Kind, TempEnumTypes.get(), isOptimized, Flags, RunTimeVer, SplitName, Kind, TempEnumTypes.get(),
TempRetainTypes.get(), TempSubprograms.get(), TempGVs.get(), TempRetainTypes.get(), TempSubprograms.get(), TempGVs.get(),
TempImportedModules.get()); TempImportedModules.get());
@ -163,132 +163,132 @@ MDCompileUnit *DIBuilder::createCompileUnit(
return CUNode; return CUNode;
} }
static MDImportedEntity* static DIImportedEntity *
createImportedModule(LLVMContext &C, dwarf::Tag Tag, MDScope* Context, createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context,
Metadata *NS, unsigned Line, StringRef Name, Metadata *NS, unsigned Line, StringRef Name,
SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) { SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) {
auto *M = auto *M = DIImportedEntity::get(C, Tag, Context, DINodeRef(NS), Line, Name);
MDImportedEntity::get(C, Tag, Context, DebugNodeRef(NS), Line, Name);
AllImportedModules.emplace_back(M); AllImportedModules.emplace_back(M);
return M; return M;
} }
MDImportedEntity* DIBuilder::createImportedModule(MDScope* Context, DIImportedEntity *DIBuilder::createImportedModule(DIScope *Context,
MDNamespace* NS, DINamespace *NS,
unsigned Line) { unsigned Line) {
return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module, return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
Context, NS, Line, StringRef(), AllImportedModules); Context, NS, Line, StringRef(), AllImportedModules);
} }
MDImportedEntity* DIBuilder::createImportedModule(MDScope* Context, DIImportedEntity *DIBuilder::createImportedModule(DIScope *Context,
MDImportedEntity* NS, DIImportedEntity *NS,
unsigned Line) { unsigned Line) {
return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module, return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
Context, NS, Line, StringRef(), AllImportedModules); Context, NS, Line, StringRef(), AllImportedModules);
} }
MDImportedEntity *DIBuilder::createImportedDeclaration(MDScope *Context, DIImportedEntity *DIBuilder::createImportedDeclaration(DIScope *Context,
DebugNode *Decl, DINode *Decl,
unsigned Line, unsigned Line,
StringRef Name) { StringRef Name) {
// Make sure to use the unique identifier based metadata reference for // Make sure to use the unique identifier based metadata reference for
// types that have one. // types that have one.
return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration, return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
Context, DebugNodeRef::get(Decl), Line, Name, Context, DINodeRef::get(Decl), Line, Name,
AllImportedModules); AllImportedModules);
} }
MDFile* DIBuilder::createFile(StringRef Filename, StringRef Directory) { DIFile *DIBuilder::createFile(StringRef Filename, StringRef Directory) {
return MDFile::get(VMContext, Filename, Directory); return DIFile::get(VMContext, Filename, Directory);
} }
MDEnumerator *DIBuilder::createEnumerator(StringRef Name, int64_t Val) { DIEnumerator *DIBuilder::createEnumerator(StringRef Name, int64_t Val) {
assert(!Name.empty() && "Unable to create enumerator without name"); assert(!Name.empty() && "Unable to create enumerator without name");
return MDEnumerator::get(VMContext, Val, Name); return DIEnumerator::get(VMContext, Val, Name);
} }
MDBasicType *DIBuilder::createUnspecifiedType(StringRef Name) { DIBasicType *DIBuilder::createUnspecifiedType(StringRef Name) {
assert(!Name.empty() && "Unable to create type without name"); assert(!Name.empty() && "Unable to create type without name");
return MDBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name); return DIBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name);
} }
MDBasicType *DIBuilder::createNullPtrType() { DIBasicType *DIBuilder::createNullPtrType() {
return createUnspecifiedType("decltype(nullptr)"); return createUnspecifiedType("decltype(nullptr)");
} }
MDBasicType *DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits, DIBasicType *DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t AlignInBits,
unsigned Encoding) { unsigned Encoding) {
assert(!Name.empty() && "Unable to create type without name"); assert(!Name.empty() && "Unable to create type without name");
return MDBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits, return DIBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits,
AlignInBits, Encoding); AlignInBits, Encoding);
} }
MDDerivedType *DIBuilder::createQualifiedType(unsigned Tag, MDType *FromTy) { DIDerivedType *DIBuilder::createQualifiedType(unsigned Tag, DIType *FromTy) {
return MDDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr,
MDTypeRef::get(FromTy), 0, 0, 0, 0); DITypeRef::get(FromTy), 0, 0, 0, 0);
} }
MDDerivedType *DIBuilder::createPointerType(MDType *PointeeTy, DIDerivedType *DIBuilder::createPointerType(DIType *PointeeTy,
uint64_t SizeInBits, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t AlignInBits,
StringRef Name) { StringRef Name) {
// FIXME: Why is there a name here? // FIXME: Why is there a name here?
return MDDerivedType::get(VMContext, dwarf::DW_TAG_pointer_type, Name, return DIDerivedType::get(VMContext, dwarf::DW_TAG_pointer_type, Name,
nullptr, 0, nullptr, MDTypeRef::get(PointeeTy), nullptr, 0, nullptr, DITypeRef::get(PointeeTy),
SizeInBits, AlignInBits, 0, 0); SizeInBits, AlignInBits, 0, 0);
} }
MDDerivedType *DIBuilder::createMemberPointerType(MDType *PointeeTy, DIDerivedType *DIBuilder::createMemberPointerType(DIType *PointeeTy,
MDType *Base, DIType *Base,
uint64_t SizeInBits, uint64_t SizeInBits,
uint64_t AlignInBits) { uint64_t AlignInBits) {
return MDDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "", return DIDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "",
nullptr, 0, nullptr, MDTypeRef::get(PointeeTy), nullptr, 0, nullptr, DITypeRef::get(PointeeTy),
SizeInBits, AlignInBits, 0, 0, MDTypeRef::get(Base)); SizeInBits, AlignInBits, 0, 0,
DITypeRef::get(Base));
} }
MDDerivedType *DIBuilder::createReferenceType(unsigned Tag, MDType *RTy) { DIDerivedType *DIBuilder::createReferenceType(unsigned Tag, DIType *RTy) {
assert(RTy && "Unable to create reference type"); assert(RTy && "Unable to create reference type");
return MDDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr,
MDTypeRef::get(RTy), 0, 0, 0, 0); DITypeRef::get(RTy), 0, 0, 0, 0);
} }
MDDerivedType *DIBuilder::createTypedef(MDType *Ty, StringRef Name, DIDerivedType *DIBuilder::createTypedef(DIType *Ty, StringRef Name,
MDFile *File, unsigned LineNo, DIFile *File, unsigned LineNo,
MDScope *Context) { DIScope *Context) {
return MDDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File, return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File,
LineNo, LineNo,
MDScopeRef::get(getNonCompileUnitScope(Context)), DIScopeRef::get(getNonCompileUnitScope(Context)),
MDTypeRef::get(Ty), 0, 0, 0, 0); DITypeRef::get(Ty), 0, 0, 0, 0);
} }
MDDerivedType *DIBuilder::createFriend(MDType *Ty, MDType *FriendTy) { DIDerivedType *DIBuilder::createFriend(DIType *Ty, DIType *FriendTy) {
assert(Ty && "Invalid type!"); assert(Ty && "Invalid type!");
assert(FriendTy && "Invalid friend type!"); assert(FriendTy && "Invalid friend type!");
return MDDerivedType::get(VMContext, dwarf::DW_TAG_friend, "", nullptr, 0, return DIDerivedType::get(VMContext, dwarf::DW_TAG_friend, "", nullptr, 0,
MDTypeRef::get(Ty), MDTypeRef::get(FriendTy), 0, 0, DITypeRef::get(Ty), DITypeRef::get(FriendTy), 0, 0,
0, 0); 0, 0);
} }
MDDerivedType *DIBuilder::createInheritance(MDType *Ty, MDType *BaseTy, DIDerivedType *DIBuilder::createInheritance(DIType *Ty, DIType *BaseTy,
uint64_t BaseOffset, uint64_t BaseOffset,
unsigned Flags) { unsigned Flags) {
assert(Ty && "Unable to create inheritance"); assert(Ty && "Unable to create inheritance");
return MDDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr, return DIDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr,
0, MDTypeRef::get(Ty), MDTypeRef::get(BaseTy), 0, 0, 0, DITypeRef::get(Ty), DITypeRef::get(BaseTy), 0, 0,
BaseOffset, Flags); BaseOffset, Flags);
} }
MDDerivedType *DIBuilder::createMemberType(MDScope *Scope, StringRef Name, DIDerivedType *DIBuilder::createMemberType(DIScope *Scope, StringRef Name,
MDFile *File, unsigned LineNumber, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t AlignInBits,
uint64_t OffsetInBits, uint64_t OffsetInBits,
unsigned Flags, MDType *Ty) { unsigned Flags, DIType *Ty) {
return MDDerivedType::get( return DIDerivedType::get(
VMContext, dwarf::DW_TAG_member, Name, File, LineNumber, VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
MDScopeRef::get(getNonCompileUnitScope(Scope)), MDTypeRef::get(Ty), DIScopeRef::get(getNonCompileUnitScope(Scope)), DITypeRef::get(Ty),
SizeInBits, AlignInBits, OffsetInBits, Flags); SizeInBits, AlignInBits, OffsetInBits, Flags);
} }
@ -298,91 +298,91 @@ static ConstantAsMetadata *getConstantOrNull(Constant *C) {
return nullptr; return nullptr;
} }
MDDerivedType *DIBuilder::createStaticMemberType(MDScope *Scope, StringRef Name, DIDerivedType *DIBuilder::createStaticMemberType(DIScope *Scope, StringRef Name,
MDFile *File, DIFile *File,
unsigned LineNumber, unsigned LineNumber,
MDType *Ty, unsigned Flags, DIType *Ty, unsigned Flags,
llvm::Constant *Val) { llvm::Constant *Val) {
Flags |= DebugNode::FlagStaticMember; Flags |= DINode::FlagStaticMember;
return MDDerivedType::get( return DIDerivedType::get(
VMContext, dwarf::DW_TAG_member, Name, File, LineNumber, VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
MDScopeRef::get(getNonCompileUnitScope(Scope)), MDTypeRef::get(Ty), 0, 0, DIScopeRef::get(getNonCompileUnitScope(Scope)), DITypeRef::get(Ty), 0, 0,
0, Flags, getConstantOrNull(Val)); 0, Flags, getConstantOrNull(Val));
} }
MDDerivedType *DIBuilder::createObjCIVar(StringRef Name, MDFile *File, DIDerivedType *DIBuilder::createObjCIVar(StringRef Name, DIFile *File,
unsigned LineNumber, unsigned LineNumber,
uint64_t SizeInBits, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t AlignInBits,
uint64_t OffsetInBits, unsigned Flags, uint64_t OffsetInBits, unsigned Flags,
MDType *Ty, MDNode *PropertyNode) { DIType *Ty, MDNode *PropertyNode) {
return MDDerivedType::get( return DIDerivedType::get(
VMContext, dwarf::DW_TAG_member, Name, File, LineNumber, VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
MDScopeRef::get(getNonCompileUnitScope(File)), MDTypeRef::get(Ty), DIScopeRef::get(getNonCompileUnitScope(File)), DITypeRef::get(Ty),
SizeInBits, AlignInBits, OffsetInBits, Flags, PropertyNode); SizeInBits, AlignInBits, OffsetInBits, Flags, PropertyNode);
} }
MDObjCProperty * DIObjCProperty *
DIBuilder::createObjCProperty(StringRef Name, MDFile *File, unsigned LineNumber, DIBuilder::createObjCProperty(StringRef Name, DIFile *File, unsigned LineNumber,
StringRef GetterName, StringRef SetterName, StringRef GetterName, StringRef SetterName,
unsigned PropertyAttributes, MDType *Ty) { unsigned PropertyAttributes, DIType *Ty) {
return MDObjCProperty::get(VMContext, Name, File, LineNumber, GetterName, return DIObjCProperty::get(VMContext, Name, File, LineNumber, GetterName,
SetterName, PropertyAttributes, Ty); SetterName, PropertyAttributes, Ty);
} }
MDTemplateTypeParameter * DITemplateTypeParameter *
DIBuilder::createTemplateTypeParameter(MDScope *Context, StringRef Name, DIBuilder::createTemplateTypeParameter(DIScope *Context, StringRef Name,
MDType *Ty) { DIType *Ty) {
assert((!Context || isa<MDCompileUnit>(Context)) && "Expected compile unit"); assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
return MDTemplateTypeParameter::get(VMContext, Name, MDTypeRef::get(Ty)); return DITemplateTypeParameter::get(VMContext, Name, DITypeRef::get(Ty));
} }
static MDTemplateValueParameter * static DITemplateValueParameter *
createTemplateValueParameterHelper(LLVMContext &VMContext, unsigned Tag, createTemplateValueParameterHelper(LLVMContext &VMContext, unsigned Tag,
MDScope *Context, StringRef Name, MDType *Ty, DIScope *Context, StringRef Name, DIType *Ty,
Metadata *MD) { Metadata *MD) {
assert((!Context || isa<MDCompileUnit>(Context)) && "Expected compile unit"); assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
return MDTemplateValueParameter::get(VMContext, Tag, Name, MDTypeRef::get(Ty), return DITemplateValueParameter::get(VMContext, Tag, Name, DITypeRef::get(Ty),
MD); MD);
} }
MDTemplateValueParameter * DITemplateValueParameter *
DIBuilder::createTemplateValueParameter(MDScope *Context, StringRef Name, DIBuilder::createTemplateValueParameter(DIScope *Context, StringRef Name,
MDType *Ty, Constant *Val) { DIType *Ty, Constant *Val) {
return createTemplateValueParameterHelper( return createTemplateValueParameterHelper(
VMContext, dwarf::DW_TAG_template_value_parameter, Context, Name, Ty, VMContext, dwarf::DW_TAG_template_value_parameter, Context, Name, Ty,
getConstantOrNull(Val)); getConstantOrNull(Val));
} }
MDTemplateValueParameter * DITemplateValueParameter *
DIBuilder::createTemplateTemplateParameter(MDScope *Context, StringRef Name, DIBuilder::createTemplateTemplateParameter(DIScope *Context, StringRef Name,
MDType *Ty, StringRef Val) { DIType *Ty, StringRef Val) {
return createTemplateValueParameterHelper( return createTemplateValueParameterHelper(
VMContext, dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty, VMContext, dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty,
MDString::get(VMContext, Val)); MDString::get(VMContext, Val));
} }
MDTemplateValueParameter * DITemplateValueParameter *
DIBuilder::createTemplateParameterPack(MDScope *Context, StringRef Name, DIBuilder::createTemplateParameterPack(DIScope *Context, StringRef Name,
MDType *Ty, DebugNodeArray Val) { DIType *Ty, DINodeArray Val) {
return createTemplateValueParameterHelper( return createTemplateValueParameterHelper(
VMContext, dwarf::DW_TAG_GNU_template_parameter_pack, Context, Name, Ty, VMContext, dwarf::DW_TAG_GNU_template_parameter_pack, Context, Name, Ty,
Val.get()); Val.get());
} }
MDCompositeType *DIBuilder::createClassType( DICompositeType *DIBuilder::createClassType(
MDScope *Context, StringRef Name, MDFile *File, unsigned LineNumber, DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
unsigned Flags, MDType *DerivedFrom, DebugNodeArray Elements, unsigned Flags, DIType *DerivedFrom, DINodeArray Elements,
MDType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) { DIType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) {
assert((!Context || isa<MDScope>(Context)) && assert((!Context || isa<DIScope>(Context)) &&
"createClassType should be called with a valid Context"); "createClassType should be called with a valid Context");
auto *R = MDCompositeType::get( auto *R = DICompositeType::get(
VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber, VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
MDScopeRef::get(getNonCompileUnitScope(Context)), DIScopeRef::get(getNonCompileUnitScope(Context)),
MDTypeRef::get(DerivedFrom), SizeInBits, AlignInBits, OffsetInBits, Flags, DITypeRef::get(DerivedFrom), SizeInBits, AlignInBits, OffsetInBits, Flags,
Elements, 0, MDTypeRef::get(VTableHolder), Elements, 0, DITypeRef::get(VTableHolder),
cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier); cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier);
if (!UniqueIdentifier.empty()) if (!UniqueIdentifier.empty())
retainType(R); retainType(R);
@ -390,29 +390,29 @@ MDCompositeType *DIBuilder::createClassType(
return R; return R;
} }
MDCompositeType *DIBuilder::createStructType( DICompositeType *DIBuilder::createStructType(
MDScope *Context, StringRef Name, MDFile *File, unsigned LineNumber, DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
MDType *DerivedFrom, DebugNodeArray Elements, unsigned RunTimeLang, DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang,
MDType *VTableHolder, StringRef UniqueIdentifier) { DIType *VTableHolder, StringRef UniqueIdentifier) {
auto *R = MDCompositeType::get( auto *R = DICompositeType::get(
VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber, VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
MDScopeRef::get(getNonCompileUnitScope(Context)), DIScopeRef::get(getNonCompileUnitScope(Context)),
MDTypeRef::get(DerivedFrom), SizeInBits, AlignInBits, 0, Flags, Elements, DITypeRef::get(DerivedFrom), SizeInBits, AlignInBits, 0, Flags, Elements,
RunTimeLang, MDTypeRef::get(VTableHolder), nullptr, UniqueIdentifier); RunTimeLang, DITypeRef::get(VTableHolder), nullptr, UniqueIdentifier);
if (!UniqueIdentifier.empty()) if (!UniqueIdentifier.empty())
retainType(R); retainType(R);
trackIfUnresolved(R); trackIfUnresolved(R);
return R; return R;
} }
MDCompositeType *DIBuilder::createUnionType( DICompositeType *DIBuilder::createUnionType(
MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNumber, DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
DebugNodeArray Elements, unsigned RunTimeLang, StringRef UniqueIdentifier) { DINodeArray Elements, unsigned RunTimeLang, StringRef UniqueIdentifier) {
auto *R = MDCompositeType::get( auto *R = DICompositeType::get(
VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber, VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber,
MDScopeRef::get(getNonCompileUnitScope(Scope)), nullptr, SizeInBits, DIScopeRef::get(getNonCompileUnitScope(Scope)), nullptr, SizeInBits,
AlignInBits, 0, Flags, Elements, RunTimeLang, nullptr, nullptr, AlignInBits, 0, Flags, Elements, RunTimeLang, nullptr, nullptr,
UniqueIdentifier); UniqueIdentifier);
if (!UniqueIdentifier.empty()) if (!UniqueIdentifier.empty())
@ -421,20 +421,20 @@ MDCompositeType *DIBuilder::createUnionType(
return R; return R;
} }
MDSubroutineType *DIBuilder::createSubroutineType(MDFile *File, DISubroutineType *DIBuilder::createSubroutineType(DIFile *File,
MDTypeRefArray ParameterTypes, DITypeRefArray ParameterTypes,
unsigned Flags) { unsigned Flags) {
return MDSubroutineType::get(VMContext, Flags, ParameterTypes); return DISubroutineType::get(VMContext, Flags, ParameterTypes);
} }
MDCompositeType *DIBuilder::createEnumerationType( DICompositeType *DIBuilder::createEnumerationType(
MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNumber, DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t AlignInBits, DebugNodeArray Elements, uint64_t SizeInBits, uint64_t AlignInBits, DINodeArray Elements,
MDType *UnderlyingType, StringRef UniqueIdentifier) { DIType *UnderlyingType, StringRef UniqueIdentifier) {
auto *CTy = MDCompositeType::get( auto *CTy = DICompositeType::get(
VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber, VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber,
MDScopeRef::get(getNonCompileUnitScope(Scope)), DIScopeRef::get(getNonCompileUnitScope(Scope)),
MDTypeRef::get(UnderlyingType), SizeInBits, AlignInBits, 0, 0, Elements, DITypeRef::get(UnderlyingType), SizeInBits, AlignInBits, 0, 0, Elements,
0, nullptr, nullptr, UniqueIdentifier); 0, nullptr, nullptr, UniqueIdentifier);
AllEnumTypes.push_back(CTy); AllEnumTypes.push_back(CTy);
if (!UniqueIdentifier.empty()) if (!UniqueIdentifier.empty())
@ -443,67 +443,67 @@ MDCompositeType *DIBuilder::createEnumerationType(
return CTy; return CTy;
} }
MDCompositeType *DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits, DICompositeType *DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
MDType *Ty, DIType *Ty,
DebugNodeArray Subscripts) { DINodeArray Subscripts) {
auto *R = MDCompositeType::get(VMContext, dwarf::DW_TAG_array_type, "", auto *R = DICompositeType::get(VMContext, dwarf::DW_TAG_array_type, "",
nullptr, 0, nullptr, MDTypeRef::get(Ty), Size, nullptr, 0, nullptr, DITypeRef::get(Ty), Size,
AlignInBits, 0, 0, Subscripts, 0, nullptr); AlignInBits, 0, 0, Subscripts, 0, nullptr);
trackIfUnresolved(R); trackIfUnresolved(R);
return R; return R;
} }
MDCompositeType *DIBuilder::createVectorType(uint64_t Size, DICompositeType *DIBuilder::createVectorType(uint64_t Size,
uint64_t AlignInBits, MDType *Ty, uint64_t AlignInBits, DIType *Ty,
DebugNodeArray Subscripts) { DINodeArray Subscripts) {
auto *R = auto *R =
MDCompositeType::get(VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0, DICompositeType::get(VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0,
nullptr, MDTypeRef::get(Ty), Size, AlignInBits, 0, nullptr, DITypeRef::get(Ty), Size, AlignInBits, 0,
DebugNode::FlagVector, Subscripts, 0, nullptr); DINode::FlagVector, Subscripts, 0, nullptr);
trackIfUnresolved(R); trackIfUnresolved(R);
return R; return R;
} }
static MDType *createTypeWithFlags(LLVMContext &Context, MDType *Ty, static DIType *createTypeWithFlags(LLVMContext &Context, DIType *Ty,
unsigned FlagsToSet) { unsigned FlagsToSet) {
auto NewTy = Ty->clone(); auto NewTy = Ty->clone();
NewTy->setFlags(NewTy->getFlags() | FlagsToSet); NewTy->setFlags(NewTy->getFlags() | FlagsToSet);
return MDNode::replaceWithUniqued(std::move(NewTy)); return MDNode::replaceWithUniqued(std::move(NewTy));
} }
MDType *DIBuilder::createArtificialType(MDType *Ty) { DIType *DIBuilder::createArtificialType(DIType *Ty) {
// FIXME: Restrict this to the nodes where it's valid. // FIXME: Restrict this to the nodes where it's valid.
if (Ty->isArtificial()) if (Ty->isArtificial())
return Ty; return Ty;
return createTypeWithFlags(VMContext, Ty, DebugNode::FlagArtificial); return createTypeWithFlags(VMContext, Ty, DINode::FlagArtificial);
} }
MDType *DIBuilder::createObjectPointerType(MDType *Ty) { DIType *DIBuilder::createObjectPointerType(DIType *Ty) {
// FIXME: Restrict this to the nodes where it's valid. // FIXME: Restrict this to the nodes where it's valid.
if (Ty->isObjectPointer()) if (Ty->isObjectPointer())
return Ty; return Ty;
unsigned Flags = DebugNode::FlagObjectPointer | DebugNode::FlagArtificial; unsigned Flags = DINode::FlagObjectPointer | DINode::FlagArtificial;
return createTypeWithFlags(VMContext, Ty, Flags); return createTypeWithFlags(VMContext, Ty, Flags);
} }
void DIBuilder::retainType(MDType *T) { void DIBuilder::retainType(DIType *T) {
assert(T && "Expected non-null type"); assert(T && "Expected non-null type");
AllRetainTypes.emplace_back(T); AllRetainTypes.emplace_back(T);
} }
MDBasicType *DIBuilder::createUnspecifiedParameter() { return nullptr; } DIBasicType *DIBuilder::createUnspecifiedParameter() { return nullptr; }
MDCompositeType* DICompositeType *
DIBuilder::createForwardDecl(unsigned Tag, StringRef Name, MDScope * Scope, DIBuilder::createForwardDecl(unsigned Tag, StringRef Name, DIScope *Scope,
MDFile* F, unsigned Line, unsigned RuntimeLang, DIFile *F, unsigned Line, unsigned RuntimeLang,
uint64_t SizeInBits, uint64_t AlignInBits, uint64_t SizeInBits, uint64_t AlignInBits,
StringRef UniqueIdentifier) { StringRef UniqueIdentifier) {
// FIXME: Define in terms of createReplaceableForwardDecl() by calling // FIXME: Define in terms of createReplaceableForwardDecl() by calling
// replaceWithUniqued(). // replaceWithUniqued().
auto *RetTy = MDCompositeType::get( auto *RetTy = DICompositeType::get(
VMContext, Tag, Name, F, Line, VMContext, Tag, Name, F, Line,
MDScopeRef::get(getNonCompileUnitScope(Scope)), nullptr, SizeInBits, DIScopeRef::get(getNonCompileUnitScope(Scope)), nullptr, SizeInBits,
AlignInBits, 0, DebugNode::FlagFwdDecl, nullptr, RuntimeLang, nullptr, AlignInBits, 0, DINode::FlagFwdDecl, nullptr, RuntimeLang, nullptr,
nullptr, UniqueIdentifier); nullptr, UniqueIdentifier);
if (!UniqueIdentifier.empty()) if (!UniqueIdentifier.empty())
retainType(RetTy); retainType(RetTy);
@ -511,118 +511,119 @@ DIBuilder::createForwardDecl(unsigned Tag, StringRef Name, MDScope * Scope,
return RetTy; return RetTy;
} }
MDCompositeType* DIBuilder::createReplaceableCompositeType( DICompositeType *DIBuilder::createReplaceableCompositeType(
unsigned Tag, StringRef Name, MDScope * Scope, MDFile* F, unsigned Line, unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
unsigned RuntimeLang, uint64_t SizeInBits, uint64_t AlignInBits, unsigned RuntimeLang, uint64_t SizeInBits, uint64_t AlignInBits,
unsigned Flags, StringRef UniqueIdentifier) { unsigned Flags, StringRef UniqueIdentifier) {
auto *RetTy = MDCompositeType::getTemporary( auto *RetTy = DICompositeType::getTemporary(
VMContext, Tag, Name, F, Line, VMContext, Tag, Name, F, Line,
MDScopeRef::get(getNonCompileUnitScope(Scope)), nullptr, DIScopeRef::get(getNonCompileUnitScope(Scope)), nullptr,
SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang, SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang,
nullptr, nullptr, UniqueIdentifier).release(); nullptr, nullptr, UniqueIdentifier)
.release();
if (!UniqueIdentifier.empty()) if (!UniqueIdentifier.empty())
retainType(RetTy); retainType(RetTy);
trackIfUnresolved(RetTy); trackIfUnresolved(RetTy);
return RetTy; return RetTy;
} }
DebugNodeArray DIBuilder::getOrCreateArray(ArrayRef<Metadata *> Elements) { DINodeArray DIBuilder::getOrCreateArray(ArrayRef<Metadata *> Elements) {
return MDTuple::get(VMContext, Elements); return MDTuple::get(VMContext, Elements);
} }
MDTypeRefArray DIBuilder::getOrCreateTypeArray(ArrayRef<Metadata *> Elements) { DITypeRefArray DIBuilder::getOrCreateTypeArray(ArrayRef<Metadata *> Elements) {
SmallVector<llvm::Metadata *, 16> Elts; SmallVector<llvm::Metadata *, 16> Elts;
for (unsigned i = 0, e = Elements.size(); i != e; ++i) { for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
if (Elements[i] && isa<MDNode>(Elements[i])) if (Elements[i] && isa<MDNode>(Elements[i]))
Elts.push_back(MDTypeRef::get(cast<MDType>(Elements[i]))); Elts.push_back(DITypeRef::get(cast<DIType>(Elements[i])));
else else
Elts.push_back(Elements[i]); Elts.push_back(Elements[i]);
} }
return MDTypeRefArray(MDNode::get(VMContext, Elts)); return DITypeRefArray(MDNode::get(VMContext, Elts));
} }
MDSubrange *DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) { DISubrange *DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) {
return MDSubrange::get(VMContext, Count, Lo); return DISubrange::get(VMContext, Count, Lo);
} }
static void checkGlobalVariableScope(MDScope * Context) { static void checkGlobalVariableScope(DIScope *Context) {
#ifndef NDEBUG #ifndef NDEBUG
if (auto *CT = if (auto *CT =
dyn_cast_or_null<MDCompositeType>(getNonCompileUnitScope(Context))) dyn_cast_or_null<DICompositeType>(getNonCompileUnitScope(Context)))
assert(CT->getIdentifier().empty() && assert(CT->getIdentifier().empty() &&
"Context of a global variable should not be a type with identifier"); "Context of a global variable should not be a type with identifier");
#endif #endif
} }
MDGlobalVariable *DIBuilder::createGlobalVariable( DIGlobalVariable *DIBuilder::createGlobalVariable(
MDScope *Context, StringRef Name, StringRef LinkageName, MDFile *F, DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
unsigned LineNumber, MDType *Ty, bool isLocalToUnit, Constant *Val, unsigned LineNumber, DIType *Ty, bool isLocalToUnit, Constant *Val,
MDNode *Decl) { MDNode *Decl) {
checkGlobalVariableScope(Context); checkGlobalVariableScope(Context);
auto *N = MDGlobalVariable::get(VMContext, cast_or_null<MDScope>(Context), auto *N = DIGlobalVariable::get(VMContext, cast_or_null<DIScope>(Context),
Name, LinkageName, F, LineNumber, Name, LinkageName, F, LineNumber,
MDTypeRef::get(Ty), isLocalToUnit, true, Val, DITypeRef::get(Ty), isLocalToUnit, true, Val,
cast_or_null<MDDerivedType>(Decl)); cast_or_null<DIDerivedType>(Decl));
AllGVs.push_back(N); AllGVs.push_back(N);
return N; return N;
} }
MDGlobalVariable *DIBuilder::createTempGlobalVariableFwdDecl( DIGlobalVariable *DIBuilder::createTempGlobalVariableFwdDecl(
MDScope *Context, StringRef Name, StringRef LinkageName, MDFile *F, DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
unsigned LineNumber, MDType *Ty, bool isLocalToUnit, Constant *Val, unsigned LineNumber, DIType *Ty, bool isLocalToUnit, Constant *Val,
MDNode *Decl) { MDNode *Decl) {
checkGlobalVariableScope(Context); checkGlobalVariableScope(Context);
return MDGlobalVariable::getTemporary( return DIGlobalVariable::getTemporary(
VMContext, cast_or_null<MDScope>(Context), Name, LinkageName, F, VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
LineNumber, MDTypeRef::get(Ty), isLocalToUnit, false, Val, LineNumber, DITypeRef::get(Ty), isLocalToUnit, false, Val,
cast_or_null<MDDerivedType>(Decl)) cast_or_null<DIDerivedType>(Decl))
.release(); .release();
} }
MDLocalVariable *DIBuilder::createLocalVariable( DILocalVariable *DIBuilder::createLocalVariable(
unsigned Tag, MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNo, unsigned Tag, DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo,
MDType *Ty, bool AlwaysPreserve, unsigned Flags, unsigned ArgNo) { DIType *Ty, bool AlwaysPreserve, unsigned Flags, unsigned ArgNo) {
// FIXME: Why getNonCompileUnitScope()? // FIXME: Why getNonCompileUnitScope()?
// FIXME: Why is "!Context" okay here? // FIXME: Why is "!Context" okay here?
// FIXME: WHy doesn't this check for a subprogram or lexical block (AFAICT // FIXME: WHy doesn't this check for a subprogram or lexical block (AFAICT
// the only valid scopes)? // the only valid scopes)?
MDScope* Context = getNonCompileUnitScope(Scope); DIScope *Context = getNonCompileUnitScope(Scope);
auto *Node = MDLocalVariable::get( auto *Node = DILocalVariable::get(
VMContext, Tag, cast_or_null<MDLocalScope>(Context), Name, File, LineNo, VMContext, Tag, cast_or_null<DILocalScope>(Context), Name, File, LineNo,
MDTypeRef::get(Ty), ArgNo, Flags); DITypeRef::get(Ty), ArgNo, Flags);
if (AlwaysPreserve) { if (AlwaysPreserve) {
// The optimizer may remove local variable. If there is an interest // The optimizer may remove local variable. If there is an interest
// to preserve variable info in such situation then stash it in a // to preserve variable info in such situation then stash it in a
// named mdnode. // named mdnode.
MDSubprogram *Fn = getDISubprogram(Scope); DISubprogram *Fn = getDISubprogram(Scope);
assert(Fn && "Missing subprogram for local variable"); assert(Fn && "Missing subprogram for local variable");
PreservedVariables[Fn].emplace_back(Node); PreservedVariables[Fn].emplace_back(Node);
} }
return Node; return Node;
} }
MDExpression* DIBuilder::createExpression(ArrayRef<uint64_t> Addr) { DIExpression *DIBuilder::createExpression(ArrayRef<uint64_t> Addr) {
return MDExpression::get(VMContext, Addr); return DIExpression::get(VMContext, Addr);
} }
MDExpression* DIBuilder::createExpression(ArrayRef<int64_t> Signed) { DIExpression *DIBuilder::createExpression(ArrayRef<int64_t> Signed) {
// TODO: Remove the callers of this signed version and delete. // TODO: Remove the callers of this signed version and delete.
SmallVector<uint64_t, 8> Addr(Signed.begin(), Signed.end()); SmallVector<uint64_t, 8> Addr(Signed.begin(), Signed.end());
return createExpression(Addr); return createExpression(Addr);
} }
MDExpression* DIBuilder::createBitPieceExpression(unsigned OffsetInBytes, DIExpression *DIBuilder::createBitPieceExpression(unsigned OffsetInBytes,
unsigned SizeInBytes) { unsigned SizeInBytes) {
uint64_t Addr[] = {dwarf::DW_OP_bit_piece, OffsetInBytes, SizeInBytes}; uint64_t Addr[] = {dwarf::DW_OP_bit_piece, OffsetInBytes, SizeInBytes};
return MDExpression::get(VMContext, Addr); return DIExpression::get(VMContext, Addr);
} }
MDSubprogram *DIBuilder::createFunction(MDScopeRef Context, StringRef Name, DISubprogram *DIBuilder::createFunction(DIScopeRef Context, StringRef Name,
StringRef LinkageName, MDFile *File, StringRef LinkageName, DIFile *File,
unsigned LineNo, MDSubroutineType *Ty, unsigned LineNo, DISubroutineType *Ty,
bool isLocalToUnit, bool isDefinition, bool isLocalToUnit, bool isDefinition,
unsigned ScopeLine, unsigned Flags, unsigned ScopeLine, unsigned Flags,
bool isOptimized, Function *Fn, bool isOptimized, Function *Fn,
@ -635,20 +636,20 @@ MDSubprogram *DIBuilder::createFunction(MDScopeRef Context, StringRef Name,
Flags, isOptimized, Fn, TParams, Decl); Flags, isOptimized, Fn, TParams, Decl);
} }
MDSubprogram* DIBuilder::createFunction(MDScope * Context, StringRef Name, DISubprogram *DIBuilder::createFunction(DIScope *Context, StringRef Name,
StringRef LinkageName, MDFile* File, StringRef LinkageName, DIFile *File,
unsigned LineNo, MDSubroutineType* Ty, unsigned LineNo, DISubroutineType *Ty,
bool isLocalToUnit, bool isDefinition, bool isLocalToUnit, bool isDefinition,
unsigned ScopeLine, unsigned Flags, unsigned ScopeLine, unsigned Flags,
bool isOptimized, Function *Fn, bool isOptimized, Function *Fn,
MDNode *TParams, MDNode *Decl) { MDNode *TParams, MDNode *Decl) {
assert(Ty->getTag() == dwarf::DW_TAG_subroutine_type && assert(Ty->getTag() == dwarf::DW_TAG_subroutine_type &&
"function types should be subroutines"); "function types should be subroutines");
auto *Node = MDSubprogram::get( auto *Node = DISubprogram::get(
VMContext, MDScopeRef::get(getNonCompileUnitScope(Context)), Name, VMContext, DIScopeRef::get(getNonCompileUnitScope(Context)), Name,
LinkageName, File, LineNo, Ty, LinkageName, File, LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine,
isLocalToUnit, isDefinition, ScopeLine, nullptr, 0, 0, Flags, isOptimized, nullptr, 0, 0, Flags, isOptimized, Fn, cast_or_null<MDTuple>(TParams),
Fn, cast_or_null<MDTuple>(TParams), cast_or_null<MDSubprogram>(Decl), cast_or_null<DISubprogram>(Decl),
MDTuple::getTemporary(VMContext, None).release()); MDTuple::getTemporary(VMContext, None).release());
if (isDefinition) if (isDefinition)
@ -657,27 +658,25 @@ MDSubprogram* DIBuilder::createFunction(MDScope * Context, StringRef Name,
return Node; return Node;
} }
MDSubprogram* DISubprogram *DIBuilder::createTempFunctionFwdDecl(
DIBuilder::createTempFunctionFwdDecl(MDScope * Context, StringRef Name, DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
StringRef LinkageName, MDFile* File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
unsigned LineNo, MDSubroutineType* Ty, bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized,
bool isLocalToUnit, bool isDefinition, Function *Fn, MDNode *TParams, MDNode *Decl) {
unsigned ScopeLine, unsigned Flags, return DISubprogram::getTemporary(
bool isOptimized, Function *Fn, VMContext, DIScopeRef::get(getNonCompileUnitScope(Context)), Name,
MDNode *TParams, MDNode *Decl) { LinkageName, File, LineNo, Ty, isLocalToUnit, isDefinition,
return MDSubprogram::getTemporary( ScopeLine, nullptr, 0, 0, Flags, isOptimized, Fn,
VMContext, MDScopeRef::get(getNonCompileUnitScope(Context)), Name, cast_or_null<MDTuple>(TParams), cast_or_null<DISubprogram>(Decl),
LinkageName, File, LineNo, Ty, nullptr)
isLocalToUnit, isDefinition, ScopeLine, nullptr, 0, 0, Flags, .release();
isOptimized, Fn, cast_or_null<MDTuple>(TParams),
cast_or_null<MDSubprogram>(Decl), nullptr).release();
} }
MDSubprogram * DISubprogram *
DIBuilder::createMethod(MDScope *Context, StringRef Name, StringRef LinkageName, DIBuilder::createMethod(DIScope *Context, StringRef Name, StringRef LinkageName,
MDFile *F, unsigned LineNo, MDSubroutineType *Ty, DIFile *F, unsigned LineNo, DISubroutineType *Ty,
bool isLocalToUnit, bool isDefinition, unsigned VK, bool isLocalToUnit, bool isDefinition, unsigned VK,
unsigned VIndex, MDType *VTableHolder, unsigned Flags, unsigned VIndex, DIType *VTableHolder, unsigned Flags,
bool isOptimized, Function *Fn, MDNode *TParam) { bool isOptimized, Function *Fn, MDNode *TParam) {
assert(Ty->getTag() == dwarf::DW_TAG_subroutine_type && assert(Ty->getTag() == dwarf::DW_TAG_subroutine_type &&
"function types should be subroutines"); "function types should be subroutines");
@ -685,10 +684,10 @@ DIBuilder::createMethod(MDScope *Context, StringRef Name, StringRef LinkageName,
"Methods should have both a Context and a context that isn't " "Methods should have both a Context and a context that isn't "
"the compile unit."); "the compile unit.");
// FIXME: Do we want to use different scope/lines? // FIXME: Do we want to use different scope/lines?
auto *SP = MDSubprogram::get( auto *SP = DISubprogram::get(
VMContext, MDScopeRef::get(cast<MDScope>(Context)), Name, LinkageName, F, VMContext, DIScopeRef::get(cast<DIScope>(Context)), Name, LinkageName, F,
LineNo, Ty, isLocalToUnit, isDefinition, LineNo, LineNo, Ty, isLocalToUnit, isDefinition, LineNo,
MDTypeRef::get(VTableHolder), VK, VIndex, Flags, isOptimized, Fn, DITypeRef::get(VTableHolder), VK, VIndex, Flags, isOptimized, Fn,
cast_or_null<MDTuple>(TParam), nullptr, nullptr); cast_or_null<MDTuple>(TParam), nullptr, nullptr);
if (isDefinition) if (isDefinition)
@ -697,23 +696,23 @@ DIBuilder::createMethod(MDScope *Context, StringRef Name, StringRef LinkageName,
return SP; return SP;
} }
MDNamespace* DIBuilder::createNameSpace(MDScope * Scope, StringRef Name, DINamespace *DIBuilder::createNameSpace(DIScope *Scope, StringRef Name,
MDFile* File, unsigned LineNo) { DIFile *File, unsigned LineNo) {
return MDNamespace::get(VMContext, getNonCompileUnitScope(Scope), File, Name, return DINamespace::get(VMContext, getNonCompileUnitScope(Scope), File, Name,
LineNo); LineNo);
} }
MDLexicalBlockFile* DIBuilder::createLexicalBlockFile(MDScope * Scope, DILexicalBlockFile *DIBuilder::createLexicalBlockFile(DIScope *Scope,
MDFile* File, DIFile *File,
unsigned Discriminator) { unsigned Discriminator) {
return MDLexicalBlockFile::get(VMContext, Scope, File, Discriminator); return DILexicalBlockFile::get(VMContext, Scope, File, Discriminator);
} }
MDLexicalBlock* DIBuilder::createLexicalBlock(MDScope * Scope, MDFile* File, DILexicalBlock *DIBuilder::createLexicalBlock(DIScope *Scope, DIFile *File,
unsigned Line, unsigned Col) { unsigned Line, unsigned Col) {
// Make these distinct, to avoid merging two lexical blocks on the same // Make these distinct, to avoid merging two lexical blocks on the same
// file/line/column. // file/line/column.
return MDLexicalBlock::getDistinct(VMContext, getNonCompileUnitScope(Scope), return DILexicalBlock::getDistinct(VMContext, getNonCompileUnitScope(Scope),
File, Line, Col); File, Line, Col);
} }
@ -722,15 +721,15 @@ static Value *getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V) {
return MetadataAsValue::get(VMContext, ValueAsMetadata::get(V)); return MetadataAsValue::get(VMContext, ValueAsMetadata::get(V));
} }
static Instruction *withDebugLoc(Instruction *I, const MDLocation *DL) { static Instruction *withDebugLoc(Instruction *I, const DILocation *DL) {
I->setDebugLoc(const_cast<MDLocation *>(DL)); I->setDebugLoc(const_cast<DILocation *>(DL));
return I; return I;
} }
Instruction *DIBuilder::insertDeclare(Value *Storage, MDLocalVariable* VarInfo, Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
MDExpression* Expr, const MDLocation *DL, DIExpression *Expr, const DILocation *DL,
Instruction *InsertBefore) { Instruction *InsertBefore) {
assert(VarInfo && "empty or invalid MDLocalVariable* passed to dbg.declare"); assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
assert(DL && "Expected debug loc"); assert(DL && "Expected debug loc");
assert(DL->getScope()->getSubprogram() == assert(DL->getScope()->getSubprogram() ==
VarInfo->getScope()->getSubprogram() && VarInfo->getScope()->getSubprogram() &&
@ -746,10 +745,10 @@ Instruction *DIBuilder::insertDeclare(Value *Storage, MDLocalVariable* VarInfo,
return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertBefore), DL); return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertBefore), DL);
} }
Instruction *DIBuilder::insertDeclare(Value *Storage, MDLocalVariable* VarInfo, Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
MDExpression* Expr, const MDLocation *DL, DIExpression *Expr, const DILocation *DL,
BasicBlock *InsertAtEnd) { BasicBlock *InsertAtEnd) {
assert(VarInfo && "empty or invalid MDLocalVariable* passed to dbg.declare"); assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
assert(DL && "Expected debug loc"); assert(DL && "Expected debug loc");
assert(DL->getScope()->getSubprogram() == assert(DL->getScope()->getSubprogram() ==
VarInfo->getScope()->getSubprogram() && VarInfo->getScope()->getSubprogram() &&
@ -771,12 +770,12 @@ Instruction *DIBuilder::insertDeclare(Value *Storage, MDLocalVariable* VarInfo,
} }
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset, Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
MDLocalVariable* VarInfo, DILocalVariable *VarInfo,
MDExpression* Expr, DIExpression *Expr,
const MDLocation *DL, const DILocation *DL,
Instruction *InsertBefore) { Instruction *InsertBefore) {
assert(V && "no value passed to dbg.value"); assert(V && "no value passed to dbg.value");
assert(VarInfo && "empty or invalid MDLocalVariable* passed to dbg.value"); assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.value");
assert(DL && "Expected debug loc"); assert(DL && "Expected debug loc");
assert(DL->getScope()->getSubprogram() == assert(DL->getScope()->getSubprogram() ==
VarInfo->getScope()->getSubprogram() && VarInfo->getScope()->getSubprogram() &&
@ -794,12 +793,12 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
} }
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset, Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
MDLocalVariable* VarInfo, DILocalVariable *VarInfo,
MDExpression* Expr, DIExpression *Expr,
const MDLocation *DL, const DILocation *DL,
BasicBlock *InsertAtEnd) { BasicBlock *InsertAtEnd) {
assert(V && "no value passed to dbg.value"); assert(V && "no value passed to dbg.value");
assert(VarInfo && "empty or invalid MDLocalVariable* passed to dbg.value"); assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.value");
assert(DL && "Expected debug loc"); assert(DL && "Expected debug loc");
assert(DL->getScope()->getSubprogram() == assert(DL->getScope()->getSubprogram() ==
VarInfo->getScope()->getSubprogram() && VarInfo->getScope()->getSubprogram() &&
@ -817,10 +816,11 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertAtEnd), DL); return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertAtEnd), DL);
} }
void DIBuilder::replaceVTableHolder(MDCompositeType* &T, MDCompositeType* VTableHolder) { void DIBuilder::replaceVTableHolder(DICompositeType *&T,
DICompositeType *VTableHolder) {
{ {
TypedTrackingMDRef<MDCompositeType> N(T); TypedTrackingMDRef<DICompositeType> N(T);
N->replaceVTableHolder(MDTypeRef::get(VTableHolder)); N->replaceVTableHolder(DITypeRef::get(VTableHolder));
T = N.get(); T = N.get();
} }
@ -836,14 +836,14 @@ void DIBuilder::replaceVTableHolder(MDCompositeType* &T, MDCompositeType* VTable
trackIfUnresolved(N); trackIfUnresolved(N);
} }
void DIBuilder::replaceArrays(MDCompositeType *&T, DebugNodeArray Elements, void DIBuilder::replaceArrays(DICompositeType *&T, DINodeArray Elements,
DebugNodeArray TParams) { DINodeArray TParams) {
{ {
TypedTrackingMDRef<MDCompositeType> N(T); TypedTrackingMDRef<DICompositeType> N(T);
if (Elements) if (Elements)
N->replaceElements(Elements); N->replaceElements(Elements);
if (TParams) if (TParams)
N->replaceTemplateParams(MDTemplateParameterArray(TParams)); N->replaceTemplateParams(DITemplateParameterArray(TParams));
T = N.get(); T = N.get();
} }

View File

@ -33,13 +33,13 @@
using namespace llvm; using namespace llvm;
using namespace llvm::dwarf; using namespace llvm::dwarf;
MDSubprogram *llvm::getDISubprogram(const MDNode *Scope) { DISubprogram *llvm::getDISubprogram(const MDNode *Scope) {
if (auto *LocalScope = dyn_cast_or_null<MDLocalScope>(Scope)) if (auto *LocalScope = dyn_cast_or_null<DILocalScope>(Scope))
return LocalScope->getSubprogram(); return LocalScope->getSubprogram();
return nullptr; return nullptr;
} }
MDSubprogram *llvm::getDISubprogram(const Function *F) { DISubprogram *llvm::getDISubprogram(const Function *F) {
// We look for the first instr that has a debug annotation leading back to F. // We look for the first instr that has a debug annotation leading back to F.
for (auto &BB : *F) { for (auto &BB : *F) {
auto Inst = std::find_if(BB.begin(), BB.end(), [](const Instruction &Inst) { auto Inst = std::find_if(BB.begin(), BB.end(), [](const Instruction &Inst) {
@ -56,11 +56,11 @@ MDSubprogram *llvm::getDISubprogram(const Function *F) {
return nullptr; return nullptr;
} }
MDCompositeTypeBase *llvm::getDICompositeType(MDType *T) { DICompositeTypeBase *llvm::getDICompositeType(DIType *T) {
if (auto *C = dyn_cast_or_null<MDCompositeTypeBase>(T)) if (auto *C = dyn_cast_or_null<DICompositeTypeBase>(T))
return C; return C;
if (auto *D = dyn_cast_or_null<MDDerivedTypeBase>(T)) { if (auto *D = dyn_cast_or_null<DIDerivedTypeBase>(T)) {
// This function is currently used by dragonegg and dragonegg does // This function is currently used by dragonegg and dragonegg does
// not generate identifier for types, so using an empty map to resolve // not generate identifier for types, so using an empty map to resolve
// DerivedFrom should be fine. // DerivedFrom should be fine.
@ -75,12 +75,12 @@ DITypeIdentifierMap
llvm::generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes) { llvm::generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes) {
DITypeIdentifierMap Map; DITypeIdentifierMap Map;
for (unsigned CUi = 0, CUe = CU_Nodes->getNumOperands(); CUi != CUe; ++CUi) { for (unsigned CUi = 0, CUe = CU_Nodes->getNumOperands(); CUi != CUe; ++CUi) {
auto *CU = cast<MDCompileUnit>(CU_Nodes->getOperand(CUi)); auto *CU = cast<DICompileUnit>(CU_Nodes->getOperand(CUi));
DebugNodeArray Retain = CU->getRetainedTypes(); DINodeArray Retain = CU->getRetainedTypes();
for (unsigned Ti = 0, Te = Retain.size(); Ti != Te; ++Ti) { for (unsigned Ti = 0, Te = Retain.size(); Ti != Te; ++Ti) {
if (!isa<MDCompositeType>(Retain[Ti])) if (!isa<DICompositeType>(Retain[Ti]))
continue; continue;
auto *Ty = cast<MDCompositeType>(Retain[Ti]); auto *Ty = cast<DICompositeType>(Retain[Ti]);
if (MDString *TypeId = Ty->getRawIdentifier()) { if (MDString *TypeId = Ty->getRawIdentifier()) {
// Definition has priority over declaration. // Definition has priority over declaration.
// Try to insert (TypeId, Ty) to Map. // Try to insert (TypeId, Ty) to Map.
@ -123,7 +123,7 @@ void DebugInfoFinder::processModule(const Module &M) {
InitializeTypeMap(M); InitializeTypeMap(M);
if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) { if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) { for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
auto *CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i)); auto *CU = cast<DICompileUnit>(CU_Nodes->getOperand(i));
addCompileUnit(CU); addCompileUnit(CU);
for (auto *DIG : CU->getGlobalVariables()) { for (auto *DIG : CU->getGlobalVariables()) {
if (addGlobalVariable(DIG)) { if (addGlobalVariable(DIG)) {
@ -139,18 +139,18 @@ void DebugInfoFinder::processModule(const Module &M) {
processType(RT); processType(RT);
for (auto *Import : CU->getImportedEntities()) { for (auto *Import : CU->getImportedEntities()) {
auto *Entity = Import->getEntity().resolve(TypeIdentifierMap); auto *Entity = Import->getEntity().resolve(TypeIdentifierMap);
if (auto *T = dyn_cast<MDType>(Entity)) if (auto *T = dyn_cast<DIType>(Entity))
processType(T); processType(T);
else if (auto *SP = dyn_cast<MDSubprogram>(Entity)) else if (auto *SP = dyn_cast<DISubprogram>(Entity))
processSubprogram(SP); processSubprogram(SP);
else if (auto *NS = dyn_cast<MDNamespace>(Entity)) else if (auto *NS = dyn_cast<DINamespace>(Entity))
processScope(NS->getScope()); processScope(NS->getScope());
} }
} }
} }
} }
void DebugInfoFinder::processLocation(const Module &M, const MDLocation *Loc) { void DebugInfoFinder::processLocation(const Module &M, const DILocation *Loc) {
if (!Loc) if (!Loc)
return; return;
InitializeTypeMap(M); InitializeTypeMap(M);
@ -158,61 +158,61 @@ void DebugInfoFinder::processLocation(const Module &M, const MDLocation *Loc) {
processLocation(M, Loc->getInlinedAt()); processLocation(M, Loc->getInlinedAt());
} }
void DebugInfoFinder::processType(MDType *DT) { void DebugInfoFinder::processType(DIType *DT) {
if (!addType(DT)) if (!addType(DT))
return; return;
processScope(DT->getScope().resolve(TypeIdentifierMap)); processScope(DT->getScope().resolve(TypeIdentifierMap));
if (auto *DCT = dyn_cast<MDCompositeTypeBase>(DT)) { if (auto *DCT = dyn_cast<DICompositeTypeBase>(DT)) {
processType(DCT->getBaseType().resolve(TypeIdentifierMap)); processType(DCT->getBaseType().resolve(TypeIdentifierMap));
if (auto *ST = dyn_cast<MDSubroutineType>(DCT)) { if (auto *ST = dyn_cast<DISubroutineType>(DCT)) {
for (MDTypeRef Ref : ST->getTypeArray()) for (DITypeRef Ref : ST->getTypeArray())
processType(Ref.resolve(TypeIdentifierMap)); processType(Ref.resolve(TypeIdentifierMap));
return; return;
} }
for (Metadata *D : DCT->getElements()) { for (Metadata *D : DCT->getElements()) {
if (auto *T = dyn_cast<MDType>(D)) if (auto *T = dyn_cast<DIType>(D))
processType(T); processType(T);
else if (auto *SP = dyn_cast<MDSubprogram>(D)) else if (auto *SP = dyn_cast<DISubprogram>(D))
processSubprogram(SP); processSubprogram(SP);
} }
} else if (auto *DDT = dyn_cast<MDDerivedTypeBase>(DT)) { } else if (auto *DDT = dyn_cast<DIDerivedTypeBase>(DT)) {
processType(DDT->getBaseType().resolve(TypeIdentifierMap)); processType(DDT->getBaseType().resolve(TypeIdentifierMap));
} }
} }
void DebugInfoFinder::processScope(MDScope *Scope) { void DebugInfoFinder::processScope(DIScope *Scope) {
if (!Scope) if (!Scope)
return; return;
if (auto *Ty = dyn_cast<MDType>(Scope)) { if (auto *Ty = dyn_cast<DIType>(Scope)) {
processType(Ty); processType(Ty);
return; return;
} }
if (auto *CU = dyn_cast<MDCompileUnit>(Scope)) { if (auto *CU = dyn_cast<DICompileUnit>(Scope)) {
addCompileUnit(CU); addCompileUnit(CU);
return; return;
} }
if (auto *SP = dyn_cast<MDSubprogram>(Scope)) { if (auto *SP = dyn_cast<DISubprogram>(Scope)) {
processSubprogram(SP); processSubprogram(SP);
return; return;
} }
if (!addScope(Scope)) if (!addScope(Scope))
return; return;
if (auto *LB = dyn_cast<MDLexicalBlockBase>(Scope)) { if (auto *LB = dyn_cast<DILexicalBlockBase>(Scope)) {
processScope(LB->getScope()); processScope(LB->getScope());
} else if (auto *NS = dyn_cast<MDNamespace>(Scope)) { } else if (auto *NS = dyn_cast<DINamespace>(Scope)) {
processScope(NS->getScope()); processScope(NS->getScope());
} }
} }
void DebugInfoFinder::processSubprogram(MDSubprogram *SP) { void DebugInfoFinder::processSubprogram(DISubprogram *SP) {
if (!addSubprogram(SP)) if (!addSubprogram(SP))
return; return;
processScope(SP->getScope().resolve(TypeIdentifierMap)); processScope(SP->getScope().resolve(TypeIdentifierMap));
processType(SP->getType()); processType(SP->getType());
for (auto *Element : SP->getTemplateParams()) { for (auto *Element : SP->getTemplateParams()) {
if (auto *TType = dyn_cast<MDTemplateTypeParameter>(Element)) { if (auto *TType = dyn_cast<DITemplateTypeParameter>(Element)) {
processType(TType->getType().resolve(TypeIdentifierMap)); processType(TType->getType().resolve(TypeIdentifierMap));
} else if (auto *TVal = dyn_cast<MDTemplateValueParameter>(Element)) { } else if (auto *TVal = dyn_cast<DITemplateValueParameter>(Element)) {
processType(TVal->getType().resolve(TypeIdentifierMap)); processType(TVal->getType().resolve(TypeIdentifierMap));
} }
} }
@ -225,7 +225,7 @@ void DebugInfoFinder::processDeclare(const Module &M,
return; return;
InitializeTypeMap(M); InitializeTypeMap(M);
auto *DV = dyn_cast<MDLocalVariable>(N); auto *DV = dyn_cast<DILocalVariable>(N);
if (!DV) if (!DV)
return; return;
@ -241,7 +241,7 @@ void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) {
return; return;
InitializeTypeMap(M); InitializeTypeMap(M);
auto *DV = dyn_cast<MDLocalVariable>(N); auto *DV = dyn_cast<DILocalVariable>(N);
if (!DV) if (!DV)
return; return;
@ -251,18 +251,18 @@ void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) {
processType(DV->getType().resolve(TypeIdentifierMap)); processType(DV->getType().resolve(TypeIdentifierMap));
} }
bool DebugInfoFinder::addType(MDType *DT) { bool DebugInfoFinder::addType(DIType *DT) {
if (!DT) if (!DT)
return false; return false;
if (!NodesSeen.insert(DT).second) if (!NodesSeen.insert(DT).second)
return false; return false;
TYs.push_back(const_cast<MDType *>(DT)); TYs.push_back(const_cast<DIType *>(DT));
return true; return true;
} }
bool DebugInfoFinder::addCompileUnit(MDCompileUnit *CU) { bool DebugInfoFinder::addCompileUnit(DICompileUnit *CU) {
if (!CU) if (!CU)
return false; return false;
if (!NodesSeen.insert(CU).second) if (!NodesSeen.insert(CU).second)
@ -272,7 +272,7 @@ bool DebugInfoFinder::addCompileUnit(MDCompileUnit *CU) {
return true; return true;
} }
bool DebugInfoFinder::addGlobalVariable(MDGlobalVariable *DIG) { bool DebugInfoFinder::addGlobalVariable(DIGlobalVariable *DIG) {
if (!DIG) if (!DIG)
return false; return false;
@ -283,7 +283,7 @@ bool DebugInfoFinder::addGlobalVariable(MDGlobalVariable *DIG) {
return true; return true;
} }
bool DebugInfoFinder::addSubprogram(MDSubprogram *SP) { bool DebugInfoFinder::addSubprogram(DISubprogram *SP) {
if (!SP) if (!SP)
return false; return false;
@ -294,7 +294,7 @@ bool DebugInfoFinder::addSubprogram(MDSubprogram *SP) {
return true; return true;
} }
bool DebugInfoFinder::addScope(MDScope *Scope) { bool DebugInfoFinder::addScope(DIScope *Scope) {
if (!Scope) if (!Scope)
return false; return false;
// FIXME: Ocaml binding generates a scope with no content, we treat it // FIXME: Ocaml binding generates a scope with no content, we treat it
@ -369,16 +369,16 @@ unsigned llvm::getDebugMetadataVersionFromModule(const Module &M) {
return 0; return 0;
} }
DenseMap<const llvm::Function *, MDSubprogram *> DenseMap<const llvm::Function *, DISubprogram *>
llvm::makeSubprogramMap(const Module &M) { llvm::makeSubprogramMap(const Module &M) {
DenseMap<const Function *, MDSubprogram *> R; DenseMap<const Function *, DISubprogram *> R;
NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu"); NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu");
if (!CU_Nodes) if (!CU_Nodes)
return R; return R;
for (MDNode *N : CU_Nodes->operands()) { for (MDNode *N : CU_Nodes->operands()) {
auto *CUNode = cast<MDCompileUnit>(N); auto *CUNode = cast<DICompileUnit>(N);
for (auto *SP : CUNode->getSubprograms()) { for (auto *SP : CUNode->getSubprograms()) {
if (Function *F = SP->getFunction()) if (Function *F = SP->getFunction())
R.insert(std::make_pair(F, SP)); R.insert(std::make_pair(F, SP));

View File

@ -19,9 +19,9 @@
using namespace llvm; using namespace llvm;
MDLocation::MDLocation(LLVMContext &C, StorageType Storage, unsigned Line, DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
unsigned Column, ArrayRef<Metadata *> MDs) unsigned Column, ArrayRef<Metadata *> MDs)
: MDNode(C, MDLocationKind, Storage, MDs) { : MDNode(C, DILocationKind, Storage, MDs) {
assert((MDs.size() == 1 || MDs.size() == 2) && assert((MDs.size() == 1 || MDs.size() == 2) &&
"Expected a scope and optional inlined-at"); "Expected a scope and optional inlined-at");
@ -38,7 +38,7 @@ static void adjustColumn(unsigned &Column) {
Column = 0; Column = 0;
} }
MDLocation *MDLocation::getImpl(LLVMContext &Context, unsigned Line, DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line,
unsigned Column, Metadata *Scope, unsigned Column, Metadata *Scope,
Metadata *InlinedAt, StorageType Storage, Metadata *InlinedAt, StorageType Storage,
bool ShouldCreate) { bool ShouldCreate) {
@ -48,8 +48,8 @@ MDLocation *MDLocation::getImpl(LLVMContext &Context, unsigned Line,
assert(Scope && "Expected scope"); assert(Scope && "Expected scope");
if (Storage == Uniqued) { if (Storage == Uniqued) {
if (auto *N = if (auto *N =
getUniqued(Context.pImpl->MDLocations, getUniqued(Context.pImpl->DILocations,
MDLocationInfo::KeyTy(Line, Column, Scope, InlinedAt))) DILocationInfo::KeyTy(Line, Column, Scope, InlinedAt)))
return N; return N;
if (!ShouldCreate) if (!ShouldCreate)
return nullptr; return nullptr;
@ -62,11 +62,11 @@ MDLocation *MDLocation::getImpl(LLVMContext &Context, unsigned Line,
if (InlinedAt) if (InlinedAt)
Ops.push_back(InlinedAt); Ops.push_back(InlinedAt);
return storeImpl(new (Ops.size()) return storeImpl(new (Ops.size())
MDLocation(Context, Storage, Line, Column, Ops), DILocation(Context, Storage, Line, Column, Ops),
Storage, Context.pImpl->MDLocations); Storage, Context.pImpl->DILocations);
} }
unsigned MDLocation::computeNewDiscriminator() const { unsigned DILocation::computeNewDiscriminator() const {
// FIXME: This seems completely wrong. // FIXME: This seems completely wrong.
// //
// 1. If two modules are generated in the same context, then the second // 1. If two modules are generated in the same context, then the second
@ -83,14 +83,14 @@ unsigned MDLocation::computeNewDiscriminator() const {
return ++getContext().pImpl->DiscriminatorTable[Key]; return ++getContext().pImpl->DiscriminatorTable[Key];
} }
unsigned DebugNode::getFlag(StringRef Flag) { unsigned DINode::getFlag(StringRef Flag) {
return StringSwitch<unsigned>(Flag) return StringSwitch<unsigned>(Flag)
#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME) #define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
#include "llvm/IR/DebugInfoFlags.def" #include "llvm/IR/DebugInfoFlags.def"
.Default(0); .Default(0);
} }
const char *DebugNode::getFlagString(unsigned Flag) { const char *DINode::getFlagString(unsigned Flag) {
switch (Flag) { switch (Flag) {
default: default:
return ""; return "";
@ -101,8 +101,8 @@ const char *DebugNode::getFlagString(unsigned Flag) {
} }
} }
unsigned DebugNode::splitFlags(unsigned Flags, unsigned DINode::splitFlags(unsigned Flags,
SmallVectorImpl<unsigned> &SplitFlags) { SmallVectorImpl<unsigned> &SplitFlags) {
// Accessibility flags need to be specially handled, since they're packed // Accessibility flags need to be specially handled, since they're packed
// together. // together.
if (unsigned A = Flags & FlagAccessibility) { if (unsigned A = Flags & FlagAccessibility) {
@ -125,33 +125,33 @@ unsigned DebugNode::splitFlags(unsigned Flags,
return Flags; return Flags;
} }
MDScopeRef MDScope::getScope() const { DIScopeRef DIScope::getScope() const {
if (auto *T = dyn_cast<MDType>(this)) if (auto *T = dyn_cast<DIType>(this))
return T->getScope(); return T->getScope();
if (auto *SP = dyn_cast<MDSubprogram>(this)) if (auto *SP = dyn_cast<DISubprogram>(this))
return SP->getScope(); return SP->getScope();
if (auto *LB = dyn_cast<MDLexicalBlockBase>(this)) if (auto *LB = dyn_cast<DILexicalBlockBase>(this))
return MDScopeRef(LB->getScope()); return DIScopeRef(LB->getScope());
if (auto *NS = dyn_cast<MDNamespace>(this)) if (auto *NS = dyn_cast<DINamespace>(this))
return MDScopeRef(NS->getScope()); return DIScopeRef(NS->getScope());
assert((isa<MDFile>(this) || isa<MDCompileUnit>(this)) && assert((isa<DIFile>(this) || isa<DICompileUnit>(this)) &&
"Unhandled type of scope."); "Unhandled type of scope.");
return nullptr; return nullptr;
} }
StringRef MDScope::getName() const { StringRef DIScope::getName() const {
if (auto *T = dyn_cast<MDType>(this)) if (auto *T = dyn_cast<DIType>(this))
return T->getName(); return T->getName();
if (auto *SP = dyn_cast<MDSubprogram>(this)) if (auto *SP = dyn_cast<DISubprogram>(this))
return SP->getName(); return SP->getName();
if (auto *NS = dyn_cast<MDNamespace>(this)) if (auto *NS = dyn_cast<DINamespace>(this))
return NS->getName(); return NS->getName();
assert((isa<MDLexicalBlockBase>(this) || isa<MDFile>(this) || assert((isa<DILexicalBlockBase>(this) || isa<DIFile>(this) ||
isa<MDCompileUnit>(this)) && isa<DICompileUnit>(this)) &&
"Unhandled type of scope."); "Unhandled type of scope.");
return ""; return "";
} }
@ -168,15 +168,14 @@ static bool isCanonical(const MDString *S) {
} }
#endif #endif
GenericDebugNode *GenericDebugNode::getImpl(LLVMContext &Context, unsigned Tag, GenericDINode *GenericDINode::getImpl(LLVMContext &Context, unsigned Tag,
MDString *Header, MDString *Header,
ArrayRef<Metadata *> DwarfOps, ArrayRef<Metadata *> DwarfOps,
StorageType Storage, StorageType Storage, bool ShouldCreate) {
bool ShouldCreate) {
unsigned Hash = 0; unsigned Hash = 0;
if (Storage == Uniqued) { if (Storage == Uniqued) {
GenericDebugNodeInfo::KeyTy Key(Tag, getString(Header), DwarfOps); GenericDINodeInfo::KeyTy Key(Tag, getString(Header), DwarfOps);
if (auto *N = getUniqued(Context.pImpl->GenericDebugNodes, Key)) if (auto *N = getUniqued(Context.pImpl->GenericDINodes, Key))
return N; return N;
if (!ShouldCreate) if (!ShouldCreate)
return nullptr; return nullptr;
@ -188,13 +187,13 @@ GenericDebugNode *GenericDebugNode::getImpl(LLVMContext &Context, unsigned Tag,
// Use a nullptr for empty headers. // Use a nullptr for empty headers.
assert(isCanonical(Header) && "Expected canonical MDString"); assert(isCanonical(Header) && "Expected canonical MDString");
Metadata *PreOps[] = {Header}; Metadata *PreOps[] = {Header};
return storeImpl(new (DwarfOps.size() + 1) GenericDebugNode( return storeImpl(new (DwarfOps.size() + 1) GenericDINode(
Context, Storage, Hash, Tag, PreOps, DwarfOps), Context, Storage, Hash, Tag, PreOps, DwarfOps),
Storage, Context.pImpl->GenericDebugNodes); Storage, Context.pImpl->GenericDINodes);
} }
void GenericDebugNode::recalculateHash() { void GenericDINode::recalculateHash() {
setHash(GenericDebugNodeInfo::KeyTy::calculateHash(this)); setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
} }
#define UNWRAP_ARGS_IMPL(...) __VA_ARGS__ #define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
@ -224,49 +223,49 @@ void GenericDebugNode::recalculateHash() {
CLASS(Context, Storage, OPS), \ CLASS(Context, Storage, OPS), \
Storage, Context.pImpl->CLASS##s) Storage, Context.pImpl->CLASS##s)
MDSubrange *MDSubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo, DISubrange *DISubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo,
StorageType Storage, bool ShouldCreate) { StorageType Storage, bool ShouldCreate) {
DEFINE_GETIMPL_LOOKUP(MDSubrange, (Count, Lo)); DEFINE_GETIMPL_LOOKUP(DISubrange, (Count, Lo));
DEFINE_GETIMPL_STORE_NO_OPS(MDSubrange, (Count, Lo)); DEFINE_GETIMPL_STORE_NO_OPS(DISubrange, (Count, Lo));
} }
MDEnumerator *MDEnumerator::getImpl(LLVMContext &Context, int64_t Value, DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, int64_t Value,
MDString *Name, StorageType Storage, MDString *Name, StorageType Storage,
bool ShouldCreate) { bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDEnumerator, (Value, getString(Name))); DEFINE_GETIMPL_LOOKUP(DIEnumerator, (Value, getString(Name)));
Metadata *Ops[] = {Name}; Metadata *Ops[] = {Name};
DEFINE_GETIMPL_STORE(MDEnumerator, (Value), Ops); DEFINE_GETIMPL_STORE(DIEnumerator, (Value), Ops);
} }
MDBasicType *MDBasicType::getImpl(LLVMContext &Context, unsigned Tag, DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag,
MDString *Name, uint64_t SizeInBits, MDString *Name, uint64_t SizeInBits,
uint64_t AlignInBits, unsigned Encoding, uint64_t AlignInBits, unsigned Encoding,
StorageType Storage, bool ShouldCreate) { StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP( DEFINE_GETIMPL_LOOKUP(
MDBasicType, (Tag, getString(Name), SizeInBits, AlignInBits, Encoding)); DIBasicType, (Tag, getString(Name), SizeInBits, AlignInBits, Encoding));
Metadata *Ops[] = {nullptr, nullptr, Name}; Metadata *Ops[] = {nullptr, nullptr, Name};
DEFINE_GETIMPL_STORE(MDBasicType, (Tag, SizeInBits, AlignInBits, Encoding), DEFINE_GETIMPL_STORE(DIBasicType, (Tag, SizeInBits, AlignInBits, Encoding),
Ops); Ops);
} }
MDDerivedType *MDDerivedType::getImpl( DIDerivedType *DIDerivedType::getImpl(
LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File, LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
Metadata *ExtraData, StorageType Storage, bool ShouldCreate) { Metadata *ExtraData, StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDDerivedType, (Tag, getString(Name), File, Line, Scope, DEFINE_GETIMPL_LOOKUP(DIDerivedType, (Tag, getString(Name), File, Line, Scope,
BaseType, SizeInBits, AlignInBits, BaseType, SizeInBits, AlignInBits,
OffsetInBits, Flags, ExtraData)); OffsetInBits, Flags, ExtraData));
Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData}; Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData};
DEFINE_GETIMPL_STORE( DEFINE_GETIMPL_STORE(
MDDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits, Flags), DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits, Flags),
Ops); Ops);
} }
MDCompositeType *MDCompositeType::getImpl( DICompositeType *DICompositeType::getImpl(
LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File, LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
@ -274,39 +273,39 @@ MDCompositeType *MDCompositeType::getImpl(
Metadata *TemplateParams, MDString *Identifier, StorageType Storage, Metadata *TemplateParams, MDString *Identifier, StorageType Storage,
bool ShouldCreate) { bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDCompositeType, DEFINE_GETIMPL_LOOKUP(DICompositeType,
(Tag, getString(Name), File, Line, Scope, BaseType, (Tag, getString(Name), File, Line, Scope, BaseType,
SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements,
RuntimeLang, VTableHolder, TemplateParams, RuntimeLang, VTableHolder, TemplateParams,
getString(Identifier))); getString(Identifier)));
Metadata *Ops[] = {File, Scope, Name, BaseType, Metadata *Ops[] = {File, Scope, Name, BaseType,
Elements, VTableHolder, TemplateParams, Identifier}; Elements, VTableHolder, TemplateParams, Identifier};
DEFINE_GETIMPL_STORE(MDCompositeType, (Tag, Line, RuntimeLang, SizeInBits, DEFINE_GETIMPL_STORE(DICompositeType, (Tag, Line, RuntimeLang, SizeInBits,
AlignInBits, OffsetInBits, Flags), AlignInBits, OffsetInBits, Flags),
Ops); Ops);
} }
MDSubroutineType *MDSubroutineType::getImpl(LLVMContext &Context, DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context,
unsigned Flags, Metadata *TypeArray, unsigned Flags, Metadata *TypeArray,
StorageType Storage, StorageType Storage,
bool ShouldCreate) { bool ShouldCreate) {
DEFINE_GETIMPL_LOOKUP(MDSubroutineType, (Flags, TypeArray)); DEFINE_GETIMPL_LOOKUP(DISubroutineType, (Flags, TypeArray));
Metadata *Ops[] = {nullptr, nullptr, nullptr, nullptr, Metadata *Ops[] = {nullptr, nullptr, nullptr, nullptr,
TypeArray, nullptr, nullptr, nullptr}; TypeArray, nullptr, nullptr, nullptr};
DEFINE_GETIMPL_STORE(MDSubroutineType, (Flags), Ops); DEFINE_GETIMPL_STORE(DISubroutineType, (Flags), Ops);
} }
MDFile *MDFile::getImpl(LLVMContext &Context, MDString *Filename, DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename,
MDString *Directory, StorageType Storage, MDString *Directory, StorageType Storage,
bool ShouldCreate) { bool ShouldCreate) {
assert(isCanonical(Filename) && "Expected canonical MDString"); assert(isCanonical(Filename) && "Expected canonical MDString");
assert(isCanonical(Directory) && "Expected canonical MDString"); assert(isCanonical(Directory) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDFile, (getString(Filename), getString(Directory))); DEFINE_GETIMPL_LOOKUP(DIFile, (getString(Filename), getString(Directory)));
Metadata *Ops[] = {Filename, Directory}; Metadata *Ops[] = {Filename, Directory};
DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(MDFile, Ops); DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIFile, Ops);
} }
MDCompileUnit *MDCompileUnit::getImpl( DICompileUnit *DICompileUnit::getImpl(
LLVMContext &Context, unsigned SourceLanguage, Metadata *File, LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
MDString *Producer, bool IsOptimized, MDString *Flags, MDString *Producer, bool IsOptimized, MDString *Flags,
unsigned RuntimeVersion, MDString *SplitDebugFilename, unsigned RuntimeVersion, MDString *SplitDebugFilename,
@ -317,7 +316,7 @@ MDCompileUnit *MDCompileUnit::getImpl(
assert(isCanonical(Flags) && "Expected canonical MDString"); assert(isCanonical(Flags) && "Expected canonical MDString");
assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString"); assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP( DEFINE_GETIMPL_LOOKUP(
MDCompileUnit, DICompileUnit,
(SourceLanguage, File, getString(Producer), IsOptimized, getString(Flags), (SourceLanguage, File, getString(Producer), IsOptimized, getString(Flags),
RuntimeVersion, getString(SplitDebugFilename), EmissionKind, EnumTypes, RuntimeVersion, getString(SplitDebugFilename), EmissionKind, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables, ImportedEntities)); RetainedTypes, Subprograms, GlobalVariables, ImportedEntities));
@ -325,17 +324,17 @@ MDCompileUnit *MDCompileUnit::getImpl(
RetainedTypes, Subprograms, GlobalVariables, RetainedTypes, Subprograms, GlobalVariables,
ImportedEntities}; ImportedEntities};
DEFINE_GETIMPL_STORE( DEFINE_GETIMPL_STORE(
MDCompileUnit, DICompileUnit,
(SourceLanguage, IsOptimized, RuntimeVersion, EmissionKind), Ops); (SourceLanguage, IsOptimized, RuntimeVersion, EmissionKind), Ops);
} }
MDSubprogram *MDLocalScope::getSubprogram() const { DISubprogram *DILocalScope::getSubprogram() const {
if (auto *Block = dyn_cast<MDLexicalBlockBase>(this)) if (auto *Block = dyn_cast<DILexicalBlockBase>(this))
return Block->getScope()->getSubprogram(); return Block->getScope()->getSubprogram();
return const_cast<MDSubprogram *>(cast<MDSubprogram>(this)); return const_cast<DISubprogram *>(cast<DISubprogram>(this));
} }
MDSubprogram *MDSubprogram::getImpl( DISubprogram *DISubprogram::getImpl(
LLVMContext &Context, Metadata *Scope, MDString *Name, LLVMContext &Context, Metadata *Scope, MDString *Name,
MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type, MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine, bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
@ -345,7 +344,7 @@ MDSubprogram *MDSubprogram::getImpl(
StorageType Storage, bool ShouldCreate) { StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
assert(isCanonical(LinkageName) && "Expected canonical MDString"); assert(isCanonical(LinkageName) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDSubprogram, DEFINE_GETIMPL_LOOKUP(DISubprogram,
(Scope, getString(Name), getString(LinkageName), File, (Scope, getString(Name), getString(LinkageName), File,
Line, Type, IsLocalToUnit, IsDefinition, ScopeLine, Line, Type, IsLocalToUnit, IsDefinition, ScopeLine,
ContainingType, Virtuality, VirtualIndex, Flags, ContainingType, Virtuality, VirtualIndex, Flags,
@ -354,18 +353,18 @@ MDSubprogram *MDSubprogram::getImpl(
Metadata *Ops[] = {File, Scope, Name, Name, Metadata *Ops[] = {File, Scope, Name, Name,
LinkageName, Type, ContainingType, Function, LinkageName, Type, ContainingType, Function,
TemplateParams, Declaration, Variables}; TemplateParams, Declaration, Variables};
DEFINE_GETIMPL_STORE(MDSubprogram, DEFINE_GETIMPL_STORE(DISubprogram,
(Line, ScopeLine, Virtuality, VirtualIndex, Flags, (Line, ScopeLine, Virtuality, VirtualIndex, Flags,
IsLocalToUnit, IsDefinition, IsOptimized), IsLocalToUnit, IsDefinition, IsOptimized),
Ops); Ops);
} }
Function *MDSubprogram::getFunction() const { Function *DISubprogram::getFunction() const {
// FIXME: Should this be looking through bitcasts? // FIXME: Should this be looking through bitcasts?
return dyn_cast_or_null<Function>(getFunctionConstant()); return dyn_cast_or_null<Function>(getFunctionConstant());
} }
bool MDSubprogram::describes(const Function *F) const { bool DISubprogram::describes(const Function *F) const {
assert(F && "Invalid function"); assert(F && "Invalid function");
if (F == getFunction()) if (F == getFunction())
return true; return true;
@ -375,64 +374,64 @@ bool MDSubprogram::describes(const Function *F) const {
return F->getName() == Name; return F->getName() == Name;
} }
void MDSubprogram::replaceFunction(Function *F) { void DISubprogram::replaceFunction(Function *F) {
replaceFunction(F ? ConstantAsMetadata::get(F) replaceFunction(F ? ConstantAsMetadata::get(F)
: static_cast<ConstantAsMetadata *>(nullptr)); : static_cast<ConstantAsMetadata *>(nullptr));
} }
MDLexicalBlock *MDLexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope, DILexicalBlock *DILexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope,
Metadata *File, unsigned Line, Metadata *File, unsigned Line,
unsigned Column, StorageType Storage, unsigned Column, StorageType Storage,
bool ShouldCreate) { bool ShouldCreate) {
assert(Scope && "Expected scope"); assert(Scope && "Expected scope");
DEFINE_GETIMPL_LOOKUP(MDLexicalBlock, (Scope, File, Line, Column)); DEFINE_GETIMPL_LOOKUP(DILexicalBlock, (Scope, File, Line, Column));
Metadata *Ops[] = {File, Scope}; Metadata *Ops[] = {File, Scope};
DEFINE_GETIMPL_STORE(MDLexicalBlock, (Line, Column), Ops); DEFINE_GETIMPL_STORE(DILexicalBlock, (Line, Column), Ops);
} }
MDLexicalBlockFile *MDLexicalBlockFile::getImpl(LLVMContext &Context, DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVMContext &Context,
Metadata *Scope, Metadata *File, Metadata *Scope, Metadata *File,
unsigned Discriminator, unsigned Discriminator,
StorageType Storage, StorageType Storage,
bool ShouldCreate) { bool ShouldCreate) {
assert(Scope && "Expected scope"); assert(Scope && "Expected scope");
DEFINE_GETIMPL_LOOKUP(MDLexicalBlockFile, (Scope, File, Discriminator)); DEFINE_GETIMPL_LOOKUP(DILexicalBlockFile, (Scope, File, Discriminator));
Metadata *Ops[] = {File, Scope}; Metadata *Ops[] = {File, Scope};
DEFINE_GETIMPL_STORE(MDLexicalBlockFile, (Discriminator), Ops); DEFINE_GETIMPL_STORE(DILexicalBlockFile, (Discriminator), Ops);
} }
MDNamespace *MDNamespace::getImpl(LLVMContext &Context, Metadata *Scope, DINamespace *DINamespace::getImpl(LLVMContext &Context, Metadata *Scope,
Metadata *File, MDString *Name, unsigned Line, Metadata *File, MDString *Name, unsigned Line,
StorageType Storage, bool ShouldCreate) { StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDNamespace, (Scope, File, getString(Name), Line)); DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, File, getString(Name), Line));
Metadata *Ops[] = {File, Scope, Name}; Metadata *Ops[] = {File, Scope, Name};
DEFINE_GETIMPL_STORE(MDNamespace, (Line), Ops); DEFINE_GETIMPL_STORE(DINamespace, (Line), Ops);
} }
MDTemplateTypeParameter *MDTemplateTypeParameter::getImpl(LLVMContext &Context, DITemplateTypeParameter *DITemplateTypeParameter::getImpl(LLVMContext &Context,
MDString *Name, MDString *Name,
Metadata *Type, Metadata *Type,
StorageType Storage, StorageType Storage,
bool ShouldCreate) { bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDTemplateTypeParameter, (getString(Name), Type)); DEFINE_GETIMPL_LOOKUP(DITemplateTypeParameter, (getString(Name), Type));
Metadata *Ops[] = {Name, Type}; Metadata *Ops[] = {Name, Type};
DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(MDTemplateTypeParameter, Ops); DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DITemplateTypeParameter, Ops);
} }
MDTemplateValueParameter *MDTemplateValueParameter::getImpl( DITemplateValueParameter *DITemplateValueParameter::getImpl(
LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type, LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
Metadata *Value, StorageType Storage, bool ShouldCreate) { Metadata *Value, StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDTemplateValueParameter, DEFINE_GETIMPL_LOOKUP(DITemplateValueParameter,
(Tag, getString(Name), Type, Value)); (Tag, getString(Name), Type, Value));
Metadata *Ops[] = {Name, Type, Value}; Metadata *Ops[] = {Name, Type, Value};
DEFINE_GETIMPL_STORE(MDTemplateValueParameter, (Tag), Ops); DEFINE_GETIMPL_STORE(DITemplateValueParameter, (Tag), Ops);
} }
MDGlobalVariable * DIGlobalVariable *
MDGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
MDString *LinkageName, Metadata *File, unsigned Line, MDString *LinkageName, Metadata *File, unsigned Line,
Metadata *Type, bool IsLocalToUnit, bool IsDefinition, Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
Metadata *Variable, Metadata *Variable,
@ -440,17 +439,17 @@ MDGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
StorageType Storage, bool ShouldCreate) { StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
assert(isCanonical(LinkageName) && "Expected canonical MDString"); assert(isCanonical(LinkageName) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDGlobalVariable, DEFINE_GETIMPL_LOOKUP(DIGlobalVariable,
(Scope, getString(Name), getString(LinkageName), File, (Scope, getString(Name), getString(LinkageName), File,
Line, Type, IsLocalToUnit, IsDefinition, Variable, Line, Type, IsLocalToUnit, IsDefinition, Variable,
StaticDataMemberDeclaration)); StaticDataMemberDeclaration));
Metadata *Ops[] = {Scope, Name, File, Type, Metadata *Ops[] = {Scope, Name, File, Type,
Name, LinkageName, Variable, StaticDataMemberDeclaration}; Name, LinkageName, Variable, StaticDataMemberDeclaration};
DEFINE_GETIMPL_STORE(MDGlobalVariable, (Line, IsLocalToUnit, IsDefinition), DEFINE_GETIMPL_STORE(DIGlobalVariable, (Line, IsLocalToUnit, IsDefinition),
Ops); Ops);
} }
MDLocalVariable *MDLocalVariable::getImpl(LLVMContext &Context, unsigned Tag, DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, unsigned Tag,
Metadata *Scope, MDString *Name, Metadata *Scope, MDString *Name,
Metadata *File, unsigned Line, Metadata *File, unsigned Line,
Metadata *Type, unsigned Arg, Metadata *Type, unsigned Arg,
@ -461,20 +460,20 @@ MDLocalVariable *MDLocalVariable::getImpl(LLVMContext &Context, unsigned Tag,
assert(Scope && "Expected scope"); assert(Scope && "Expected scope");
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDLocalVariable, (Tag, Scope, getString(Name), File, DEFINE_GETIMPL_LOOKUP(DILocalVariable, (Tag, Scope, getString(Name), File,
Line, Type, Arg, Flags)); Line, Type, Arg, Flags));
Metadata *Ops[] = {Scope, Name, File, Type}; Metadata *Ops[] = {Scope, Name, File, Type};
DEFINE_GETIMPL_STORE(MDLocalVariable, (Tag, Line, Arg, Flags), Ops); DEFINE_GETIMPL_STORE(DILocalVariable, (Tag, Line, Arg, Flags), Ops);
} }
MDExpression *MDExpression::getImpl(LLVMContext &Context, DIExpression *DIExpression::getImpl(LLVMContext &Context,
ArrayRef<uint64_t> Elements, ArrayRef<uint64_t> Elements,
StorageType Storage, bool ShouldCreate) { StorageType Storage, bool ShouldCreate) {
DEFINE_GETIMPL_LOOKUP(MDExpression, (Elements)); DEFINE_GETIMPL_LOOKUP(DIExpression, (Elements));
DEFINE_GETIMPL_STORE_NO_OPS(MDExpression, (Elements)); DEFINE_GETIMPL_STORE_NO_OPS(DIExpression, (Elements));
} }
unsigned MDExpression::ExprOperand::getSize() const { unsigned DIExpression::ExprOperand::getSize() const {
switch (getOp()) { switch (getOp()) {
case dwarf::DW_OP_bit_piece: case dwarf::DW_OP_bit_piece:
return 3; return 3;
@ -485,7 +484,7 @@ unsigned MDExpression::ExprOperand::getSize() const {
} }
} }
bool MDExpression::isValid() const { bool DIExpression::isValid() const {
for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) { for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) {
// Check that there's space for the operand. // Check that there's space for the operand.
if (I->get() + I->getSize() > E->get()) if (I->get() + I->getSize() > E->get())
@ -506,7 +505,7 @@ bool MDExpression::isValid() const {
return true; return true;
} }
bool MDExpression::isBitPiece() const { bool DIExpression::isBitPiece() const {
assert(isValid() && "Expected valid expression"); assert(isValid() && "Expected valid expression");
if (unsigned N = getNumElements()) if (unsigned N = getNumElements())
if (N >= 3) if (N >= 3)
@ -514,38 +513,38 @@ bool MDExpression::isBitPiece() const {
return false; return false;
} }
uint64_t MDExpression::getBitPieceOffset() const { uint64_t DIExpression::getBitPieceOffset() const {
assert(isBitPiece() && "Expected bit piece"); assert(isBitPiece() && "Expected bit piece");
return getElement(getNumElements() - 2); return getElement(getNumElements() - 2);
} }
uint64_t MDExpression::getBitPieceSize() const { uint64_t DIExpression::getBitPieceSize() const {
assert(isBitPiece() && "Expected bit piece"); assert(isBitPiece() && "Expected bit piece");
return getElement(getNumElements() - 1); return getElement(getNumElements() - 1);
} }
MDObjCProperty *MDObjCProperty::getImpl( DIObjCProperty *DIObjCProperty::getImpl(
LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line, LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
MDString *GetterName, MDString *SetterName, unsigned Attributes, MDString *GetterName, MDString *SetterName, unsigned Attributes,
Metadata *Type, StorageType Storage, bool ShouldCreate) { Metadata *Type, StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
assert(isCanonical(GetterName) && "Expected canonical MDString"); assert(isCanonical(GetterName) && "Expected canonical MDString");
assert(isCanonical(SetterName) && "Expected canonical MDString"); assert(isCanonical(SetterName) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDObjCProperty, DEFINE_GETIMPL_LOOKUP(DIObjCProperty,
(getString(Name), File, Line, getString(GetterName), (getString(Name), File, Line, getString(GetterName),
getString(SetterName), Attributes, Type)); getString(SetterName), Attributes, Type));
Metadata *Ops[] = {Name, File, GetterName, SetterName, Type}; Metadata *Ops[] = {Name, File, GetterName, SetterName, Type};
DEFINE_GETIMPL_STORE(MDObjCProperty, (Line, Attributes), Ops); DEFINE_GETIMPL_STORE(DIObjCProperty, (Line, Attributes), Ops);
} }
MDImportedEntity *MDImportedEntity::getImpl(LLVMContext &Context, unsigned Tag, DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag,
Metadata *Scope, Metadata *Entity, Metadata *Scope, Metadata *Entity,
unsigned Line, MDString *Name, unsigned Line, MDString *Name,
StorageType Storage, StorageType Storage,
bool ShouldCreate) { bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDImportedEntity, DEFINE_GETIMPL_LOOKUP(DIImportedEntity,
(Tag, Scope, Entity, Line, getString(Name))); (Tag, Scope, Entity, Line, getString(Name)));
Metadata *Ops[] = {Scope, Entity, Name}; Metadata *Ops[] = {Scope, Entity, Name};
DEFINE_GETIMPL_STORE(MDImportedEntity, (Tag, Line), Ops); DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops);
} }

View File

@ -16,11 +16,11 @@ using namespace llvm;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// DebugLoc Implementation // DebugLoc Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
DebugLoc::DebugLoc(const MDLocation *L) : Loc(const_cast<MDLocation *>(L)) {} DebugLoc::DebugLoc(const DILocation *L) : Loc(const_cast<DILocation *>(L)) {}
DebugLoc::DebugLoc(const MDNode *L) : Loc(const_cast<MDNode *>(L)) {} DebugLoc::DebugLoc(const MDNode *L) : Loc(const_cast<MDNode *>(L)) {}
MDLocation *DebugLoc::get() const { DILocation *DebugLoc::get() const {
return cast_or_null<MDLocation>(Loc.get()); return cast_or_null<DILocation>(Loc.get());
} }
unsigned DebugLoc::getLine() const { unsigned DebugLoc::getLine() const {
@ -38,17 +38,17 @@ MDNode *DebugLoc::getScope() const {
return get()->getScope(); return get()->getScope();
} }
MDLocation *DebugLoc::getInlinedAt() const { DILocation *DebugLoc::getInlinedAt() const {
assert(get() && "Expected valid DebugLoc"); assert(get() && "Expected valid DebugLoc");
return get()->getInlinedAt(); return get()->getInlinedAt();
} }
MDNode *DebugLoc::getInlinedAtScope() const { MDNode *DebugLoc::getInlinedAtScope() const {
return cast<MDLocation>(Loc)->getInlinedAtScope(); return cast<DILocation>(Loc)->getInlinedAtScope();
} }
DebugLoc DebugLoc::getFnDebugLoc() const { DebugLoc DebugLoc::getFnDebugLoc() const {
// FIXME: Add a method on \a MDLocation that does this work. // FIXME: Add a method on \a DILocation that does this work.
const MDNode *Scope = getInlinedAtScope(); const MDNode *Scope = getInlinedAtScope();
if (auto *SP = getDISubprogram(Scope)) if (auto *SP = getDISubprogram(Scope))
return DebugLoc::get(SP->getScopeLine(), 0, SP); return DebugLoc::get(SP->getScopeLine(), 0, SP);
@ -62,7 +62,7 @@ DebugLoc DebugLoc::get(unsigned Line, unsigned Col, const MDNode *Scope,
if (!Scope) if (!Scope)
return DebugLoc(); return DebugLoc();
return MDLocation::get(Scope->getContext(), Line, Col, return DILocation::get(Scope->getContext(), Line, Col,
const_cast<MDNode *>(Scope), const_cast<MDNode *>(Scope),
const_cast<MDNode *>(InlinedAt)); const_cast<MDNode *>(InlinedAt));
} }
@ -88,7 +88,7 @@ void DebugLoc::print(raw_ostream &OS) const {
return; return;
// Print source line info. // Print source line info.
auto *Scope = cast<MDScope>(getScope()); auto *Scope = cast<DIScope>(getScope());
OS << Scope->getFilename(); OS << Scope->getFilename();
OS << ':' << getLine(); OS << ':' << getLine();
if (getCol() != 0) if (getCol() != 0)

View File

@ -135,7 +135,7 @@ bool DiagnosticInfoOptimizationBase::isLocationAvailable() const {
void DiagnosticInfoOptimizationBase::getLocation(StringRef *Filename, void DiagnosticInfoOptimizationBase::getLocation(StringRef *Filename,
unsigned *Line, unsigned *Line,
unsigned *Column) const { unsigned *Column) const {
MDLocation *L = getDebugLoc(); DILocation *L = getDebugLoc();
*Filename = L->getFilename(); *Filename = L->getFilename();
*Line = L->getLine(); *Line = L->getLine();
*Column = L->getColumn(); *Column = L->getColumn();

View File

@ -228,8 +228,8 @@ template <> struct MDNodeKeyImpl<MDTuple> : MDNodeOpsKey {
} }
}; };
/// \brief DenseMapInfo for MDLocation. /// \brief DenseMapInfo for DILocation.
template <> struct MDNodeKeyImpl<MDLocation> { template <> struct MDNodeKeyImpl<DILocation> {
unsigned Line; unsigned Line;
unsigned Column; unsigned Column;
Metadata *Scope; Metadata *Scope;
@ -239,11 +239,11 @@ template <> struct MDNodeKeyImpl<MDLocation> {
Metadata *InlinedAt) Metadata *InlinedAt)
: Line(Line), Column(Column), Scope(Scope), InlinedAt(InlinedAt) {} : Line(Line), Column(Column), Scope(Scope), InlinedAt(InlinedAt) {}
MDNodeKeyImpl(const MDLocation *L) MDNodeKeyImpl(const DILocation *L)
: Line(L->getLine()), Column(L->getColumn()), Scope(L->getRawScope()), : Line(L->getLine()), Column(L->getColumn()), Scope(L->getRawScope()),
InlinedAt(L->getRawInlinedAt()) {} InlinedAt(L->getRawInlinedAt()) {}
bool isKeyOf(const MDLocation *RHS) const { bool isKeyOf(const DILocation *RHS) const {
return Line == RHS->getLine() && Column == RHS->getColumn() && return Line == RHS->getLine() && Column == RHS->getColumn() &&
Scope == RHS->getRawScope() && InlinedAt == RHS->getRawInlinedAt(); Scope == RHS->getRawScope() && InlinedAt == RHS->getRawInlinedAt();
} }
@ -252,57 +252,57 @@ template <> struct MDNodeKeyImpl<MDLocation> {
} }
}; };
/// \brief DenseMapInfo for GenericDebugNode. /// \brief DenseMapInfo for GenericDINode.
template <> struct MDNodeKeyImpl<GenericDebugNode> : MDNodeOpsKey { template <> struct MDNodeKeyImpl<GenericDINode> : MDNodeOpsKey {
unsigned Tag; unsigned Tag;
StringRef Header; StringRef Header;
MDNodeKeyImpl(unsigned Tag, StringRef Header, ArrayRef<Metadata *> DwarfOps) MDNodeKeyImpl(unsigned Tag, StringRef Header, ArrayRef<Metadata *> DwarfOps)
: MDNodeOpsKey(DwarfOps), Tag(Tag), Header(Header) {} : MDNodeOpsKey(DwarfOps), Tag(Tag), Header(Header) {}
MDNodeKeyImpl(const GenericDebugNode *N) MDNodeKeyImpl(const GenericDINode *N)
: MDNodeOpsKey(N, 1), Tag(N->getTag()), Header(N->getHeader()) {} : MDNodeOpsKey(N, 1), Tag(N->getTag()), Header(N->getHeader()) {}
bool isKeyOf(const GenericDebugNode *RHS) const { bool isKeyOf(const GenericDINode *RHS) const {
return Tag == RHS->getTag() && Header == RHS->getHeader() && return Tag == RHS->getTag() && Header == RHS->getHeader() &&
compareOps(RHS, 1); compareOps(RHS, 1);
} }
unsigned getHashValue() const { return hash_combine(getHash(), Tag, Header); } unsigned getHashValue() const { return hash_combine(getHash(), Tag, Header); }
static unsigned calculateHash(GenericDebugNode *N) { static unsigned calculateHash(GenericDINode *N) {
return MDNodeOpsKey::calculateHash(N, 1); return MDNodeOpsKey::calculateHash(N, 1);
} }
}; };
template <> struct MDNodeKeyImpl<MDSubrange> { template <> struct MDNodeKeyImpl<DISubrange> {
int64_t Count; int64_t Count;
int64_t LowerBound; int64_t LowerBound;
MDNodeKeyImpl(int64_t Count, int64_t LowerBound) MDNodeKeyImpl(int64_t Count, int64_t LowerBound)
: Count(Count), LowerBound(LowerBound) {} : Count(Count), LowerBound(LowerBound) {}
MDNodeKeyImpl(const MDSubrange *N) MDNodeKeyImpl(const DISubrange *N)
: Count(N->getCount()), LowerBound(N->getLowerBound()) {} : Count(N->getCount()), LowerBound(N->getLowerBound()) {}
bool isKeyOf(const MDSubrange *RHS) const { bool isKeyOf(const DISubrange *RHS) const {
return Count == RHS->getCount() && LowerBound == RHS->getLowerBound(); return Count == RHS->getCount() && LowerBound == RHS->getLowerBound();
} }
unsigned getHashValue() const { return hash_combine(Count, LowerBound); } unsigned getHashValue() const { return hash_combine(Count, LowerBound); }
}; };
template <> struct MDNodeKeyImpl<MDEnumerator> { template <> struct MDNodeKeyImpl<DIEnumerator> {
int64_t Value; int64_t Value;
StringRef Name; StringRef Name;
MDNodeKeyImpl(int64_t Value, StringRef Name) : Value(Value), Name(Name) {} MDNodeKeyImpl(int64_t Value, StringRef Name) : Value(Value), Name(Name) {}
MDNodeKeyImpl(const MDEnumerator *N) MDNodeKeyImpl(const DIEnumerator *N)
: Value(N->getValue()), Name(N->getName()) {} : Value(N->getValue()), Name(N->getName()) {}
bool isKeyOf(const MDEnumerator *RHS) const { bool isKeyOf(const DIEnumerator *RHS) const {
return Value == RHS->getValue() && Name == RHS->getName(); return Value == RHS->getValue() && Name == RHS->getName();
} }
unsigned getHashValue() const { return hash_combine(Value, Name); } unsigned getHashValue() const { return hash_combine(Value, Name); }
}; };
template <> struct MDNodeKeyImpl<MDBasicType> { template <> struct MDNodeKeyImpl<DIBasicType> {
unsigned Tag; unsigned Tag;
StringRef Name; StringRef Name;
uint64_t SizeInBits; uint64_t SizeInBits;
@ -313,11 +313,11 @@ template <> struct MDNodeKeyImpl<MDBasicType> {
uint64_t AlignInBits, unsigned Encoding) uint64_t AlignInBits, unsigned Encoding)
: Tag(Tag), Name(Name), SizeInBits(SizeInBits), AlignInBits(AlignInBits), : Tag(Tag), Name(Name), SizeInBits(SizeInBits), AlignInBits(AlignInBits),
Encoding(Encoding) {} Encoding(Encoding) {}
MDNodeKeyImpl(const MDBasicType *N) MDNodeKeyImpl(const DIBasicType *N)
: Tag(N->getTag()), Name(N->getName()), SizeInBits(N->getSizeInBits()), : Tag(N->getTag()), Name(N->getName()), SizeInBits(N->getSizeInBits()),
AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()) {} AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()) {}
bool isKeyOf(const MDBasicType *RHS) const { bool isKeyOf(const DIBasicType *RHS) const {
return Tag == RHS->getTag() && Name == RHS->getName() && return Tag == RHS->getTag() && Name == RHS->getName() &&
SizeInBits == RHS->getSizeInBits() && SizeInBits == RHS->getSizeInBits() &&
AlignInBits == RHS->getAlignInBits() && AlignInBits == RHS->getAlignInBits() &&
@ -328,7 +328,7 @@ template <> struct MDNodeKeyImpl<MDBasicType> {
} }
}; };
template <> struct MDNodeKeyImpl<MDDerivedType> { template <> struct MDNodeKeyImpl<DIDerivedType> {
unsigned Tag; unsigned Tag;
StringRef Name; StringRef Name;
Metadata *File; Metadata *File;
@ -348,14 +348,14 @@ template <> struct MDNodeKeyImpl<MDDerivedType> {
: Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope), : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
BaseType(BaseType), SizeInBits(SizeInBits), AlignInBits(AlignInBits), BaseType(BaseType), SizeInBits(SizeInBits), AlignInBits(AlignInBits),
OffsetInBits(OffsetInBits), Flags(Flags), ExtraData(ExtraData) {} OffsetInBits(OffsetInBits), Flags(Flags), ExtraData(ExtraData) {}
MDNodeKeyImpl(const MDDerivedType *N) MDNodeKeyImpl(const DIDerivedType *N)
: Tag(N->getTag()), Name(N->getName()), File(N->getRawFile()), : Tag(N->getTag()), Name(N->getName()), File(N->getRawFile()),
Line(N->getLine()), Scope(N->getRawScope()), Line(N->getLine()), Scope(N->getRawScope()),
BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()), BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()),
AlignInBits(N->getAlignInBits()), OffsetInBits(N->getOffsetInBits()), AlignInBits(N->getAlignInBits()), OffsetInBits(N->getOffsetInBits()),
Flags(N->getFlags()), ExtraData(N->getRawExtraData()) {} Flags(N->getFlags()), ExtraData(N->getRawExtraData()) {}
bool isKeyOf(const MDDerivedType *RHS) const { bool isKeyOf(const DIDerivedType *RHS) const {
return Tag == RHS->getTag() && Name == RHS->getName() && return Tag == RHS->getTag() && Name == RHS->getName() &&
File == RHS->getRawFile() && Line == RHS->getLine() && File == RHS->getRawFile() && Line == RHS->getLine() &&
Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() && Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
@ -370,7 +370,7 @@ template <> struct MDNodeKeyImpl<MDDerivedType> {
} }
}; };
template <> struct MDNodeKeyImpl<MDCompositeType> { template <> struct MDNodeKeyImpl<DICompositeType> {
unsigned Tag; unsigned Tag;
StringRef Name; StringRef Name;
Metadata *File; Metadata *File;
@ -398,7 +398,7 @@ template <> struct MDNodeKeyImpl<MDCompositeType> {
OffsetInBits(OffsetInBits), Flags(Flags), Elements(Elements), OffsetInBits(OffsetInBits), Flags(Flags), Elements(Elements),
RuntimeLang(RuntimeLang), VTableHolder(VTableHolder), RuntimeLang(RuntimeLang), VTableHolder(VTableHolder),
TemplateParams(TemplateParams), Identifier(Identifier) {} TemplateParams(TemplateParams), Identifier(Identifier) {}
MDNodeKeyImpl(const MDCompositeType *N) MDNodeKeyImpl(const DICompositeType *N)
: Tag(N->getTag()), Name(N->getName()), File(N->getRawFile()), : Tag(N->getTag()), Name(N->getName()), File(N->getRawFile()),
Line(N->getLine()), Scope(N->getRawScope()), Line(N->getLine()), Scope(N->getRawScope()),
BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()), BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()),
@ -408,7 +408,7 @@ template <> struct MDNodeKeyImpl<MDCompositeType> {
TemplateParams(N->getRawTemplateParams()), TemplateParams(N->getRawTemplateParams()),
Identifier(N->getIdentifier()) {} Identifier(N->getIdentifier()) {}
bool isKeyOf(const MDCompositeType *RHS) const { bool isKeyOf(const DICompositeType *RHS) const {
return Tag == RHS->getTag() && Name == RHS->getName() && return Tag == RHS->getTag() && Name == RHS->getName() &&
File == RHS->getRawFile() && Line == RHS->getLine() && File == RHS->getRawFile() && Line == RHS->getLine() &&
Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() && Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
@ -428,37 +428,37 @@ template <> struct MDNodeKeyImpl<MDCompositeType> {
} }
}; };
template <> struct MDNodeKeyImpl<MDSubroutineType> { template <> struct MDNodeKeyImpl<DISubroutineType> {
unsigned Flags; unsigned Flags;
Metadata *TypeArray; Metadata *TypeArray;
MDNodeKeyImpl(int64_t Flags, Metadata *TypeArray) MDNodeKeyImpl(int64_t Flags, Metadata *TypeArray)
: Flags(Flags), TypeArray(TypeArray) {} : Flags(Flags), TypeArray(TypeArray) {}
MDNodeKeyImpl(const MDSubroutineType *N) MDNodeKeyImpl(const DISubroutineType *N)
: Flags(N->getFlags()), TypeArray(N->getRawTypeArray()) {} : Flags(N->getFlags()), TypeArray(N->getRawTypeArray()) {}
bool isKeyOf(const MDSubroutineType *RHS) const { bool isKeyOf(const DISubroutineType *RHS) const {
return Flags == RHS->getFlags() && TypeArray == RHS->getRawTypeArray(); return Flags == RHS->getFlags() && TypeArray == RHS->getRawTypeArray();
} }
unsigned getHashValue() const { return hash_combine(Flags, TypeArray); } unsigned getHashValue() const { return hash_combine(Flags, TypeArray); }
}; };
template <> struct MDNodeKeyImpl<MDFile> { template <> struct MDNodeKeyImpl<DIFile> {
StringRef Filename; StringRef Filename;
StringRef Directory; StringRef Directory;
MDNodeKeyImpl(StringRef Filename, StringRef Directory) MDNodeKeyImpl(StringRef Filename, StringRef Directory)
: Filename(Filename), Directory(Directory) {} : Filename(Filename), Directory(Directory) {}
MDNodeKeyImpl(const MDFile *N) MDNodeKeyImpl(const DIFile *N)
: Filename(N->getFilename()), Directory(N->getDirectory()) {} : Filename(N->getFilename()), Directory(N->getDirectory()) {}
bool isKeyOf(const MDFile *RHS) const { bool isKeyOf(const DIFile *RHS) const {
return Filename == RHS->getFilename() && Directory == RHS->getDirectory(); return Filename == RHS->getFilename() && Directory == RHS->getDirectory();
} }
unsigned getHashValue() const { return hash_combine(Filename, Directory); } unsigned getHashValue() const { return hash_combine(Filename, Directory); }
}; };
template <> struct MDNodeKeyImpl<MDCompileUnit> { template <> struct MDNodeKeyImpl<DICompileUnit> {
unsigned SourceLanguage; unsigned SourceLanguage;
Metadata *File; Metadata *File;
StringRef Producer; StringRef Producer;
@ -485,7 +485,7 @@ template <> struct MDNodeKeyImpl<MDCompileUnit> {
EnumTypes(EnumTypes), RetainedTypes(RetainedTypes), EnumTypes(EnumTypes), RetainedTypes(RetainedTypes),
Subprograms(Subprograms), GlobalVariables(GlobalVariables), Subprograms(Subprograms), GlobalVariables(GlobalVariables),
ImportedEntities(ImportedEntities) {} ImportedEntities(ImportedEntities) {}
MDNodeKeyImpl(const MDCompileUnit *N) MDNodeKeyImpl(const DICompileUnit *N)
: SourceLanguage(N->getSourceLanguage()), File(N->getRawFile()), : SourceLanguage(N->getSourceLanguage()), File(N->getRawFile()),
Producer(N->getProducer()), IsOptimized(N->isOptimized()), Producer(N->getProducer()), IsOptimized(N->isOptimized()),
Flags(N->getFlags()), RuntimeVersion(N->getRuntimeVersion()), Flags(N->getFlags()), RuntimeVersion(N->getRuntimeVersion()),
@ -496,7 +496,7 @@ template <> struct MDNodeKeyImpl<MDCompileUnit> {
GlobalVariables(N->getRawGlobalVariables()), GlobalVariables(N->getRawGlobalVariables()),
ImportedEntities(N->getRawImportedEntities()) {} ImportedEntities(N->getRawImportedEntities()) {}
bool isKeyOf(const MDCompileUnit *RHS) const { bool isKeyOf(const DICompileUnit *RHS) const {
return SourceLanguage == RHS->getSourceLanguage() && return SourceLanguage == RHS->getSourceLanguage() &&
File == RHS->getRawFile() && Producer == RHS->getProducer() && File == RHS->getRawFile() && Producer == RHS->getProducer() &&
IsOptimized == RHS->isOptimized() && Flags == RHS->getFlags() && IsOptimized == RHS->isOptimized() && Flags == RHS->getFlags() &&
@ -517,7 +517,7 @@ template <> struct MDNodeKeyImpl<MDCompileUnit> {
} }
}; };
template <> struct MDNodeKeyImpl<MDSubprogram> { template <> struct MDNodeKeyImpl<DISubprogram> {
Metadata *Scope; Metadata *Scope;
StringRef Name; StringRef Name;
StringRef LinkageName; StringRef LinkageName;
@ -551,7 +551,7 @@ template <> struct MDNodeKeyImpl<MDSubprogram> {
VirtualIndex(VirtualIndex), Flags(Flags), IsOptimized(IsOptimized), VirtualIndex(VirtualIndex), Flags(Flags), IsOptimized(IsOptimized),
Function(Function), TemplateParams(TemplateParams), Function(Function), TemplateParams(TemplateParams),
Declaration(Declaration), Variables(Variables) {} Declaration(Declaration), Variables(Variables) {}
MDNodeKeyImpl(const MDSubprogram *N) MDNodeKeyImpl(const DISubprogram *N)
: Scope(N->getRawScope()), Name(N->getName()), : Scope(N->getRawScope()), Name(N->getName()),
LinkageName(N->getLinkageName()), File(N->getRawFile()), LinkageName(N->getLinkageName()), File(N->getRawFile()),
Line(N->getLine()), Type(N->getRawType()), Line(N->getLine()), Type(N->getRawType()),
@ -563,7 +563,7 @@ template <> struct MDNodeKeyImpl<MDSubprogram> {
TemplateParams(N->getRawTemplateParams()), TemplateParams(N->getRawTemplateParams()),
Declaration(N->getRawDeclaration()), Variables(N->getRawVariables()) {} Declaration(N->getRawDeclaration()), Variables(N->getRawVariables()) {}
bool isKeyOf(const MDSubprogram *RHS) const { bool isKeyOf(const DISubprogram *RHS) const {
return Scope == RHS->getRawScope() && Name == RHS->getName() && return Scope == RHS->getRawScope() && Name == RHS->getName() &&
LinkageName == RHS->getLinkageName() && File == RHS->getRawFile() && LinkageName == RHS->getLinkageName() && File == RHS->getRawFile() &&
Line == RHS->getLine() && Type == RHS->getRawType() && Line == RHS->getLine() && Type == RHS->getRawType() &&
@ -587,7 +587,7 @@ template <> struct MDNodeKeyImpl<MDSubprogram> {
} }
}; };
template <> struct MDNodeKeyImpl<MDLexicalBlock> { template <> struct MDNodeKeyImpl<DILexicalBlock> {
Metadata *Scope; Metadata *Scope;
Metadata *File; Metadata *File;
unsigned Line; unsigned Line;
@ -595,11 +595,11 @@ template <> struct MDNodeKeyImpl<MDLexicalBlock> {
MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Line, unsigned Column) MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Line, unsigned Column)
: Scope(Scope), File(File), Line(Line), Column(Column) {} : Scope(Scope), File(File), Line(Line), Column(Column) {}
MDNodeKeyImpl(const MDLexicalBlock *N) MDNodeKeyImpl(const DILexicalBlock *N)
: Scope(N->getRawScope()), File(N->getRawFile()), Line(N->getLine()), : Scope(N->getRawScope()), File(N->getRawFile()), Line(N->getLine()),
Column(N->getColumn()) {} Column(N->getColumn()) {}
bool isKeyOf(const MDLexicalBlock *RHS) const { bool isKeyOf(const DILexicalBlock *RHS) const {
return Scope == RHS->getRawScope() && File == RHS->getRawFile() && return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
Line == RHS->getLine() && Column == RHS->getColumn(); Line == RHS->getLine() && Column == RHS->getColumn();
} }
@ -608,18 +608,18 @@ template <> struct MDNodeKeyImpl<MDLexicalBlock> {
} }
}; };
template <> struct MDNodeKeyImpl<MDLexicalBlockFile> { template <> struct MDNodeKeyImpl<DILexicalBlockFile> {
Metadata *Scope; Metadata *Scope;
Metadata *File; Metadata *File;
unsigned Discriminator; unsigned Discriminator;
MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Discriminator) MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Discriminator)
: Scope(Scope), File(File), Discriminator(Discriminator) {} : Scope(Scope), File(File), Discriminator(Discriminator) {}
MDNodeKeyImpl(const MDLexicalBlockFile *N) MDNodeKeyImpl(const DILexicalBlockFile *N)
: Scope(N->getRawScope()), File(N->getRawFile()), : Scope(N->getRawScope()), File(N->getRawFile()),
Discriminator(N->getDiscriminator()) {} Discriminator(N->getDiscriminator()) {}
bool isKeyOf(const MDLexicalBlockFile *RHS) const { bool isKeyOf(const DILexicalBlockFile *RHS) const {
return Scope == RHS->getRawScope() && File == RHS->getRawFile() && return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
Discriminator == RHS->getDiscriminator(); Discriminator == RHS->getDiscriminator();
} }
@ -628,7 +628,7 @@ template <> struct MDNodeKeyImpl<MDLexicalBlockFile> {
} }
}; };
template <> struct MDNodeKeyImpl<MDNamespace> { template <> struct MDNodeKeyImpl<DINamespace> {
Metadata *Scope; Metadata *Scope;
Metadata *File; Metadata *File;
StringRef Name; StringRef Name;
@ -636,11 +636,11 @@ template <> struct MDNodeKeyImpl<MDNamespace> {
MDNodeKeyImpl(Metadata *Scope, Metadata *File, StringRef Name, unsigned Line) MDNodeKeyImpl(Metadata *Scope, Metadata *File, StringRef Name, unsigned Line)
: Scope(Scope), File(File), Name(Name), Line(Line) {} : Scope(Scope), File(File), Name(Name), Line(Line) {}
MDNodeKeyImpl(const MDNamespace *N) MDNodeKeyImpl(const DINamespace *N)
: Scope(N->getRawScope()), File(N->getRawFile()), Name(N->getName()), : Scope(N->getRawScope()), File(N->getRawFile()), Name(N->getName()),
Line(N->getLine()) {} Line(N->getLine()) {}
bool isKeyOf(const MDNamespace *RHS) const { bool isKeyOf(const DINamespace *RHS) const {
return Scope == RHS->getRawScope() && File == RHS->getRawFile() && return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
Name == RHS->getName() && Line == RHS->getLine(); Name == RHS->getName() && Line == RHS->getLine();
} }
@ -649,21 +649,21 @@ template <> struct MDNodeKeyImpl<MDNamespace> {
} }
}; };
template <> struct MDNodeKeyImpl<MDTemplateTypeParameter> { template <> struct MDNodeKeyImpl<DITemplateTypeParameter> {
StringRef Name; StringRef Name;
Metadata *Type; Metadata *Type;
MDNodeKeyImpl(StringRef Name, Metadata *Type) : Name(Name), Type(Type) {} MDNodeKeyImpl(StringRef Name, Metadata *Type) : Name(Name), Type(Type) {}
MDNodeKeyImpl(const MDTemplateTypeParameter *N) MDNodeKeyImpl(const DITemplateTypeParameter *N)
: Name(N->getName()), Type(N->getRawType()) {} : Name(N->getName()), Type(N->getRawType()) {}
bool isKeyOf(const MDTemplateTypeParameter *RHS) const { bool isKeyOf(const DITemplateTypeParameter *RHS) const {
return Name == RHS->getName() && Type == RHS->getRawType(); return Name == RHS->getName() && Type == RHS->getRawType();
} }
unsigned getHashValue() const { return hash_combine(Name, Type); } unsigned getHashValue() const { return hash_combine(Name, Type); }
}; };
template <> struct MDNodeKeyImpl<MDTemplateValueParameter> { template <> struct MDNodeKeyImpl<DITemplateValueParameter> {
unsigned Tag; unsigned Tag;
StringRef Name; StringRef Name;
Metadata *Type; Metadata *Type;
@ -671,18 +671,18 @@ template <> struct MDNodeKeyImpl<MDTemplateValueParameter> {
MDNodeKeyImpl(unsigned Tag, StringRef Name, Metadata *Type, Metadata *Value) MDNodeKeyImpl(unsigned Tag, StringRef Name, Metadata *Type, Metadata *Value)
: Tag(Tag), Name(Name), Type(Type), Value(Value) {} : Tag(Tag), Name(Name), Type(Type), Value(Value) {}
MDNodeKeyImpl(const MDTemplateValueParameter *N) MDNodeKeyImpl(const DITemplateValueParameter *N)
: Tag(N->getTag()), Name(N->getName()), Type(N->getRawType()), : Tag(N->getTag()), Name(N->getName()), Type(N->getRawType()),
Value(N->getValue()) {} Value(N->getValue()) {}
bool isKeyOf(const MDTemplateValueParameter *RHS) const { bool isKeyOf(const DITemplateValueParameter *RHS) const {
return Tag == RHS->getTag() && Name == RHS->getName() && return Tag == RHS->getTag() && Name == RHS->getName() &&
Type == RHS->getRawType() && Value == RHS->getValue(); Type == RHS->getRawType() && Value == RHS->getValue();
} }
unsigned getHashValue() const { return hash_combine(Tag, Name, Type, Value); } unsigned getHashValue() const { return hash_combine(Tag, Name, Type, Value); }
}; };
template <> struct MDNodeKeyImpl<MDGlobalVariable> { template <> struct MDNodeKeyImpl<DIGlobalVariable> {
Metadata *Scope; Metadata *Scope;
StringRef Name; StringRef Name;
StringRef LinkageName; StringRef LinkageName;
@ -702,7 +702,7 @@ template <> struct MDNodeKeyImpl<MDGlobalVariable> {
Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit), Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
IsDefinition(IsDefinition), Variable(Variable), IsDefinition(IsDefinition), Variable(Variable),
StaticDataMemberDeclaration(StaticDataMemberDeclaration) {} StaticDataMemberDeclaration(StaticDataMemberDeclaration) {}
MDNodeKeyImpl(const MDGlobalVariable *N) MDNodeKeyImpl(const DIGlobalVariable *N)
: Scope(N->getRawScope()), Name(N->getName()), : Scope(N->getRawScope()), Name(N->getName()),
LinkageName(N->getLinkageName()), File(N->getRawFile()), LinkageName(N->getLinkageName()), File(N->getRawFile()),
Line(N->getLine()), Type(N->getRawType()), Line(N->getLine()), Type(N->getRawType()),
@ -710,7 +710,7 @@ template <> struct MDNodeKeyImpl<MDGlobalVariable> {
Variable(N->getRawVariable()), Variable(N->getRawVariable()),
StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()) {} StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()) {}
bool isKeyOf(const MDGlobalVariable *RHS) const { bool isKeyOf(const DIGlobalVariable *RHS) const {
return Scope == RHS->getRawScope() && Name == RHS->getName() && return Scope == RHS->getRawScope() && Name == RHS->getName() &&
LinkageName == RHS->getLinkageName() && File == RHS->getRawFile() && LinkageName == RHS->getLinkageName() && File == RHS->getRawFile() &&
Line == RHS->getLine() && Type == RHS->getRawType() && Line == RHS->getLine() && Type == RHS->getRawType() &&
@ -727,7 +727,7 @@ template <> struct MDNodeKeyImpl<MDGlobalVariable> {
} }
}; };
template <> struct MDNodeKeyImpl<MDLocalVariable> { template <> struct MDNodeKeyImpl<DILocalVariable> {
unsigned Tag; unsigned Tag;
Metadata *Scope; Metadata *Scope;
StringRef Name; StringRef Name;
@ -741,12 +741,12 @@ template <> struct MDNodeKeyImpl<MDLocalVariable> {
unsigned Line, Metadata *Type, unsigned Arg, unsigned Flags) unsigned Line, Metadata *Type, unsigned Arg, unsigned Flags)
: Tag(Tag), Scope(Scope), Name(Name), File(File), Line(Line), Type(Type), : Tag(Tag), Scope(Scope), Name(Name), File(File), Line(Line), Type(Type),
Arg(Arg), Flags(Flags) {} Arg(Arg), Flags(Flags) {}
MDNodeKeyImpl(const MDLocalVariable *N) MDNodeKeyImpl(const DILocalVariable *N)
: Tag(N->getTag()), Scope(N->getRawScope()), Name(N->getName()), : Tag(N->getTag()), Scope(N->getRawScope()), Name(N->getName()),
File(N->getRawFile()), Line(N->getLine()), Type(N->getRawType()), File(N->getRawFile()), Line(N->getLine()), Type(N->getRawType()),
Arg(N->getArg()), Flags(N->getFlags()) {} Arg(N->getArg()), Flags(N->getFlags()) {}
bool isKeyOf(const MDLocalVariable *RHS) const { bool isKeyOf(const DILocalVariable *RHS) const {
return Tag == RHS->getTag() && Scope == RHS->getRawScope() && return Tag == RHS->getTag() && Scope == RHS->getRawScope() &&
Name == RHS->getName() && File == RHS->getRawFile() && Name == RHS->getName() && File == RHS->getRawFile() &&
Line == RHS->getLine() && Type == RHS->getRawType() && Line == RHS->getLine() && Type == RHS->getRawType() &&
@ -757,13 +757,13 @@ template <> struct MDNodeKeyImpl<MDLocalVariable> {
} }
}; };
template <> struct MDNodeKeyImpl<MDExpression> { template <> struct MDNodeKeyImpl<DIExpression> {
ArrayRef<uint64_t> Elements; ArrayRef<uint64_t> Elements;
MDNodeKeyImpl(ArrayRef<uint64_t> Elements) : Elements(Elements) {} MDNodeKeyImpl(ArrayRef<uint64_t> Elements) : Elements(Elements) {}
MDNodeKeyImpl(const MDExpression *N) : Elements(N->getElements()) {} MDNodeKeyImpl(const DIExpression *N) : Elements(N->getElements()) {}
bool isKeyOf(const MDExpression *RHS) const { bool isKeyOf(const DIExpression *RHS) const {
return Elements == RHS->getElements(); return Elements == RHS->getElements();
} }
unsigned getHashValue() const { unsigned getHashValue() const {
@ -771,7 +771,7 @@ template <> struct MDNodeKeyImpl<MDExpression> {
} }
}; };
template <> struct MDNodeKeyImpl<MDObjCProperty> { template <> struct MDNodeKeyImpl<DIObjCProperty> {
StringRef Name; StringRef Name;
Metadata *File; Metadata *File;
unsigned Line; unsigned Line;
@ -785,12 +785,12 @@ template <> struct MDNodeKeyImpl<MDObjCProperty> {
Metadata *Type) Metadata *Type)
: Name(Name), File(File), Line(Line), GetterName(GetterName), : Name(Name), File(File), Line(Line), GetterName(GetterName),
SetterName(SetterName), Attributes(Attributes), Type(Type) {} SetterName(SetterName), Attributes(Attributes), Type(Type) {}
MDNodeKeyImpl(const MDObjCProperty *N) MDNodeKeyImpl(const DIObjCProperty *N)
: Name(N->getName()), File(N->getRawFile()), Line(N->getLine()), : Name(N->getName()), File(N->getRawFile()), Line(N->getLine()),
GetterName(N->getGetterName()), SetterName(N->getSetterName()), GetterName(N->getGetterName()), SetterName(N->getSetterName()),
Attributes(N->getAttributes()), Type(N->getRawType()) {} Attributes(N->getAttributes()), Type(N->getRawType()) {}
bool isKeyOf(const MDObjCProperty *RHS) const { bool isKeyOf(const DIObjCProperty *RHS) const {
return Name == RHS->getName() && File == RHS->getRawFile() && return Name == RHS->getName() && File == RHS->getRawFile() &&
Line == RHS->getLine() && GetterName == RHS->getGetterName() && Line == RHS->getLine() && GetterName == RHS->getGetterName() &&
SetterName == RHS->getSetterName() && SetterName == RHS->getSetterName() &&
@ -802,7 +802,7 @@ template <> struct MDNodeKeyImpl<MDObjCProperty> {
} }
}; };
template <> struct MDNodeKeyImpl<MDImportedEntity> { template <> struct MDNodeKeyImpl<DIImportedEntity> {
unsigned Tag; unsigned Tag;
Metadata *Scope; Metadata *Scope;
Metadata *Entity; Metadata *Entity;
@ -812,11 +812,11 @@ template <> struct MDNodeKeyImpl<MDImportedEntity> {
MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, unsigned Line, MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, unsigned Line,
StringRef Name) StringRef Name)
: Tag(Tag), Scope(Scope), Entity(Entity), Line(Line), Name(Name) {} : Tag(Tag), Scope(Scope), Entity(Entity), Line(Line), Name(Name) {}
MDNodeKeyImpl(const MDImportedEntity *N) MDNodeKeyImpl(const DIImportedEntity *N)
: Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()), : Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()),
Line(N->getLine()), Name(N->getName()) {} Line(N->getLine()), Name(N->getName()) {}
bool isKeyOf(const MDImportedEntity *RHS) const { bool isKeyOf(const DIImportedEntity *RHS) const {
return Tag == RHS->getTag() && Scope == RHS->getRawScope() && return Tag == RHS->getTag() && Scope == RHS->getRawScope() &&
Entity == RHS->getRawEntity() && Line == RHS->getLine() && Entity == RHS->getRawEntity() && Line == RHS->getLine() &&
Name == RHS->getName(); Name == RHS->getName();

View File

@ -305,11 +305,11 @@ private:
template <class Ty> bool isValidMetadataArray(const MDTuple &N); template <class Ty> bool isValidMetadataArray(const MDTuple &N);
#define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) void visit##CLASS(const CLASS &N); #define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) void visit##CLASS(const CLASS &N);
#include "llvm/IR/Metadata.def" #include "llvm/IR/Metadata.def"
void visitMDScope(const MDScope &N); void visitDIScope(const DIScope &N);
void visitMDDerivedTypeBase(const MDDerivedTypeBase &N); void visitDIDerivedTypeBase(const DIDerivedTypeBase &N);
void visitMDVariable(const MDVariable &N); void visitDIVariable(const DIVariable &N);
void visitMDLexicalBlockBase(const MDLexicalBlockBase &N); void visitDILexicalBlockBase(const DILexicalBlockBase &N);
void visitMDTemplateParameter(const MDTemplateParameter &N); void visitDITemplateParameter(const DITemplateParameter &N);
void visitTemplateParams(const MDNode &N, const Metadata &RawParams); void visitTemplateParams(const MDNode &N, const Metadata &RawParams);
@ -321,17 +321,17 @@ private:
/// \brief Check for a valid type reference. /// \brief Check for a valid type reference.
/// ///
/// Checks for subclasses of \a MDType, or \a isValidUUID(). /// Checks for subclasses of \a DIType, or \a isValidUUID().
bool isTypeRef(const MDNode &N, const Metadata *MD); bool isTypeRef(const MDNode &N, const Metadata *MD);
/// \brief Check for a valid scope reference. /// \brief Check for a valid scope reference.
/// ///
/// Checks for subclasses of \a MDScope, or \a isValidUUID(). /// Checks for subclasses of \a DIScope, or \a isValidUUID().
bool isScopeRef(const MDNode &N, const Metadata *MD); bool isScopeRef(const MDNode &N, const Metadata *MD);
/// \brief Check for a valid debug info reference. /// \brief Check for a valid debug info reference.
/// ///
/// Checks for subclasses of \a DebugNode, or \a isValidUUID(). /// Checks for subclasses of \a DINode, or \a isValidUUID().
bool isDIRef(const MDNode &N, const Metadata *MD); bool isDIRef(const MDNode &N, const Metadata *MD);
// InstVisitor overrides... // InstVisitor overrides...
@ -605,7 +605,7 @@ void Verifier::visitNamedMDNode(const NamedMDNode &NMD) {
MDNode *MD = NMD.getOperand(i); MDNode *MD = NMD.getOperand(i);
if (NMD.getName() == "llvm.dbg.cu") { if (NMD.getName() == "llvm.dbg.cu") {
Assert(MD && isa<MDCompileUnit>(MD), "invalid compile unit", &NMD, MD); Assert(MD && isa<DICompileUnit>(MD), "invalid compile unit", &NMD, MD);
} }
if (!MD) if (!MD)
@ -711,17 +711,17 @@ bool Verifier::isValidUUID(const MDNode &N, const Metadata *MD) {
/// \brief Check if a value can be a reference to a type. /// \brief Check if a value can be a reference to a type.
bool Verifier::isTypeRef(const MDNode &N, const Metadata *MD) { bool Verifier::isTypeRef(const MDNode &N, const Metadata *MD) {
return !MD || isValidUUID(N, MD) || isa<MDType>(MD); return !MD || isValidUUID(N, MD) || isa<DIType>(MD);
} }
/// \brief Check if a value can be a ScopeRef. /// \brief Check if a value can be a ScopeRef.
bool Verifier::isScopeRef(const MDNode &N, const Metadata *MD) { bool Verifier::isScopeRef(const MDNode &N, const Metadata *MD) {
return !MD || isValidUUID(N, MD) || isa<MDScope>(MD); return !MD || isValidUUID(N, MD) || isa<DIScope>(MD);
} }
/// \brief Check if a value can be a debug info ref. /// \brief Check if a value can be a debug info ref.
bool Verifier::isDIRef(const MDNode &N, const Metadata *MD) { bool Verifier::isDIRef(const MDNode &N, const Metadata *MD) {
return !MD || isValidUUID(N, MD) || isa<DebugNode>(MD); return !MD || isValidUUID(N, MD) || isa<DINode>(MD);
} }
template <class Ty> template <class Ty>
@ -748,40 +748,40 @@ bool isValidMetadataNullArray(const MDTuple &N) {
return isValidMetadataArrayImpl<Ty>(N, /* AllowNull */ true); return isValidMetadataArrayImpl<Ty>(N, /* AllowNull */ true);
} }
void Verifier::visitMDLocation(const MDLocation &N) { void Verifier::visitDILocation(const DILocation &N) {
Assert(N.getRawScope() && isa<MDLocalScope>(N.getRawScope()), Assert(N.getRawScope() && isa<DILocalScope>(N.getRawScope()),
"location requires a valid scope", &N, N.getRawScope()); "location requires a valid scope", &N, N.getRawScope());
if (auto *IA = N.getRawInlinedAt()) if (auto *IA = N.getRawInlinedAt())
Assert(isa<MDLocation>(IA), "inlined-at should be a location", &N, IA); Assert(isa<DILocation>(IA), "inlined-at should be a location", &N, IA);
} }
void Verifier::visitGenericDebugNode(const GenericDebugNode &N) { void Verifier::visitGenericDINode(const GenericDINode &N) {
Assert(N.getTag(), "invalid tag", &N); Assert(N.getTag(), "invalid tag", &N);
} }
void Verifier::visitMDScope(const MDScope &N) { void Verifier::visitDIScope(const DIScope &N) {
if (auto *F = N.getRawFile()) if (auto *F = N.getRawFile())
Assert(isa<MDFile>(F), "invalid file", &N, F); Assert(isa<DIFile>(F), "invalid file", &N, F);
} }
void Verifier::visitMDSubrange(const MDSubrange &N) { void Verifier::visitDISubrange(const DISubrange &N) {
Assert(N.getTag() == dwarf::DW_TAG_subrange_type, "invalid tag", &N); Assert(N.getTag() == dwarf::DW_TAG_subrange_type, "invalid tag", &N);
Assert(N.getCount() >= -1, "invalid subrange count", &N); Assert(N.getCount() >= -1, "invalid subrange count", &N);
} }
void Verifier::visitMDEnumerator(const MDEnumerator &N) { void Verifier::visitDIEnumerator(const DIEnumerator &N) {
Assert(N.getTag() == dwarf::DW_TAG_enumerator, "invalid tag", &N); Assert(N.getTag() == dwarf::DW_TAG_enumerator, "invalid tag", &N);
} }
void Verifier::visitMDBasicType(const MDBasicType &N) { void Verifier::visitDIBasicType(const DIBasicType &N) {
Assert(N.getTag() == dwarf::DW_TAG_base_type || Assert(N.getTag() == dwarf::DW_TAG_base_type ||
N.getTag() == dwarf::DW_TAG_unspecified_type, N.getTag() == dwarf::DW_TAG_unspecified_type,
"invalid tag", &N); "invalid tag", &N);
} }
void Verifier::visitMDDerivedTypeBase(const MDDerivedTypeBase &N) { void Verifier::visitDIDerivedTypeBase(const DIDerivedTypeBase &N) {
// Common scope checks. // Common scope checks.
visitMDScope(N); visitDIScope(N);
Assert(isScopeRef(N, N.getScope()), "invalid scope", &N, N.getScope()); Assert(isScopeRef(N, N.getScope()), "invalid scope", &N, N.getScope());
Assert(isTypeRef(N, N.getBaseType()), "invalid base type", &N, Assert(isTypeRef(N, N.getBaseType()), "invalid base type", &N,
@ -808,9 +808,9 @@ void Verifier::visitMDDerivedTypeBase(const MDDerivedTypeBase &N) {
} }
} }
void Verifier::visitMDDerivedType(const MDDerivedType &N) { void Verifier::visitDIDerivedType(const DIDerivedType &N) {
// Common derived type checks. // Common derived type checks.
visitMDDerivedTypeBase(N); visitDIDerivedTypeBase(N);
Assert(N.getTag() == dwarf::DW_TAG_typedef || Assert(N.getTag() == dwarf::DW_TAG_typedef ||
N.getTag() == dwarf::DW_TAG_pointer_type || N.getTag() == dwarf::DW_TAG_pointer_type ||
@ -831,22 +831,22 @@ void Verifier::visitMDDerivedType(const MDDerivedType &N) {
} }
static bool hasConflictingReferenceFlags(unsigned Flags) { static bool hasConflictingReferenceFlags(unsigned Flags) {
return (Flags & DebugNode::FlagLValueReference) && return (Flags & DINode::FlagLValueReference) &&
(Flags & DebugNode::FlagRValueReference); (Flags & DINode::FlagRValueReference);
} }
void Verifier::visitTemplateParams(const MDNode &N, const Metadata &RawParams) { void Verifier::visitTemplateParams(const MDNode &N, const Metadata &RawParams) {
auto *Params = dyn_cast<MDTuple>(&RawParams); auto *Params = dyn_cast<MDTuple>(&RawParams);
Assert(Params, "invalid template params", &N, &RawParams); Assert(Params, "invalid template params", &N, &RawParams);
for (Metadata *Op : Params->operands()) { for (Metadata *Op : Params->operands()) {
Assert(Op && isa<MDTemplateParameter>(Op), "invalid template parameter", &N, Assert(Op && isa<DITemplateParameter>(Op), "invalid template parameter", &N,
Params, Op); Params, Op);
} }
} }
void Verifier::visitMDCompositeType(const MDCompositeType &N) { void Verifier::visitDICompositeType(const DICompositeType &N) {
// Common derived type checks. // Common derived type checks.
visitMDDerivedTypeBase(N); visitDIDerivedTypeBase(N);
Assert(N.getTag() == dwarf::DW_TAG_array_type || Assert(N.getTag() == dwarf::DW_TAG_array_type ||
N.getTag() == dwarf::DW_TAG_structure_type || N.getTag() == dwarf::DW_TAG_structure_type ||
@ -868,7 +868,7 @@ void Verifier::visitMDCompositeType(const MDCompositeType &N) {
visitTemplateParams(N, *Params); visitTemplateParams(N, *Params);
} }
void Verifier::visitMDSubroutineType(const MDSubroutineType &N) { void Verifier::visitDISubroutineType(const DISubroutineType &N) {
Assert(N.getTag() == dwarf::DW_TAG_subroutine_type, "invalid tag", &N); Assert(N.getTag() == dwarf::DW_TAG_subroutine_type, "invalid tag", &N);
if (auto *Types = N.getRawTypeArray()) { if (auto *Types = N.getRawTypeArray()) {
Assert(isa<MDTuple>(Types), "invalid composite elements", &N, Types); Assert(isa<MDTuple>(Types), "invalid composite elements", &N, Types);
@ -880,24 +880,24 @@ void Verifier::visitMDSubroutineType(const MDSubroutineType &N) {
&N); &N);
} }
void Verifier::visitMDFile(const MDFile &N) { void Verifier::visitDIFile(const DIFile &N) {
Assert(N.getTag() == dwarf::DW_TAG_file_type, "invalid tag", &N); Assert(N.getTag() == dwarf::DW_TAG_file_type, "invalid tag", &N);
} }
void Verifier::visitMDCompileUnit(const MDCompileUnit &N) { void Verifier::visitDICompileUnit(const DICompileUnit &N) {
Assert(N.getTag() == dwarf::DW_TAG_compile_unit, "invalid tag", &N); Assert(N.getTag() == dwarf::DW_TAG_compile_unit, "invalid tag", &N);
// Don't bother verifying the compilation directory or producer string // Don't bother verifying the compilation directory or producer string
// as those could be empty. // as those could be empty.
Assert(N.getRawFile() && isa<MDFile>(N.getRawFile()), Assert(N.getRawFile() && isa<DIFile>(N.getRawFile()), "invalid file", &N,
"invalid file", &N, N.getRawFile()); N.getRawFile());
Assert(!N.getFile()->getFilename().empty(), "invalid filename", &N, Assert(!N.getFile()->getFilename().empty(), "invalid filename", &N,
N.getFile()); N.getFile());
if (auto *Array = N.getRawEnumTypes()) { if (auto *Array = N.getRawEnumTypes()) {
Assert(isa<MDTuple>(Array), "invalid enum list", &N, Array); Assert(isa<MDTuple>(Array), "invalid enum list", &N, Array);
for (Metadata *Op : N.getEnumTypes()->operands()) { for (Metadata *Op : N.getEnumTypes()->operands()) {
auto *Enum = dyn_cast_or_null<MDCompositeType>(Op); auto *Enum = dyn_cast_or_null<DICompositeType>(Op);
Assert(Enum && Enum->getTag() == dwarf::DW_TAG_enumeration_type, Assert(Enum && Enum->getTag() == dwarf::DW_TAG_enumeration_type,
"invalid enum type", &N, N.getEnumTypes(), Op); "invalid enum type", &N, N.getEnumTypes(), Op);
} }
@ -905,36 +905,36 @@ void Verifier::visitMDCompileUnit(const MDCompileUnit &N) {
if (auto *Array = N.getRawRetainedTypes()) { if (auto *Array = N.getRawRetainedTypes()) {
Assert(isa<MDTuple>(Array), "invalid retained type list", &N, Array); Assert(isa<MDTuple>(Array), "invalid retained type list", &N, Array);
for (Metadata *Op : N.getRetainedTypes()->operands()) { for (Metadata *Op : N.getRetainedTypes()->operands()) {
Assert(Op && isa<MDType>(Op), "invalid retained type", &N, Op); Assert(Op && isa<DIType>(Op), "invalid retained type", &N, Op);
} }
} }
if (auto *Array = N.getRawSubprograms()) { if (auto *Array = N.getRawSubprograms()) {
Assert(isa<MDTuple>(Array), "invalid subprogram list", &N, Array); Assert(isa<MDTuple>(Array), "invalid subprogram list", &N, Array);
for (Metadata *Op : N.getSubprograms()->operands()) { for (Metadata *Op : N.getSubprograms()->operands()) {
Assert(Op && isa<MDSubprogram>(Op), "invalid subprogram ref", &N, Op); Assert(Op && isa<DISubprogram>(Op), "invalid subprogram ref", &N, Op);
} }
} }
if (auto *Array = N.getRawGlobalVariables()) { if (auto *Array = N.getRawGlobalVariables()) {
Assert(isa<MDTuple>(Array), "invalid global variable list", &N, Array); Assert(isa<MDTuple>(Array), "invalid global variable list", &N, Array);
for (Metadata *Op : N.getGlobalVariables()->operands()) { for (Metadata *Op : N.getGlobalVariables()->operands()) {
Assert(Op && isa<MDGlobalVariable>(Op), "invalid global variable ref", &N, Assert(Op && isa<DIGlobalVariable>(Op), "invalid global variable ref", &N,
Op); Op);
} }
} }
if (auto *Array = N.getRawImportedEntities()) { if (auto *Array = N.getRawImportedEntities()) {
Assert(isa<MDTuple>(Array), "invalid imported entity list", &N, Array); Assert(isa<MDTuple>(Array), "invalid imported entity list", &N, Array);
for (Metadata *Op : N.getImportedEntities()->operands()) { for (Metadata *Op : N.getImportedEntities()->operands()) {
Assert(Op && isa<MDImportedEntity>(Op), "invalid imported entity ref", &N, Assert(Op && isa<DIImportedEntity>(Op), "invalid imported entity ref", &N,
Op); Op);
} }
} }
} }
void Verifier::visitMDSubprogram(const MDSubprogram &N) { void Verifier::visitDISubprogram(const DISubprogram &N) {
Assert(N.getTag() == dwarf::DW_TAG_subprogram, "invalid tag", &N); Assert(N.getTag() == dwarf::DW_TAG_subprogram, "invalid tag", &N);
Assert(isScopeRef(N, N.getRawScope()), "invalid scope", &N, N.getRawScope()); Assert(isScopeRef(N, N.getRawScope()), "invalid scope", &N, N.getRawScope());
if (auto *T = N.getRawType()) if (auto *T = N.getRawType())
Assert(isa<MDSubroutineType>(T), "invalid subroutine type", &N, T); Assert(isa<DISubroutineType>(T), "invalid subroutine type", &N, T);
Assert(isTypeRef(N, N.getRawContainingType()), "invalid containing type", &N, Assert(isTypeRef(N, N.getRawContainingType()), "invalid containing type", &N,
N.getRawContainingType()); N.getRawContainingType());
if (auto *RawF = N.getRawFunction()) { if (auto *RawF = N.getRawFunction()) {
@ -947,14 +947,14 @@ void Verifier::visitMDSubprogram(const MDSubprogram &N) {
if (auto *Params = N.getRawTemplateParams()) if (auto *Params = N.getRawTemplateParams())
visitTemplateParams(N, *Params); visitTemplateParams(N, *Params);
if (auto *S = N.getRawDeclaration()) { if (auto *S = N.getRawDeclaration()) {
Assert(isa<MDSubprogram>(S) && !cast<MDSubprogram>(S)->isDefinition(), Assert(isa<DISubprogram>(S) && !cast<DISubprogram>(S)->isDefinition(),
"invalid subprogram declaration", &N, S); "invalid subprogram declaration", &N, S);
} }
if (auto *RawVars = N.getRawVariables()) { if (auto *RawVars = N.getRawVariables()) {
auto *Vars = dyn_cast<MDTuple>(RawVars); auto *Vars = dyn_cast<MDTuple>(RawVars);
Assert(Vars, "invalid variable list", &N, RawVars); Assert(Vars, "invalid variable list", &N, RawVars);
for (Metadata *Op : Vars->operands()) { for (Metadata *Op : Vars->operands()) {
Assert(Op && isa<MDLocalVariable>(Op), "invalid local variable", &N, Vars, Assert(Op && isa<DILocalVariable>(Op), "invalid local variable", &N, Vars,
Op); Op);
} }
} }
@ -973,20 +973,20 @@ void Verifier::visitMDSubprogram(const MDSubprogram &N) {
SmallPtrSet<const MDNode *, 32> Seen; SmallPtrSet<const MDNode *, 32> Seen;
for (auto &BB : *F) for (auto &BB : *F)
for (auto &I : BB) { for (auto &I : BB) {
// Be careful about using MDLocation here since we might be dealing with // Be careful about using DILocation here since we might be dealing with
// broken code (this is the Verifier after all). // broken code (this is the Verifier after all).
MDLocation *DL = DILocation *DL =
dyn_cast_or_null<MDLocation>(I.getDebugLoc().getAsMDNode()); dyn_cast_or_null<DILocation>(I.getDebugLoc().getAsMDNode());
if (!DL) if (!DL)
continue; continue;
if (!Seen.insert(DL).second) if (!Seen.insert(DL).second)
continue; continue;
MDLocalScope *Scope = DL->getInlinedAtScope(); DILocalScope *Scope = DL->getInlinedAtScope();
if (Scope && !Seen.insert(Scope).second) if (Scope && !Seen.insert(Scope).second)
continue; continue;
MDSubprogram *SP = Scope ? Scope->getSubprogram() : nullptr; DISubprogram *SP = Scope ? Scope->getSubprogram() : nullptr;
if (SP && !Seen.insert(SP).second) if (SP && !Seen.insert(SP).second)
continue; continue;
@ -997,43 +997,43 @@ void Verifier::visitMDSubprogram(const MDSubprogram &N) {
} }
} }
void Verifier::visitMDLexicalBlockBase(const MDLexicalBlockBase &N) { void Verifier::visitDILexicalBlockBase(const DILexicalBlockBase &N) {
Assert(N.getTag() == dwarf::DW_TAG_lexical_block, "invalid tag", &N); Assert(N.getTag() == dwarf::DW_TAG_lexical_block, "invalid tag", &N);
Assert(N.getRawScope() && isa<MDLocalScope>(N.getRawScope()), Assert(N.getRawScope() && isa<DILocalScope>(N.getRawScope()),
"invalid local scope", &N, N.getRawScope()); "invalid local scope", &N, N.getRawScope());
} }
void Verifier::visitMDLexicalBlock(const MDLexicalBlock &N) { void Verifier::visitDILexicalBlock(const DILexicalBlock &N) {
visitMDLexicalBlockBase(N); visitDILexicalBlockBase(N);
Assert(N.getLine() || !N.getColumn(), Assert(N.getLine() || !N.getColumn(),
"cannot have column info without line info", &N); "cannot have column info without line info", &N);
} }
void Verifier::visitMDLexicalBlockFile(const MDLexicalBlockFile &N) { void Verifier::visitDILexicalBlockFile(const DILexicalBlockFile &N) {
visitMDLexicalBlockBase(N); visitDILexicalBlockBase(N);
} }
void Verifier::visitMDNamespace(const MDNamespace &N) { void Verifier::visitDINamespace(const DINamespace &N) {
Assert(N.getTag() == dwarf::DW_TAG_namespace, "invalid tag", &N); Assert(N.getTag() == dwarf::DW_TAG_namespace, "invalid tag", &N);
if (auto *S = N.getRawScope()) if (auto *S = N.getRawScope())
Assert(isa<MDScope>(S), "invalid scope ref", &N, S); Assert(isa<DIScope>(S), "invalid scope ref", &N, S);
} }
void Verifier::visitMDTemplateParameter(const MDTemplateParameter &N) { void Verifier::visitDITemplateParameter(const DITemplateParameter &N) {
Assert(isTypeRef(N, N.getType()), "invalid type ref", &N, N.getType()); Assert(isTypeRef(N, N.getType()), "invalid type ref", &N, N.getType());
} }
void Verifier::visitMDTemplateTypeParameter(const MDTemplateTypeParameter &N) { void Verifier::visitDITemplateTypeParameter(const DITemplateTypeParameter &N) {
visitMDTemplateParameter(N); visitDITemplateParameter(N);
Assert(N.getTag() == dwarf::DW_TAG_template_type_parameter, "invalid tag", Assert(N.getTag() == dwarf::DW_TAG_template_type_parameter, "invalid tag",
&N); &N);
} }
void Verifier::visitMDTemplateValueParameter( void Verifier::visitDITemplateValueParameter(
const MDTemplateValueParameter &N) { const DITemplateValueParameter &N) {
visitMDTemplateParameter(N); visitDITemplateParameter(N);
Assert(N.getTag() == dwarf::DW_TAG_template_value_parameter || Assert(N.getTag() == dwarf::DW_TAG_template_value_parameter ||
N.getTag() == dwarf::DW_TAG_GNU_template_template_param || N.getTag() == dwarf::DW_TAG_GNU_template_template_param ||
@ -1041,17 +1041,17 @@ void Verifier::visitMDTemplateValueParameter(
"invalid tag", &N); "invalid tag", &N);
} }
void Verifier::visitMDVariable(const MDVariable &N) { void Verifier::visitDIVariable(const DIVariable &N) {
if (auto *S = N.getRawScope()) if (auto *S = N.getRawScope())
Assert(isa<MDScope>(S), "invalid scope", &N, S); Assert(isa<DIScope>(S), "invalid scope", &N, S);
Assert(isTypeRef(N, N.getRawType()), "invalid type ref", &N, N.getRawType()); Assert(isTypeRef(N, N.getRawType()), "invalid type ref", &N, N.getRawType());
if (auto *F = N.getRawFile()) if (auto *F = N.getRawFile())
Assert(isa<MDFile>(F), "invalid file", &N, F); Assert(isa<DIFile>(F), "invalid file", &N, F);
} }
void Verifier::visitMDGlobalVariable(const MDGlobalVariable &N) { void Verifier::visitDIGlobalVariable(const DIGlobalVariable &N) {
// Checks common to all variables. // Checks common to all variables.
visitMDVariable(N); visitDIVariable(N);
Assert(N.getTag() == dwarf::DW_TAG_variable, "invalid tag", &N); Assert(N.getTag() == dwarf::DW_TAG_variable, "invalid tag", &N);
Assert(!N.getName().empty(), "missing global variable name", &N); Assert(!N.getName().empty(), "missing global variable name", &N);
@ -1061,40 +1061,40 @@ void Verifier::visitMDGlobalVariable(const MDGlobalVariable &N) {
"invalid global varaible ref", &N, V); "invalid global varaible ref", &N, V);
} }
if (auto *Member = N.getRawStaticDataMemberDeclaration()) { if (auto *Member = N.getRawStaticDataMemberDeclaration()) {
Assert(isa<MDDerivedType>(Member), "invalid static data member declaration", Assert(isa<DIDerivedType>(Member), "invalid static data member declaration",
&N, Member); &N, Member);
} }
} }
void Verifier::visitMDLocalVariable(const MDLocalVariable &N) { void Verifier::visitDILocalVariable(const DILocalVariable &N) {
// Checks common to all variables. // Checks common to all variables.
visitMDVariable(N); visitDIVariable(N);
Assert(N.getTag() == dwarf::DW_TAG_auto_variable || Assert(N.getTag() == dwarf::DW_TAG_auto_variable ||
N.getTag() == dwarf::DW_TAG_arg_variable, N.getTag() == dwarf::DW_TAG_arg_variable,
"invalid tag", &N); "invalid tag", &N);
Assert(N.getRawScope() && isa<MDLocalScope>(N.getRawScope()), Assert(N.getRawScope() && isa<DILocalScope>(N.getRawScope()),
"local variable requires a valid scope", &N, N.getRawScope()); "local variable requires a valid scope", &N, N.getRawScope());
} }
void Verifier::visitMDExpression(const MDExpression &N) { void Verifier::visitDIExpression(const DIExpression &N) {
Assert(N.isValid(), "invalid expression", &N); Assert(N.isValid(), "invalid expression", &N);
} }
void Verifier::visitMDObjCProperty(const MDObjCProperty &N) { void Verifier::visitDIObjCProperty(const DIObjCProperty &N) {
Assert(N.getTag() == dwarf::DW_TAG_APPLE_property, "invalid tag", &N); Assert(N.getTag() == dwarf::DW_TAG_APPLE_property, "invalid tag", &N);
if (auto *T = N.getRawType()) if (auto *T = N.getRawType())
Assert(isa<MDType>(T), "invalid type ref", &N, T); Assert(isa<DIType>(T), "invalid type ref", &N, T);
if (auto *F = N.getRawFile()) if (auto *F = N.getRawFile())
Assert(isa<MDFile>(F), "invalid file", &N, F); Assert(isa<DIFile>(F), "invalid file", &N, F);
} }
void Verifier::visitMDImportedEntity(const MDImportedEntity &N) { void Verifier::visitDIImportedEntity(const DIImportedEntity &N) {
Assert(N.getTag() == dwarf::DW_TAG_imported_module || Assert(N.getTag() == dwarf::DW_TAG_imported_module ||
N.getTag() == dwarf::DW_TAG_imported_declaration, N.getTag() == dwarf::DW_TAG_imported_declaration,
"invalid tag", &N); "invalid tag", &N);
if (auto *S = N.getRawScope()) if (auto *S = N.getRawScope())
Assert(isa<MDScope>(S), "invalid scope for imported entity", &N, S); Assert(isa<DIScope>(S), "invalid scope for imported entity", &N, S);
Assert(isDIRef(N, N.getEntity()), "invalid imported entity", &N, Assert(isDIRef(N, N.getEntity()), "invalid imported entity", &N,
N.getEntity()); N.getEntity());
} }
@ -2904,7 +2904,7 @@ void Verifier::visitInstruction(Instruction &I) {
} }
if (MDNode *N = I.getDebugLoc().getAsMDNode()) { if (MDNode *N = I.getDebugLoc().getAsMDNode()) {
Assert(isa<MDLocation>(N), "invalid !dbg metadata attachment", &I, N); Assert(isa<DILocation>(N), "invalid !dbg metadata attachment", &I, N);
visitMDNode(*N); visitMDNode(*N);
} }
@ -3373,18 +3373,18 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
/// ///
/// This carefully grabs the subprogram from a local scope, avoiding the /// This carefully grabs the subprogram from a local scope, avoiding the
/// built-in assertions that would typically fire. /// built-in assertions that would typically fire.
static MDSubprogram *getSubprogram(Metadata *LocalScope) { static DISubprogram *getSubprogram(Metadata *LocalScope) {
if (!LocalScope) if (!LocalScope)
return nullptr; return nullptr;
if (auto *SP = dyn_cast<MDSubprogram>(LocalScope)) if (auto *SP = dyn_cast<DISubprogram>(LocalScope))
return SP; return SP;
if (auto *LB = dyn_cast<MDLexicalBlockBase>(LocalScope)) if (auto *LB = dyn_cast<DILexicalBlockBase>(LocalScope))
return getSubprogram(LB->getRawScope()); return getSubprogram(LB->getRawScope());
// Just return null; broken scope chains are checked elsewhere. // Just return null; broken scope chains are checked elsewhere.
assert(!isa<MDLocalScope>(LocalScope) && "Unknown type of local scope"); assert(!isa<DILocalScope>(LocalScope) && "Unknown type of local scope");
return nullptr; return nullptr;
} }
@ -3394,29 +3394,29 @@ void Verifier::visitDbgIntrinsic(StringRef Kind, DbgIntrinsicTy &DII) {
Assert(isa<ValueAsMetadata>(MD) || Assert(isa<ValueAsMetadata>(MD) ||
(isa<MDNode>(MD) && !cast<MDNode>(MD)->getNumOperands()), (isa<MDNode>(MD) && !cast<MDNode>(MD)->getNumOperands()),
"invalid llvm.dbg." + Kind + " intrinsic address/value", &DII, MD); "invalid llvm.dbg." + Kind + " intrinsic address/value", &DII, MD);
Assert(isa<MDLocalVariable>(DII.getRawVariable()), Assert(isa<DILocalVariable>(DII.getRawVariable()),
"invalid llvm.dbg." + Kind + " intrinsic variable", &DII, "invalid llvm.dbg." + Kind + " intrinsic variable", &DII,
DII.getRawVariable()); DII.getRawVariable());
Assert(isa<MDExpression>(DII.getRawExpression()), Assert(isa<DIExpression>(DII.getRawExpression()),
"invalid llvm.dbg." + Kind + " intrinsic expression", &DII, "invalid llvm.dbg." + Kind + " intrinsic expression", &DII,
DII.getRawExpression()); DII.getRawExpression());
// Ignore broken !dbg attachments; they're checked elsewhere. // Ignore broken !dbg attachments; they're checked elsewhere.
if (MDNode *N = DII.getDebugLoc().getAsMDNode()) if (MDNode *N = DII.getDebugLoc().getAsMDNode())
if (!isa<MDLocation>(N)) if (!isa<DILocation>(N))
return; return;
BasicBlock *BB = DII.getParent(); BasicBlock *BB = DII.getParent();
Function *F = BB ? BB->getParent() : nullptr; Function *F = BB ? BB->getParent() : nullptr;
// The scopes for variables and !dbg attachments must agree. // The scopes for variables and !dbg attachments must agree.
MDLocalVariable *Var = DII.getVariable(); DILocalVariable *Var = DII.getVariable();
MDLocation *Loc = DII.getDebugLoc(); DILocation *Loc = DII.getDebugLoc();
Assert(Loc, "llvm.dbg." + Kind + " intrinsic requires a !dbg attachment", Assert(Loc, "llvm.dbg." + Kind + " intrinsic requires a !dbg attachment",
&DII, BB, F); &DII, BB, F);
MDSubprogram *VarSP = getSubprogram(Var->getRawScope()); DISubprogram *VarSP = getSubprogram(Var->getRawScope());
MDSubprogram *LocSP = getSubprogram(Loc->getRawScope()); DISubprogram *LocSP = getSubprogram(Loc->getRawScope());
if (!VarSP || !LocSP) if (!VarSP || !LocSP)
return; // Broken scope chains are checked elsewhere. return; // Broken scope chains are checked elsewhere.
@ -3427,16 +3427,16 @@ void Verifier::visitDbgIntrinsic(StringRef Kind, DbgIntrinsicTy &DII) {
} }
template <class MapTy> template <class MapTy>
static uint64_t getVariableSize(const MDLocalVariable &V, const MapTy &Map) { static uint64_t getVariableSize(const DILocalVariable &V, const MapTy &Map) {
// Be careful of broken types (checked elsewhere). // Be careful of broken types (checked elsewhere).
const Metadata *RawType = V.getRawType(); const Metadata *RawType = V.getRawType();
while (RawType) { while (RawType) {
// Try to get the size directly. // Try to get the size directly.
if (auto *T = dyn_cast<MDType>(RawType)) if (auto *T = dyn_cast<DIType>(RawType))
if (uint64_t Size = T->getSizeInBits()) if (uint64_t Size = T->getSizeInBits())
return Size; return Size;
if (auto *DT = dyn_cast<MDDerivedType>(RawType)) { if (auto *DT = dyn_cast<DIDerivedType>(RawType)) {
// Look at the base type. // Look at the base type.
RawType = DT->getRawBaseType(); RawType = DT->getRawBaseType();
continue; continue;
@ -3459,15 +3459,15 @@ static uint64_t getVariableSize(const MDLocalVariable &V, const MapTy &Map) {
template <class MapTy> template <class MapTy>
void Verifier::verifyBitPieceExpression(const DbgInfoIntrinsic &I, void Verifier::verifyBitPieceExpression(const DbgInfoIntrinsic &I,
const MapTy &TypeRefs) { const MapTy &TypeRefs) {
MDLocalVariable *V; DILocalVariable *V;
MDExpression *E; DIExpression *E;
if (auto *DVI = dyn_cast<DbgValueInst>(&I)) { if (auto *DVI = dyn_cast<DbgValueInst>(&I)) {
V = dyn_cast_or_null<MDLocalVariable>(DVI->getRawVariable()); V = dyn_cast_or_null<DILocalVariable>(DVI->getRawVariable());
E = dyn_cast_or_null<MDExpression>(DVI->getRawExpression()); E = dyn_cast_or_null<DIExpression>(DVI->getRawExpression());
} else { } else {
auto *DDI = cast<DbgDeclareInst>(&I); auto *DDI = cast<DbgDeclareInst>(&I);
V = dyn_cast_or_null<MDLocalVariable>(DDI->getRawVariable()); V = dyn_cast_or_null<DILocalVariable>(DDI->getRawVariable());
E = dyn_cast_or_null<MDExpression>(DDI->getRawExpression()); E = dyn_cast_or_null<DIExpression>(DDI->getRawExpression());
} }
// We don't know whether this intrinsic verified correctly. // We don't know whether this intrinsic verified correctly.
@ -3503,11 +3503,11 @@ void Verifier::verifyTypeRefs() {
return; return;
// Visit all the compile units again to map the type references. // Visit all the compile units again to map the type references.
SmallDenseMap<const MDString *, const MDType *, 32> TypeRefs; SmallDenseMap<const MDString *, const DIType *, 32> TypeRefs;
for (auto *CU : CUs->operands()) for (auto *CU : CUs->operands())
if (auto Ts = cast<MDCompileUnit>(CU)->getRetainedTypes()) if (auto Ts = cast<DICompileUnit>(CU)->getRetainedTypes())
for (MDType *Op : Ts) for (DIType *Op : Ts)
if (auto *T = dyn_cast<MDCompositeType>(Op)) if (auto *T = dyn_cast<DICompositeType>(Op))
if (auto *S = T->getRawIdentifier()) { if (auto *S = T->getRawIdentifier()) {
UnresolvedTypeRefs.erase(S); UnresolvedTypeRefs.erase(S);
TypeRefs.insert(std::make_pair(S, T)); TypeRefs.insert(std::make_pair(S, T));

View File

@ -1288,10 +1288,10 @@ void ModuleLinker::stripReplacedSubprograms() {
if (!CompileUnits) if (!CompileUnits)
return; return;
for (unsigned I = 0, E = CompileUnits->getNumOperands(); I != E; ++I) { for (unsigned I = 0, E = CompileUnits->getNumOperands(); I != E; ++I) {
auto *CU = cast<MDCompileUnit>(CompileUnits->getOperand(I)); auto *CU = cast<DICompileUnit>(CompileUnits->getOperand(I));
assert(CU && "Expected valid compile unit"); assert(CU && "Expected valid compile unit");
for (MDSubprogram *SP : CU->getSubprograms()) { for (DISubprogram *SP : CU->getSubprograms()) {
if (!SP || !SP->getFunction() || !Functions.count(SP->getFunction())) if (!SP || !SP->getFunction() || !Functions.count(SP->getFunction()))
continue; continue;

View File

@ -348,7 +348,7 @@ void AArch64AsmPrinter::PrintDebugValueComment(const MachineInstr *MI,
assert(NOps == 4); assert(NOps == 4);
OS << '\t' << MAI->getCommentString() << "DEBUG_VALUE: "; OS << '\t' << MAI->getCommentString() << "DEBUG_VALUE: ";
// cast away const; DIetc do not take const operands for some reason. // cast away const; DIetc do not take const operands for some reason.
OS << cast<MDLocalVariable>(MI->getOperand(NOps - 2).getMetadata()) OS << cast<DILocalVariable>(MI->getOperand(NOps - 2).getMetadata())
->getName(); ->getName();
OS << " <- "; OS << " <- ";
// Frame address. Currently handles register +- offset only. // Frame address. Currently handles register +- offset only.

View File

@ -129,7 +129,7 @@ void NVPTXAsmPrinter::emitLineNumberAsDotLoc(const MachineInstr &MI) {
if (!curLoc) if (!curLoc)
return; return;
auto *Scope = cast_or_null<MDScope>(curLoc.getScope()); auto *Scope = cast_or_null<DIScope>(curLoc.getScope());
if (!Scope) if (!Scope)
return; return;
@ -773,7 +773,7 @@ void NVPTXAsmPrinter::recordAndEmitFilenames(Module &M) {
DbgFinder.processModule(M); DbgFinder.processModule(M);
unsigned i = 1; unsigned i = 1;
for (const MDCompileUnit *DIUnit : DbgFinder.compile_units()) { for (const DICompileUnit *DIUnit : DbgFinder.compile_units()) {
StringRef Filename = DIUnit->getFilename(); StringRef Filename = DIUnit->getFilename();
StringRef Dirname = DIUnit->getDirectory(); StringRef Dirname = DIUnit->getDirectory();
SmallString<128> FullPathName = Dirname; SmallString<128> FullPathName = Dirname;
@ -788,7 +788,7 @@ void NVPTXAsmPrinter::recordAndEmitFilenames(Module &M) {
++i; ++i;
} }
for (MDSubprogram *SP : DbgFinder.subprograms()) { for (DISubprogram *SP : DbgFinder.subprograms()) {
StringRef Filename = SP->getFilename(); StringRef Filename = SP->getFilename();
StringRef Dirname = SP->getDirectory(); StringRef Dirname = SP->getDirectory();
SmallString<128> FullPathName = Dirname; SmallString<128> FullPathName = Dirname;

View File

@ -90,7 +90,7 @@ namespace {
bool doInitialization(CallGraph &CG) override; bool doInitialization(CallGraph &CG) override;
/// The maximum number of elements to expand, or 0 for unlimited. /// The maximum number of elements to expand, or 0 for unlimited.
unsigned maxElements; unsigned maxElements;
DenseMap<const Function *, MDSubprogram *> FunctionDIs; DenseMap<const Function *, DISubprogram *> FunctionDIs;
}; };
} }
@ -706,7 +706,7 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
// Patch the pointer to LLVM function in debug info descriptor. // Patch the pointer to LLVM function in debug info descriptor.
auto DI = FunctionDIs.find(F); auto DI = FunctionDIs.find(F);
if (DI != FunctionDIs.end()) { if (DI != FunctionDIs.end()) {
MDSubprogram *SP = DI->second; DISubprogram *SP = DI->second;
SP->replaceFunction(NF); SP->replaceFunction(NF);
// Ensure the map is updated so it can be reused on subsequent argument // Ensure the map is updated so it can be reused on subsequent argument
// promotions of the same function. // promotions of the same function.

View File

@ -127,7 +127,7 @@ namespace {
// As the code generation for module is finished (and DIBuilder is // As the code generation for module is finished (and DIBuilder is
// finalized) we assume that subprogram descriptors won't be changed, and // finalized) we assume that subprogram descriptors won't be changed, and
// they are stored in map for short duration anyway. // they are stored in map for short duration anyway.
DenseMap<const Function *, MDSubprogram *> FunctionDIs; DenseMap<const Function *, DISubprogram *> FunctionDIs;
protected: protected:
// DAH uses this to specify a different ID. // DAH uses this to specify a different ID.
@ -303,7 +303,7 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
// Patch the pointer to LLVM function in debug info descriptor. // Patch the pointer to LLVM function in debug info descriptor.
auto DI = FunctionDIs.find(&Fn); auto DI = FunctionDIs.find(&Fn);
if (DI != FunctionDIs.end()) { if (DI != FunctionDIs.end()) {
MDSubprogram *SP = DI->second; DISubprogram *SP = DI->second;
SP->replaceFunction(NF); SP->replaceFunction(NF);
// Ensure the map is updated so it can be reused on non-varargs argument // Ensure the map is updated so it can be reused on non-varargs argument
// eliminations of the same function. // eliminations of the same function.

View File

@ -305,10 +305,10 @@ bool StripDeadDebugInfo::runOnModule(Module &M) {
SmallVector<Metadata *, 64> LiveSubprograms; SmallVector<Metadata *, 64> LiveSubprograms;
DenseSet<const MDNode *> VisitedSet; DenseSet<const MDNode *> VisitedSet;
for (MDCompileUnit *DIC : F.compile_units()) { for (DICompileUnit *DIC : F.compile_units()) {
// Create our live subprogram list. // Create our live subprogram list.
bool SubprogramChange = false; bool SubprogramChange = false;
for (MDSubprogram *DISP : DIC->getSubprograms()) { for (DISubprogram *DISP : DIC->getSubprograms()) {
// Make sure we visit each subprogram only once. // Make sure we visit each subprogram only once.
if (!VisitedSet.insert(DISP).second) if (!VisitedSet.insert(DISP).second)
continue; continue;
@ -322,7 +322,7 @@ bool StripDeadDebugInfo::runOnModule(Module &M) {
// Create our live global variable list. // Create our live global variable list.
bool GlobalVariableChange = false; bool GlobalVariableChange = false;
for (MDGlobalVariable *DIG : DIC->getGlobalVariables()) { for (DIGlobalVariable *DIG : DIC->getGlobalVariables()) {
// Make sure we only visit each global variable only once. // Make sure we only visit each global variable only once.
if (!VisitedSet.insert(DIG).second) if (!VisitedSet.insert(DIG).second)
continue; continue;

View File

@ -250,8 +250,8 @@ struct LocationMetadata {
void parse(MDNode *MDN) { void parse(MDNode *MDN) {
assert(MDN->getNumOperands() == 3); assert(MDN->getNumOperands() == 3);
MDString *MDFilename = cast<MDString>(MDN->getOperand(0)); MDString *DIFilename = cast<MDString>(MDN->getOperand(0));
Filename = MDFilename->getString(); Filename = DIFilename->getString();
LineNo = LineNo =
mdconst::extract<ConstantInt>(MDN->getOperand(1))->getLimitedValue(); mdconst::extract<ConstantInt>(MDN->getOperand(1))->getLimitedValue();
ColumnNo = ColumnNo =

View File

@ -248,7 +248,7 @@ class DataFlowSanitizer : public ModulePass {
DFSanABIList ABIList; DFSanABIList ABIList;
DenseMap<Value *, Function *> UnwrappedFnMap; DenseMap<Value *, Function *> UnwrappedFnMap;
AttributeSet ReadOnlyNoneAttrs; AttributeSet ReadOnlyNoneAttrs;
DenseMap<const Function *, MDSubprogram *> FunctionDIs; DenseMap<const Function *, DISubprogram *> FunctionDIs;
Value *getShadowAddress(Value *Addr, Instruction *Pos); Value *getShadowAddress(Value *Addr, Instruction *Pos);
bool isInstrumented(const Function *F); bool isInstrumented(const Function *F);

View File

@ -126,7 +126,7 @@ namespace {
Function *insertFlush(ArrayRef<std::pair<GlobalVariable*, MDNode*> >); Function *insertFlush(ArrayRef<std::pair<GlobalVariable*, MDNode*> >);
void insertIndirectCounterIncrement(); void insertIndirectCounterIncrement();
std::string mangleName(const MDCompileUnit *CU, const char *NewStem); std::string mangleName(const DICompileUnit *CU, const char *NewStem);
GCOVOptions Options; GCOVOptions Options;
@ -149,7 +149,7 @@ ModulePass *llvm::createGCOVProfilerPass(const GCOVOptions &Options) {
return new GCOVProfiler(Options); return new GCOVProfiler(Options);
} }
static StringRef getFunctionName(const MDSubprogram *SP) { static StringRef getFunctionName(const DISubprogram *SP) {
if (!SP->getLinkageName().empty()) if (!SP->getLinkageName().empty())
return SP->getLinkageName(); return SP->getLinkageName();
return SP->getName(); return SP->getName();
@ -309,7 +309,7 @@ namespace {
// object users can construct, the blocks and lines will be rooted here. // object users can construct, the blocks and lines will be rooted here.
class GCOVFunction : public GCOVRecord { class GCOVFunction : public GCOVRecord {
public: public:
GCOVFunction(const MDSubprogram *SP, raw_ostream *os, uint32_t Ident, GCOVFunction(const DISubprogram *SP, raw_ostream *os, uint32_t Ident,
bool UseCfgChecksum, bool ExitBlockBeforeBody) bool UseCfgChecksum, bool ExitBlockBeforeBody)
: SP(SP), Ident(Ident), UseCfgChecksum(UseCfgChecksum), CfgChecksum(0), : SP(SP), Ident(Ident), UseCfgChecksum(UseCfgChecksum), CfgChecksum(0),
ReturnBlock(1, os) { ReturnBlock(1, os) {
@ -411,7 +411,7 @@ namespace {
} }
private: private:
const MDSubprogram *SP; const DISubprogram *SP;
uint32_t Ident; uint32_t Ident;
uint32_t FuncChecksum; uint32_t FuncChecksum;
bool UseCfgChecksum; bool UseCfgChecksum;
@ -421,7 +421,7 @@ namespace {
}; };
} }
std::string GCOVProfiler::mangleName(const MDCompileUnit *CU, std::string GCOVProfiler::mangleName(const DICompileUnit *CU,
const char *NewStem) { const char *NewStem) {
if (NamedMDNode *GCov = M->getNamedMetadata("llvm.gcov")) { if (NamedMDNode *GCov = M->getNamedMetadata("llvm.gcov")) {
for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) { for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) {
@ -488,7 +488,7 @@ void GCOVProfiler::emitProfileNotes() {
// this pass over the original .o's as they're produced, or run it after // this pass over the original .o's as they're produced, or run it after
// LTO, we'll generate the same .gcno files. // LTO, we'll generate the same .gcno files.
auto *CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i)); auto *CU = cast<DICompileUnit>(CU_Nodes->getOperand(i));
std::error_code EC; std::error_code EC;
raw_fd_ostream out(mangleName(CU, "gcno"), EC, sys::fs::F_None); raw_fd_ostream out(mangleName(CU, "gcno"), EC, sys::fs::F_None);
std::string EdgeDestinations; std::string EdgeDestinations;
@ -571,7 +571,7 @@ bool GCOVProfiler::emitProfileArcs() {
bool Result = false; bool Result = false;
bool InsertIndCounterIncrCode = false; bool InsertIndCounterIncrCode = false;
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) { for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
auto *CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i)); auto *CU = cast<DICompileUnit>(CU_Nodes->getOperand(i));
SmallVector<std::pair<GlobalVariable *, MDNode *>, 8> CountersBySP; SmallVector<std::pair<GlobalVariable *, MDNode *>, 8> CountersBySP;
for (auto *SP : CU->getSubprograms()) { for (auto *SP : CU->getSubprograms()) {
Function *F = SP->getFunction(); Function *F = SP->getFunction();
@ -847,7 +847,7 @@ Function *GCOVProfiler::insertCounterWriteout(
NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu"); NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
if (CU_Nodes) { if (CU_Nodes) {
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) { for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
auto *CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i)); auto *CU = cast<DICompileUnit>(CU_Nodes->getOperand(i));
std::string FilenameGcda = mangleName(CU, "gcda"); std::string FilenameGcda = mangleName(CU, "gcda");
uint32_t CfgChecksum = FileChecksums.empty() ? 0 : FileChecksums[i]; uint32_t CfgChecksum = FileChecksums.empty() ? 0 : FileChecksums[i];
Builder.CreateCall3(StartFile, Builder.CreateCall3(StartFile,
@ -855,7 +855,7 @@ Function *GCOVProfiler::insertCounterWriteout(
Builder.CreateGlobalStringPtr(ReversedVersion), Builder.CreateGlobalStringPtr(ReversedVersion),
Builder.getInt32(CfgChecksum)); Builder.getInt32(CfgChecksum));
for (unsigned j = 0, e = CountersBySP.size(); j != e; ++j) { for (unsigned j = 0, e = CountersBySP.size(); j != e; ++j) {
auto *SP = cast_or_null<MDSubprogram>(CountersBySP[j].second); auto *SP = cast_or_null<DISubprogram>(CountersBySP[j].second);
uint32_t FuncChecksum = Funcs.empty() ? 0 : Funcs[j]->getFuncChecksum(); uint32_t FuncChecksum = Funcs.empty() ? 0 : Funcs[j]->getFuncChecksum();
Builder.CreateCall5( Builder.CreateCall5(
EmitFunction, Builder.getInt32(j), EmitFunction, Builder.getInt32(j),

View File

@ -1096,8 +1096,8 @@ public:
// Retain the debug information attached to the alloca for use when // Retain the debug information attached to the alloca for use when
// rewriting loads and stores. // rewriting loads and stores.
if (auto *L = LocalAsMetadata::getIfExists(&AI)) { if (auto *L = LocalAsMetadata::getIfExists(&AI)) {
if (auto *DebugNode = MetadataAsValue::getIfExists(AI.getContext(), L)) { if (auto *DINode = MetadataAsValue::getIfExists(AI.getContext(), L)) {
for (User *U : DebugNode->users()) for (User *U : DINode->users())
if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(U)) if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(U))
DDIs.push_back(DDI); DDIs.push_back(DDI);
else if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(U)) else if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(U))

View File

@ -224,7 +224,7 @@ unsigned SampleProfileLoader::getInstWeight(Instruction &Inst) {
if (Lineno < HeaderLineno) if (Lineno < HeaderLineno)
return 0; return 0;
const MDLocation *DIL = DLoc; const DILocation *DIL = DLoc;
int LOffset = Lineno - HeaderLineno; int LOffset = Lineno - HeaderLineno;
unsigned Discriminator = DIL->getDiscriminator(); unsigned Discriminator = DIL->getDiscriminator();
unsigned Weight = Samples->samplesAt(LOffset, Discriminator); unsigned Weight = Samples->samplesAt(LOffset, Discriminator);
@ -642,7 +642,7 @@ void SampleProfileLoader::propagateWeights(Function &F) {
/// \returns the line number where \p F is defined. If it returns 0, /// \returns the line number where \p F is defined. If it returns 0,
/// it means that there is no debug information available for \p F. /// it means that there is no debug information available for \p F.
unsigned SampleProfileLoader::getFunctionLoc(Function &F) { unsigned SampleProfileLoader::getFunctionLoc(Function &F) {
if (MDSubprogram *S = getDISubprogram(&F)) if (DISubprogram *S = getDISubprogram(&F))
return S->getLine(); return S->getLine();
// If could not find the start of \p F, emit a diagnostic to inform the user // If could not find the start of \p F, emit a diagnostic to inform the user

View File

@ -1060,8 +1060,8 @@ public:
// Remember which alloca we're promoting (for isInstInList). // Remember which alloca we're promoting (for isInstInList).
this->AI = AI; this->AI = AI;
if (auto *L = LocalAsMetadata::getIfExists(AI)) { if (auto *L = LocalAsMetadata::getIfExists(AI)) {
if (auto *DebugNode = MetadataAsValue::getIfExists(AI->getContext(), L)) { if (auto *DINode = MetadataAsValue::getIfExists(AI->getContext(), L)) {
for (User *U : DebugNode->users()) for (User *U : DINode->users())
if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(U)) if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(U))
DDIs.push_back(DDI); DDIs.push_back(DDI);
else if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(U)) else if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(U))

View File

@ -174,14 +174,14 @@ bool AddDiscriminators::runOnFunction(Function &F) {
for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) { for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
BasicBlock *B = I; BasicBlock *B = I;
TerminatorInst *Last = B->getTerminator(); TerminatorInst *Last = B->getTerminator();
const MDLocation *LastDIL = Last->getDebugLoc(); const DILocation *LastDIL = Last->getDebugLoc();
if (!LastDIL) if (!LastDIL)
continue; continue;
for (unsigned I = 0; I < Last->getNumSuccessors(); ++I) { for (unsigned I = 0; I < Last->getNumSuccessors(); ++I) {
BasicBlock *Succ = Last->getSuccessor(I); BasicBlock *Succ = Last->getSuccessor(I);
Instruction *First = Succ->getFirstNonPHIOrDbgOrLifetime(); Instruction *First = Succ->getFirstNonPHIOrDbgOrLifetime();
const MDLocation *FirstDIL = First->getDebugLoc(); const DILocation *FirstDIL = First->getDebugLoc();
if (!FirstDIL) if (!FirstDIL)
continue; continue;
@ -197,7 +197,7 @@ bool AddDiscriminators::runOnFunction(Function &F) {
auto *File = Builder.createFile(Filename, Scope->getDirectory()); auto *File = Builder.createFile(Filename, Scope->getDirectory());
// FIXME: Calculate the discriminator here, based on local information, // FIXME: Calculate the discriminator here, based on local information,
// and delete MDLocation::computeNewDiscriminator(). The current // and delete DILocation::computeNewDiscriminator(). The current
// solution gives different results depending on other modules in the // solution gives different results depending on other modules in the
// same context. All we really need is to discriminate between // same context. All we really need is to discriminate between
// FirstDIL and LastDIL -- a local map would suffice. // FirstDIL and LastDIL -- a local map would suffice.
@ -205,7 +205,7 @@ bool AddDiscriminators::runOnFunction(Function &F) {
auto *NewScope = auto *NewScope =
Builder.createLexicalBlockFile(Scope, File, Discriminator); Builder.createLexicalBlockFile(Scope, File, Discriminator);
auto *NewDIL = auto *NewDIL =
MDLocation::get(Ctx, FirstDIL->getLine(), FirstDIL->getColumn(), DILocation::get(Ctx, FirstDIL->getLine(), FirstDIL->getColumn(),
NewScope, FirstDIL->getInlinedAt()); NewScope, FirstDIL->getInlinedAt());
DebugLoc newDebugLoc = NewDIL; DebugLoc newDebugLoc = NewDIL;

View File

@ -155,9 +155,9 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
} }
// Find the MDNode which corresponds to the subprogram data that described F. // Find the MDNode which corresponds to the subprogram data that described F.
static MDSubprogram *FindSubprogram(const Function *F, static DISubprogram *FindSubprogram(const Function *F,
DebugInfoFinder &Finder) { DebugInfoFinder &Finder) {
for (MDSubprogram *Subprogram : Finder.subprograms()) { for (DISubprogram *Subprogram : Finder.subprograms()) {
if (Subprogram->describes(F)) if (Subprogram->describes(F))
return Subprogram; return Subprogram;
} }
@ -166,7 +166,7 @@ static MDSubprogram *FindSubprogram(const Function *F,
// Add an operand to an existing MDNode. The new operand will be added at the // Add an operand to an existing MDNode. The new operand will be added at the
// back of the operand list. // back of the operand list.
static void AddOperand(MDCompileUnit *CU, MDSubprogramArray SPs, static void AddOperand(DICompileUnit *CU, DISubprogramArray SPs,
Metadata *NewSP) { Metadata *NewSP) {
SmallVector<Metadata *, 16> NewSPs; SmallVector<Metadata *, 16> NewSPs;
NewSPs.reserve(SPs.size() + 1); NewSPs.reserve(SPs.size() + 1);
@ -183,14 +183,14 @@ static void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc,
DebugInfoFinder Finder; DebugInfoFinder Finder;
Finder.processModule(*OldFunc->getParent()); Finder.processModule(*OldFunc->getParent());
const MDSubprogram *OldSubprogramMDNode = FindSubprogram(OldFunc, Finder); const DISubprogram *OldSubprogramMDNode = FindSubprogram(OldFunc, Finder);
if (!OldSubprogramMDNode) return; if (!OldSubprogramMDNode) return;
// Ensure that OldFunc appears in the map. // Ensure that OldFunc appears in the map.
// (if it's already there it must point to NewFunc anyway) // (if it's already there it must point to NewFunc anyway)
VMap[OldFunc] = NewFunc; VMap[OldFunc] = NewFunc;
auto *NewSubprogram = auto *NewSubprogram =
cast<MDSubprogram>(MapMetadata(OldSubprogramMDNode, VMap)); cast<DISubprogram>(MapMetadata(OldSubprogramMDNode, VMap));
for (auto *CU : Finder.compile_units()) { for (auto *CU : Finder.compile_units()) {
auto Subprograms = CU->getSubprograms(); auto Subprograms = CU->getSubprograms();

View File

@ -830,17 +830,16 @@ static bool hasLifetimeMarkers(AllocaInst *AI) {
/// Rebuild the entire inlined-at chain for this instruction so that the top of /// Rebuild the entire inlined-at chain for this instruction so that the top of
/// the chain now is inlined-at the new call site. /// the chain now is inlined-at the new call site.
static DebugLoc static DebugLoc
updateInlinedAtInfo(DebugLoc DL, MDLocation *InlinedAtNode, updateInlinedAtInfo(DebugLoc DL, DILocation *InlinedAtNode, LLVMContext &Ctx,
LLVMContext &Ctx, DenseMap<const DILocation *, DILocation *> &IANodes) {
DenseMap<const MDLocation *, MDLocation *> &IANodes) { SmallVector<DILocation *, 3> InlinedAtLocations;
SmallVector<MDLocation*, 3> InlinedAtLocations; DILocation *Last = InlinedAtNode;
MDLocation *Last = InlinedAtNode; DILocation *CurInlinedAt = DL;
MDLocation *CurInlinedAt = DL;
// Gather all the inlined-at nodes // Gather all the inlined-at nodes
while (MDLocation *IA = CurInlinedAt->getInlinedAt()) { while (DILocation *IA = CurInlinedAt->getInlinedAt()) {
// Skip any we've already built nodes for // Skip any we've already built nodes for
if (MDLocation *Found = IANodes[IA]) { if (DILocation *Found = IANodes[IA]) {
Last = Found; Last = Found;
break; break;
} }
@ -854,8 +853,8 @@ updateInlinedAtInfo(DebugLoc DL, MDLocation *InlinedAtNode,
// map of already-constructed inlined-at nodes. // map of already-constructed inlined-at nodes.
for (auto I = InlinedAtLocations.rbegin(), E = InlinedAtLocations.rend(); for (auto I = InlinedAtLocations.rbegin(), E = InlinedAtLocations.rend();
I != E; ++I) { I != E; ++I) {
const MDLocation *MD = *I; const DILocation *MD = *I;
Last = IANodes[MD] = MDLocation::getDistinct( Last = IANodes[MD] = DILocation::getDistinct(
Ctx, MD->getLine(), MD->getColumn(), MD->getScope(), Last); Ctx, MD->getLine(), MD->getColumn(), MD->getScope(), Last);
} }
@ -873,18 +872,18 @@ static void fixupLineNumbers(Function *Fn, Function::iterator FI,
return; return;
auto &Ctx = Fn->getContext(); auto &Ctx = Fn->getContext();
MDLocation *InlinedAtNode = TheCallDL; DILocation *InlinedAtNode = TheCallDL;
// Create a unique call site, not to be confused with any other call from the // Create a unique call site, not to be confused with any other call from the
// same location. // same location.
InlinedAtNode = MDLocation::getDistinct( InlinedAtNode = DILocation::getDistinct(
Ctx, InlinedAtNode->getLine(), InlinedAtNode->getColumn(), Ctx, InlinedAtNode->getLine(), InlinedAtNode->getColumn(),
InlinedAtNode->getScope(), InlinedAtNode->getInlinedAt()); InlinedAtNode->getScope(), InlinedAtNode->getInlinedAt());
// Cache the inlined-at nodes as they're built so they are reused, without // Cache the inlined-at nodes as they're built so they are reused, without
// this every instruction's inlined-at chain would become distinct from each // this every instruction's inlined-at chain would become distinct from each
// other. // other.
DenseMap<const MDLocation *, MDLocation *> IANodes; DenseMap<const DILocation *, DILocation *> IANodes;
for (; FI != Fn->end(); ++FI) { for (; FI != Fn->end(); ++FI) {
for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); for (BasicBlock::iterator BI = FI->begin(), BE = FI->end();

View File

@ -978,7 +978,7 @@ unsigned llvm::getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign,
/// ///
/// See if there is a dbg.value intrinsic for DIVar before I. /// See if there is a dbg.value intrinsic for DIVar before I.
static bool LdStHasDebugValue(const MDLocalVariable *DIVar, Instruction *I) { static bool LdStHasDebugValue(const DILocalVariable *DIVar, Instruction *I) {
// Since we can't guarantee that the original dbg.declare instrinsic // Since we can't guarantee that the original dbg.declare instrinsic
// is removed by LowerDbgDeclare(), we need to make sure that we are // is removed by LowerDbgDeclare(), we need to make sure that we are
// not inserting the same dbg.value intrinsic over and over. // not inserting the same dbg.value intrinsic over and over.

View File

@ -13,7 +13,7 @@ target triple = "x86_64-apple-darwin10.2"
define i32 @main() nounwind readonly { define i32 @main() nounwind readonly {
%diff1 = alloca i64 ; <i64*> [#uses=2] %diff1 = alloca i64 ; <i64*> [#uses=2]
; CHECK: call void @llvm.dbg.value(metadata i64 72, ; CHECK: call void @llvm.dbg.value(metadata i64 72,
call void @llvm.dbg.declare(metadata i64* %diff1, metadata !0, metadata !MDExpression()), !dbg !MDLocation(scope: !1) call void @llvm.dbg.declare(metadata i64* %diff1, metadata !0, metadata !DIExpression()), !dbg !DILocation(scope: !1)
store i64 72, i64* %diff1, align 8 store i64 72, i64* %diff1, align 8
%v1 = load %struct.test*, %struct.test** @TestArrayPtr, align 8 ; <%struct.test*> [#uses=1] %v1 = load %struct.test*, %struct.test** @TestArrayPtr, align 8 ; <%struct.test*> [#uses=1]
%v2 = ptrtoint %struct.test* %v1 to i64 ; <i64> [#uses=1] %v2 = ptrtoint %struct.test* %v1 to i64 ; <i64> [#uses=1]
@ -25,14 +25,14 @@ define i32 @main() nounwind readonly {
declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
!7 = !{!1} !7 = !{!1}
!6 = !MDCompileUnit(language: DW_LANG_C99, producer: "clang version 3.0 (trunk 131941)", isOptimized: true, emissionKind: 0, file: !8, enums: !9, retainedTypes: !9, subprograms: !7) !6 = !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.0 (trunk 131941)", isOptimized: true, emissionKind: 0, file: !8, enums: !9, retainedTypes: !9, subprograms: !7)
!0 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "c", line: 2, scope: !1, file: !2, type: !5) !0 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "c", line: 2, scope: !1, file: !2, type: !5)
!1 = !MDSubprogram(name: "main", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 1, file: !8, scope: !2, type: !3, function: i32 ()* @main) !1 = !DISubprogram(name: "main", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 1, file: !8, scope: !2, type: !3, function: i32 ()* @main)
!2 = !MDFile(filename: "/d/j/debug-test.c", directory: "/Volumes/Data/b") !2 = !DIFile(filename: "/d/j/debug-test.c", directory: "/Volumes/Data/b")
!3 = !MDSubroutineType(types: !4) !3 = !DISubroutineType(types: !4)
!4 = !{!5} !4 = !{!5}
!5 = !MDBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
!8 = !MDFile(filename: "/d/j/debug-test.c", directory: "/Volumes/Data/b") !8 = !DIFile(filename: "/d/j/debug-test.c", directory: "/Volumes/Data/b")
!9 = !{i32 0} !9 = !{i32 0}
!llvm.module.flags = !{!10} !llvm.module.flags = !{!10}

View File

@ -4,69 +4,69 @@
; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5, !6, !7, !8, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !27} ; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5, !6, !7, !8, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !27}
!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30} !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30}
; CHECK: !0 = !MDSubrange(count: 3) ; CHECK: !0 = !DISubrange(count: 3)
; CHECK-NEXT: !1 = !MDSubrange(count: 3, lowerBound: 4) ; CHECK-NEXT: !1 = !DISubrange(count: 3, lowerBound: 4)
; CHECK-NEXT: !2 = !MDSubrange(count: 3, lowerBound: -5) ; CHECK-NEXT: !2 = !DISubrange(count: 3, lowerBound: -5)
!0 = !MDSubrange(count: 3) !0 = !DISubrange(count: 3)
!1 = !MDSubrange(count: 3, lowerBound: 0) !1 = !DISubrange(count: 3, lowerBound: 0)
!2 = !MDSubrange(count: 3, lowerBound: 4) !2 = !DISubrange(count: 3, lowerBound: 4)
!3 = !MDSubrange(count: 3, lowerBound: -5) !3 = !DISubrange(count: 3, lowerBound: -5)
; CHECK-NEXT: !3 = !MDEnumerator(name: "seven", value: 7) ; CHECK-NEXT: !3 = !DIEnumerator(name: "seven", value: 7)
; CHECK-NEXT: !4 = !MDEnumerator(name: "negeight", value: -8) ; CHECK-NEXT: !4 = !DIEnumerator(name: "negeight", value: -8)
; CHECK-NEXT: !5 = !MDEnumerator(name: "", value: 0) ; CHECK-NEXT: !5 = !DIEnumerator(name: "", value: 0)
!4 = !MDEnumerator(name: "seven", value: 7) !4 = !DIEnumerator(name: "seven", value: 7)
!5 = !MDEnumerator(name: "negeight", value: -8) !5 = !DIEnumerator(name: "negeight", value: -8)
!6 = !MDEnumerator(name: "", value: 0) !6 = !DIEnumerator(name: "", value: 0)
; CHECK-NEXT: !6 = !MDBasicType(name: "name", size: 1, align: 2, encoding: DW_ATE_unsigned_char) ; CHECK-NEXT: !6 = !DIBasicType(name: "name", size: 1, align: 2, encoding: DW_ATE_unsigned_char)
; CHECK-NEXT: !7 = !MDBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)") ; CHECK-NEXT: !7 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
; CHECK-NEXT: !8 = !MDBasicType() ; CHECK-NEXT: !8 = !DIBasicType()
!7 = !MDBasicType(tag: DW_TAG_base_type, name: "name", size: 1, align: 2, encoding: DW_ATE_unsigned_char) !7 = !DIBasicType(tag: DW_TAG_base_type, name: "name", size: 1, align: 2, encoding: DW_ATE_unsigned_char)
!8 = !MDBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)") !8 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
!9 = !MDBasicType() !9 = !DIBasicType()
!10 = !MDBasicType(tag: DW_TAG_base_type, name: "", size: 0, align: 0, encoding: 0) !10 = !DIBasicType(tag: DW_TAG_base_type, name: "", size: 0, align: 0, encoding: 0)
; CHECK-NEXT: !9 = !MDTemplateTypeParameter(type: !6) ; CHECK-NEXT: !9 = !DITemplateTypeParameter(type: !6)
; CHECK-NEXT: !10 = !MDFile(filename: "path/to/file", directory: "/path/to/dir") ; CHECK-NEXT: !10 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
; CHECK-NEXT: !11 = distinct !{} ; CHECK-NEXT: !11 = distinct !{}
; CHECK-NEXT: !12 = !MDFile(filename: "", directory: "") ; CHECK-NEXT: !12 = !DIFile(filename: "", directory: "")
!11 = !MDTemplateTypeParameter(type: !7) !11 = !DITemplateTypeParameter(type: !7)
!12 = !MDFile(filename: "path/to/file", directory: "/path/to/dir") !12 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
!13 = distinct !{} !13 = distinct !{}
!14 = !MDFile(filename: "", directory: "") !14 = !DIFile(filename: "", directory: "")
; CHECK-NEXT: !13 = !MDDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 32, align: 32) ; CHECK-NEXT: !13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 32, align: 32)
!15 = !MDDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32, align: 32) !15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32, align: 32)
; CHECK-NEXT: !14 = !MDCompositeType(tag: DW_TAG_structure_type, name: "MyType", file: !10, line: 2, size: 32, align: 32, identifier: "MangledMyType") ; CHECK-NEXT: !14 = !DICompositeType(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", scope: !14, file: !10, line: 3, size: 128, align: 32, offset: 64, flags: DIFlagPublic, elements: !16, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !15, templateParams: !18, identifier: "MangledBase") ; CHECK-NEXT: !15 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Base", scope: !14, file: !10, line: 3, size: 128, align: 32, offset: 64, flags: DIFlagPublic, elements: !16, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !15, templateParams: !18, identifier: "MangledBase")
; CHECK-NEXT: !16 = !{!17} ; CHECK-NEXT: !16 = !{!17}
; CHECK-NEXT: !17 = !MDDerivedType(tag: DW_TAG_member, name: "field", scope: !15, file: !10, line: 4, baseType: !6, size: 32, align: 32, offset: 32, flags: DIFlagPublic) ; CHECK-NEXT: !17 = !DIDerivedType(tag: DW_TAG_member, name: "field", scope: !15, file: !10, line: 4, baseType: !6, size: 32, align: 32, offset: 32, flags: DIFlagPublic)
; CHECK-NEXT: !18 = !{!9} ; CHECK-NEXT: !18 = !{!9}
; CHECK-NEXT: !19 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Derived", scope: !14, file: !10, line: 3, baseType: !15, size: 128, align: 32, offset: 64, flags: DIFlagPublic, elements: !20, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !15, templateParams: !18, identifier: "MangledBase") ; CHECK-NEXT: !19 = !DICompositeType(tag: DW_TAG_structure_type, name: "Derived", scope: !14, file: !10, line: 3, baseType: !15, size: 128, align: 32, offset: 64, flags: DIFlagPublic, elements: !20, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !15, templateParams: !18, identifier: "MangledBase")
; CHECK-NEXT: !20 = !{!21} ; CHECK-NEXT: !20 = !{!21}
; CHECK-NEXT: !21 = !MDDerivedType(tag: DW_TAG_inheritance, scope: !19, baseType: !15) ; CHECK-NEXT: !21 = !DIDerivedType(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: !22 = !DIDerivedType(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: !23 = !DICompositeType(tag: DW_TAG_structure_type)
; CHECK-NEXT: !24 = !MDCompositeType(tag: DW_TAG_structure_type, runtimeLang: DW_LANG_Cobol85) ; CHECK-NEXT: !24 = !DICompositeType(tag: DW_TAG_structure_type, runtimeLang: DW_LANG_Cobol85)
!16 = !MDCompositeType(tag: DW_TAG_structure_type, name: "MyType", file: !12, line: 2, size: 32, align: 32, identifier: "MangledMyType") !16 = !DICompositeType(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", scope: !16, file: !12, line: 3, size: 128, align: 32, offset: 64, flags: DIFlagPublic, elements: !18, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !17, templateParams: !20, identifier: "MangledBase") !17 = !DICompositeType(tag: DW_TAG_structure_type, name: "Base", scope: !16, file: !12, line: 3, size: 128, align: 32, offset: 64, flags: DIFlagPublic, elements: !18, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !17, templateParams: !20, identifier: "MangledBase")
!18 = !{!19} !18 = !{!19}
!19 = !MDDerivedType(tag: DW_TAG_member, name: "field", scope: !17, file: !12, line: 4, baseType: !7, size: 32, align: 32, offset: 32, flags: DIFlagPublic) !19 = !DIDerivedType(tag: DW_TAG_member, name: "field", scope: !17, file: !12, line: 4, baseType: !7, size: 32, align: 32, offset: 32, flags: DIFlagPublic)
!20 = !{!11} !20 = !{!11}
!21 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Derived", scope: !16, file: !12, line: 3, baseType: !17, size: 128, align: 32, offset: 64, flags: DIFlagPublic, elements: !22, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !17, templateParams: !20, identifier: "MangledBase") !21 = !DICompositeType(tag: DW_TAG_structure_type, name: "Derived", scope: !16, file: !12, line: 3, baseType: !17, size: 128, align: 32, offset: 64, flags: DIFlagPublic, elements: !22, runtimeLang: DW_LANG_C_plus_plus_11, vtableHolder: !17, templateParams: !20, identifier: "MangledBase")
!22 = !{!23} !22 = !{!23}
!23 = !MDDerivedType(tag: DW_TAG_inheritance, scope: !21, baseType: !17) !23 = !DIDerivedType(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) !24 = !DIDerivedType(tag: DW_TAG_ptr_to_member_type, baseType: !7, size: 32, align: 32, extraData: !17)
!25 = !MDCompositeType(tag: DW_TAG_structure_type) !25 = !DICompositeType(tag: DW_TAG_structure_type)
!26 = !MDCompositeType(tag: DW_TAG_structure_type, runtimeLang: 6) !26 = !DICompositeType(tag: DW_TAG_structure_type, runtimeLang: 6)
; !25 = !{!7, !7} ; !25 = !{!7, !7}
; !26 = !MDSubroutineType(flags: DIFlagPublic | DIFlagStaticMember, types: !25) ; !26 = !DISubroutineType(flags: DIFlagPublic | DIFlagStaticMember, types: !25)
; !27 = !MDSubroutineType(types: !25) ; !27 = !DISubroutineType(types: !25)
!27 = !{!7, !7} !27 = !{!7, !7}
!28 = !MDSubroutineType(flags: DIFlagPublic | DIFlagStaticMember, types: !27) !28 = !DISubroutineType(flags: DIFlagPublic | DIFlagStaticMember, types: !27)
!29 = !MDSubroutineType(flags: 0, types: !27) !29 = !DISubroutineType(flags: 0, types: !27)
!30 = !MDSubroutineType(types: !27) !30 = !DISubroutineType(types: !27)

View File

@ -12,17 +12,17 @@ entry:
!llvm.dbg.cu = !{!0} !llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!9} !llvm.module.flags = !{!9}
!0 = !MDCompileUnit(language: DW_LANG_C99, producer: "clang version 3.5 (trunk 195495) (llvm/trunk 195495:195504M)", isOptimized: false, emissionKind: 0, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) !0 = !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5 (trunk 195495) (llvm/trunk 195495:195504M)", isOptimized: false, emissionKind: 0, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
!1 = !MDFile(filename: "../llvm/tools/clang/test/CodeGen/debug-info-version.c", directory: "/Users/manmanren/llvm_gmail/release") !1 = !DIFile(filename: "../llvm/tools/clang/test/CodeGen/debug-info-version.c", directory: "/Users/manmanren/llvm_gmail/release")
!2 = !{i32 0} !2 = !{i32 0}
!3 = !{!4} !3 = !{!4}
!4 = !MDSubprogram(name: "main", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 3, file: !1, scope: !5, type: !6, function: i32 ()* @main, variables: !2) !4 = !DISubprogram(name: "main", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 3, file: !1, scope: !5, type: !6, function: i32 ()* @main, variables: !2)
!5 = !MDFile(filename: "../llvm/tools/clang/test/CodeGen/debug-info-version.c", directory: "/Users/manmanren/llvm_gmail/release") !5 = !DIFile(filename: "../llvm/tools/clang/test/CodeGen/debug-info-version.c", directory: "/Users/manmanren/llvm_gmail/release")
!6 = !MDSubroutineType(types: !7) !6 = !DISubroutineType(types: !7)
!7 = !{!8} !7 = !{!8}
!8 = !MDBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
!9 = !{i32 2, !"Dwarf Version", i32 2} !9 = !{i32 2, !"Dwarf Version", i32 2}
!12 = !MDLocation(line: 4, scope: !4) !12 = !DILocation(line: 4, scope: !4)
; WARN: warning: ignoring debug info with an invalid version (0) ; WARN: warning: ignoring debug info with an invalid version (0)
; CHECK-NOT: !dbg ; CHECK-NOT: !dbg

View File

@ -7,21 +7,21 @@
; CHECK: !0 = !{} ; CHECK: !0 = !{}
!0 = !{} !0 = !{}
; CHECK-NEXT: !1 = !GenericDebugNode(tag: DW_TAG_entry_point, header: "some\00header", operands: {!0, !2, !2}) ; CHECK-NEXT: !1 = !GenericDINode(tag: DW_TAG_entry_point, header: "some\00header", operands: {!0, !2, !2})
!1 = !GenericDebugNode(tag: 3, header: "some\00header", operands: {!0, !3, !4}) !1 = !GenericDINode(tag: 3, header: "some\00header", operands: {!0, !3, !4})
!2 = !GenericDebugNode(tag: 3, header: "some\00header", operands: {!{}, !3, !4}) !2 = !GenericDINode(tag: 3, header: "some\00header", operands: {!{}, !3, !4})
; CHECK-NEXT: !2 = !GenericDebugNode(tag: DW_TAG_entry_point) ; CHECK-NEXT: !2 = !GenericDINode(tag: DW_TAG_entry_point)
!3 = !GenericDebugNode(tag: 3) !3 = !GenericDINode(tag: 3)
!4 = !GenericDebugNode(tag: 3, header: "") !4 = !GenericDINode(tag: 3, header: "")
!5 = !GenericDebugNode(tag: 3, operands: {}) !5 = !GenericDINode(tag: 3, operands: {})
!6 = !GenericDebugNode(tag: 3, header: "", operands: {}) !6 = !GenericDINode(tag: 3, header: "", operands: {})
; CHECK-NEXT: !3 = distinct !GenericDebugNode(tag: DW_TAG_entry_point) ; CHECK-NEXT: !3 = distinct !GenericDINode(tag: DW_TAG_entry_point)
!7 = distinct !GenericDebugNode(tag: 3) !7 = distinct !GenericDINode(tag: 3)
; CHECK-NEXT: !4 = !GenericDebugNode(tag: 65535) ; CHECK-NEXT: !4 = !GenericDINode(tag: 65535)
!8 = !GenericDebugNode(tag: 65535) !8 = !GenericDINode(tag: 65535)
; CHECK-NOT: ! ; CHECK-NOT: !
!9 = !GenericDebugNode(tag: DW_TAG_entry_point) !9 = !GenericDINode(tag: DW_TAG_entry_point)

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:29: error: invalid DWARF tag 'DW_TAG_badtag' ; CHECK: <stdin>:[[@LINE+1]]:26: error: invalid DWARF tag 'DW_TAG_badtag'
!0 = !GenericDebugNode(tag: DW_TAG_badtag) !0 = !GenericDINode(tag: DW_TAG_badtag)

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:47: error: missing required field 'tag' ; CHECK: <stdin>:[[@LINE+1]]:44: error: missing required field 'tag'
!0 = !GenericDebugNode(header: "some\00header") !0 = !GenericDINode(header: "some\00header")

View File

@ -1,7 +1,7 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK-NOT: error: ; CHECK-NOT: error:
!0 = !GenericDebugNode(tag: 65535) !0 = !GenericDINode(tag: 65535)
; CHECK: <stdin>:[[@LINE+1]]:29: error: value for 'tag' too large, limit is 65535 ; CHECK: <stdin>:[[@LINE+1]]:26: error: value for 'tag' too large, limit is 65535
!1 = !GenericDebugNode(tag: 65536) !1 = !GenericDINode(tag: 65536)

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:29: error: expected DWARF tag ; CHECK: <stdin>:[[@LINE+1]]:26: error: expected DWARF tag
!0 = !GenericDebugNode(tag: "string") !0 = !GenericDINode(tag: "string")

View File

@ -1,5 +1,5 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:31: error: invalid DWARF language 'DW_LANG_NoSuchLanguage' ; CHECK: <stdin>:[[@LINE+1]]:31: error: invalid DWARF language 'DW_LANG_NoSuchLanguage'
!0 = !MDCompileUnit(language: DW_LANG_NoSuchLanguage, !0 = !DICompileUnit(language: DW_LANG_NoSuchLanguage,
file: !MDFile(filename: "a", directory: "b")) file: !DIFile(filename: "a", directory: "b"))

View File

@ -1,9 +1,9 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK-NOT: error: ; CHECK-NOT: error:
!0 = !MDCompileUnit(language: 65535, !0 = !DICompileUnit(language: 65535,
file: !MDFile(filename: "a", directory: "b")) file: !DIFile(filename: "a", directory: "b"))
; CHECK: <stdin>:[[@LINE+1]]:31: error: value for 'language' too large, limit is 65535 ; CHECK: <stdin>:[[@LINE+1]]:31: error: value for 'language' too large, limit is 65535
!1 = !MDCompileUnit(language: 65536, !1 = !DICompileUnit(language: 65536,
file: !MDFile(filename: "a", directory: "b")) file: !DIFile(filename: "a", directory: "b"))

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:65: error: missing required field 'language' ; CHECK: <stdin>:[[@LINE+1]]:65: error: missing required field 'language'
!0 = !MDCompileUnit(file: !MDFile(filename: "a", directory: "b")) !0 = !DICompileUnit(file: !DIFile(filename: "a", directory: "b"))

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:27: error: 'file' cannot be null ; CHECK: <stdin>:[[@LINE+1]]:27: error: 'file' cannot be null
!0 = !MDCompileUnit(file: null) !0 = !DICompileUnit(file: null)

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: [[@LINE+1]]:36: error: missing required field 'tag' ; CHECK: [[@LINE+1]]:36: error: missing required field 'tag'
!25 = !MDCompositeType(name: "Type") !25 = !DICompositeType(name: "Type")

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: [[@LINE+1]]:45: error: missing required field 'baseType' ; CHECK: [[@LINE+1]]:45: error: missing required field 'baseType'
!0 = !MDDerivedType(tag: DW_TAG_pointer_type) !0 = !DIDerivedType(tag: DW_TAG_pointer_type)

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: [[@LINE+1]]:34: error: missing required field 'tag' ; CHECK: [[@LINE+1]]:34: error: missing required field 'tag'
!0 = !MDDerivedType(baseType: !{}) !0 = !DIDerivedType(baseType: !{})

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: [[@LINE+1]]:28: error: missing required field 'name' ; CHECK: [[@LINE+1]]:28: error: missing required field 'name'
!0 = !MDEnumerator(value: 7) !0 = !DIEnumerator(value: 7)

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: [[@LINE+1]]:32: error: missing required field 'value' ; CHECK: [[@LINE+1]]:32: error: missing required field 'value'
!0 = !MDEnumerator(name: "name") !0 = !DIEnumerator(name: "name")

View File

@ -1,7 +1,7 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK-NOT: error: ; CHECK-NOT: error:
!0 = !MDExpression(18446744073709551615) !0 = !DIExpression(18446744073709551615)
; CHECK: <stdin>:[[@LINE+1]]:20: error: element too large, limit is 18446744073709551615 ; CHECK: <stdin>:[[@LINE+1]]:20: error: element too large, limit is 18446744073709551615
!1 = !MDExpression(18446744073709551616) !1 = !DIExpression(18446744073709551616)

View File

@ -4,6 +4,6 @@
; NOVERIFY: !named = !{!0} ; NOVERIFY: !named = !{!0}
!named = !{!0} !named = !{!0}
; NOVERIFY: !0 = !MDExpression(0, 1, 9, 7, 2) ; NOVERIFY: !0 = !DIExpression(0, 1, 9, 7, 2)
; VERIFY: assembly parsed, but does not verify ; VERIFY: assembly parsed, but does not verify
!0 = !MDExpression(0, 1, 9, 7, 2) !0 = !DIExpression(0, 1, 9, 7, 2)

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: [[@LINE+1]]:30: error: missing required field 'directory' ; CHECK: [[@LINE+1]]:30: error: missing required field 'directory'
!0 = !MDFile(filename: "file") !0 = !DIFile(filename: "file")

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: [[@LINE+1]]:30: error: missing required field 'filename' ; CHECK: [[@LINE+1]]:30: error: missing required field 'filename'
!0 = !MDFile(directory: "dir") !0 = !DIFile(directory: "dir")

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:30: error: 'name' cannot be empty ; CHECK: <stdin>:[[@LINE+1]]:30: error: 'name' cannot be empty
!0 = !MDGlobalVariable(name: "") !0 = !DIGlobalVariable(name: "")

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:24: error: missing required field 'name' ; CHECK: <stdin>:[[@LINE+1]]:24: error: missing required field 'name'
!0 = !MDGlobalVariable() !0 = !DIGlobalVariable()

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: [[@LINE+1]]:51: error: missing required field 'scope' ; CHECK: [[@LINE+1]]:51: error: missing required field 'scope'
!3 = !MDImportedEntity(tag: DW_TAG_imported_module) !3 = !DIImportedEntity(tag: DW_TAG_imported_module)

View File

@ -1,4 +1,4 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: [[@LINE+1]]:33: error: missing required field 'tag' ; CHECK: [[@LINE+1]]:33: error: missing required field 'tag'
!3 = !MDImportedEntity(scope: !0) !3 = !DIImportedEntity(scope: !0)

Some files were not shown because too many files have changed in this diff Show More