1 //===- DebugInfoMetadata.cpp - Implement debug info metadata --------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements the debug info Metadata classes.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/IR/DebugInfoMetadata.h"
14 #include "LLVMContextImpl.h"
15 #include "MetadataImpl.h"
16 #include "llvm/ADT/SmallSet.h"
17 #include "llvm/ADT/StringSwitch.h"
18 #include "llvm/IR/DIBuilder.h"
19 #include "llvm/IR/Function.h"
20 #include "llvm/IR/Instructions.h"
26 DILocation::DILocation(LLVMContext
&C
, StorageType Storage
, unsigned Line
,
27 unsigned Column
, ArrayRef
<Metadata
*> MDs
,
29 : MDNode(C
, DILocationKind
, Storage
, MDs
) {
30 assert((MDs
.size() == 1 || MDs
.size() == 2) &&
31 "Expected a scope and optional inlined-at");
33 // Set line and column.
34 assert(Column
< (1u << 16) && "Expected 16-bit column");
36 SubclassData32
= Line
;
37 SubclassData16
= Column
;
39 setImplicitCode(ImplicitCode
);
42 static void adjustColumn(unsigned &Column
) {
43 // Set to unknown on overflow. We only have 16 bits to play with here.
44 if (Column
>= (1u << 16))
48 DILocation
*DILocation::getImpl(LLVMContext
&Context
, unsigned Line
,
49 unsigned Column
, Metadata
*Scope
,
50 Metadata
*InlinedAt
, bool ImplicitCode
,
51 StorageType Storage
, bool ShouldCreate
) {
55 if (Storage
== Uniqued
) {
56 if (auto *N
= getUniqued(Context
.pImpl
->DILocations
,
57 DILocationInfo::KeyTy(Line
, Column
, Scope
,
58 InlinedAt
, ImplicitCode
)))
63 assert(ShouldCreate
&& "Expected non-uniqued nodes to always be created");
66 SmallVector
<Metadata
*, 2> Ops
;
69 Ops
.push_back(InlinedAt
);
70 return storeImpl(new (Ops
.size()) DILocation(Context
, Storage
, Line
, Column
,
72 Storage
, Context
.pImpl
->DILocations
);
75 const DILocation
*DILocation::getMergedLocation(const DILocation
*LocA
,
76 const DILocation
*LocB
) {
83 SmallPtrSet
<DILocation
*, 5> InlinedLocationsA
;
84 for (DILocation
*L
= LocA
->getInlinedAt(); L
; L
= L
->getInlinedAt())
85 InlinedLocationsA
.insert(L
);
86 SmallSet
<std::pair
<DIScope
*, DILocation
*>, 5> Locations
;
87 DIScope
*S
= LocA
->getScope();
88 DILocation
*L
= LocA
->getInlinedAt();
90 Locations
.insert(std::make_pair(S
, L
));
91 S
= S
->getScope().resolve();
94 L
= L
->getInlinedAt();
97 const DILocation
*Result
= LocB
;
99 L
= LocB
->getInlinedAt();
101 if (Locations
.count(std::make_pair(S
, L
)))
103 S
= S
->getScope().resolve();
106 L
= L
->getInlinedAt();
110 // If the two locations are irreconsilable, just pick one. This is misleading,
111 // but on the other hand, it's a "line 0" location.
112 if (!S
|| !isa
<DILocalScope
>(S
))
113 S
= LocA
->getScope();
114 return DILocation::get(Result
->getContext(), 0, 0, S
, L
);
117 Optional
<unsigned> DILocation::encodeDiscriminator(unsigned BD
, unsigned DF
, unsigned CI
) {
118 SmallVector
<unsigned, 3> Components
= {BD
, DF
, CI
};
119 uint64_t RemainingWork
= 0U;
120 // We use RemainingWork to figure out if we have no remaining components to
121 // encode. For example: if BD != 0 but DF == 0 && CI == 0, we don't need to
122 // encode anything for the latter 2.
123 // Since any of the input components is at most 32 bits, their sum will be
124 // less than 34 bits, and thus RemainingWork won't overflow.
125 RemainingWork
= std::accumulate(Components
.begin(), Components
.end(), RemainingWork
);
129 unsigned NextBitInsertionIndex
= 0;
130 while (RemainingWork
> 0) {
131 unsigned C
= Components
[I
++];
133 unsigned EC
= encodeComponent(C
);
134 Ret
|= (EC
<< NextBitInsertionIndex
);
135 NextBitInsertionIndex
+= encodingBits(C
);
138 // Encoding may be unsuccessful because of overflow. We determine success by
139 // checking equivalence of components before & after encoding. Alternatively,
140 // we could determine Success during encoding, but the current alternative is
142 unsigned TBD
, TDF
, TCI
= 0;
143 decodeDiscriminator(Ret
, TBD
, TDF
, TCI
);
144 if (TBD
== BD
&& TDF
== DF
&& TCI
== CI
)
149 void DILocation::decodeDiscriminator(unsigned D
, unsigned &BD
, unsigned &DF
,
151 BD
= getUnsignedFromPrefixEncoding(D
);
152 DF
= getUnsignedFromPrefixEncoding(getNextComponentInDiscriminator(D
));
153 CI
= getUnsignedFromPrefixEncoding(
154 getNextComponentInDiscriminator(getNextComponentInDiscriminator(D
)));
158 DINode::DIFlags
DINode::getFlag(StringRef Flag
) {
159 return StringSwitch
<DIFlags
>(Flag
)
160 #define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
161 #include "llvm/IR/DebugInfoFlags.def"
162 .Default(DINode::FlagZero
);
165 StringRef
DINode::getFlagString(DIFlags Flag
) {
167 #define HANDLE_DI_FLAG(ID, NAME) \
169 return "DIFlag" #NAME;
170 #include "llvm/IR/DebugInfoFlags.def"
175 DINode::DIFlags
DINode::splitFlags(DIFlags Flags
,
176 SmallVectorImpl
<DIFlags
> &SplitFlags
) {
177 // Flags that are packed together need to be specially handled, so
178 // that, for example, we emit "DIFlagPublic" and not
179 // "DIFlagPrivate | DIFlagProtected".
180 if (DIFlags A
= Flags
& FlagAccessibility
) {
181 if (A
== FlagPrivate
)
182 SplitFlags
.push_back(FlagPrivate
);
183 else if (A
== FlagProtected
)
184 SplitFlags
.push_back(FlagProtected
);
186 SplitFlags
.push_back(FlagPublic
);
189 if (DIFlags R
= Flags
& FlagPtrToMemberRep
) {
190 if (R
== FlagSingleInheritance
)
191 SplitFlags
.push_back(FlagSingleInheritance
);
192 else if (R
== FlagMultipleInheritance
)
193 SplitFlags
.push_back(FlagMultipleInheritance
);
195 SplitFlags
.push_back(FlagVirtualInheritance
);
198 if ((Flags
& FlagIndirectVirtualBase
) == FlagIndirectVirtualBase
) {
199 Flags
&= ~FlagIndirectVirtualBase
;
200 SplitFlags
.push_back(FlagIndirectVirtualBase
);
203 #define HANDLE_DI_FLAG(ID, NAME) \
204 if (DIFlags Bit = Flags & Flag##NAME) { \
205 SplitFlags.push_back(Bit); \
208 #include "llvm/IR/DebugInfoFlags.def"
212 DIScopeRef
DIScope::getScope() const {
213 if (auto *T
= dyn_cast
<DIType
>(this))
214 return T
->getScope();
216 if (auto *SP
= dyn_cast
<DISubprogram
>(this))
217 return SP
->getScope();
219 if (auto *LB
= dyn_cast
<DILexicalBlockBase
>(this))
220 return LB
->getScope();
222 if (auto *NS
= dyn_cast
<DINamespace
>(this))
223 return NS
->getScope();
225 if (auto *M
= dyn_cast
<DIModule
>(this))
226 return M
->getScope();
228 assert((isa
<DIFile
>(this) || isa
<DICompileUnit
>(this)) &&
229 "Unhandled type of scope.");
233 StringRef
DIScope::getName() const {
234 if (auto *T
= dyn_cast
<DIType
>(this))
236 if (auto *SP
= dyn_cast
<DISubprogram
>(this))
237 return SP
->getName();
238 if (auto *NS
= dyn_cast
<DINamespace
>(this))
239 return NS
->getName();
240 if (auto *M
= dyn_cast
<DIModule
>(this))
242 assert((isa
<DILexicalBlockBase
>(this) || isa
<DIFile
>(this) ||
243 isa
<DICompileUnit
>(this)) &&
244 "Unhandled type of scope.");
249 static bool isCanonical(const MDString
*S
) {
250 return !S
|| !S
->getString().empty();
254 GenericDINode
*GenericDINode::getImpl(LLVMContext
&Context
, unsigned Tag
,
256 ArrayRef
<Metadata
*> DwarfOps
,
257 StorageType Storage
, bool ShouldCreate
) {
259 if (Storage
== Uniqued
) {
260 GenericDINodeInfo::KeyTy
Key(Tag
, Header
, DwarfOps
);
261 if (auto *N
= getUniqued(Context
.pImpl
->GenericDINodes
, Key
))
265 Hash
= Key
.getHash();
267 assert(ShouldCreate
&& "Expected non-uniqued nodes to always be created");
270 // Use a nullptr for empty headers.
271 assert(isCanonical(Header
) && "Expected canonical MDString");
272 Metadata
*PreOps
[] = {Header
};
273 return storeImpl(new (DwarfOps
.size() + 1) GenericDINode(
274 Context
, Storage
, Hash
, Tag
, PreOps
, DwarfOps
),
275 Storage
, Context
.pImpl
->GenericDINodes
);
278 void GenericDINode::recalculateHash() {
279 setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
282 #define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
283 #define UNWRAP_ARGS(ARGS) UNWRAP_ARGS_IMPL ARGS
284 #define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS) \
286 if (Storage == Uniqued) { \
287 if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
288 CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)))) \
293 assert(ShouldCreate && \
294 "Expected non-uniqued nodes to always be created"); \
297 #define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS) \
298 return storeImpl(new (array_lengthof(OPS)) \
299 CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
300 Storage, Context.pImpl->CLASS##s)
301 #define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS) \
302 return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)), \
303 Storage, Context.pImpl->CLASS##s)
304 #define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS) \
305 return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage, OPS), \
306 Storage, Context.pImpl->CLASS##s)
307 #define DEFINE_GETIMPL_STORE_N(CLASS, ARGS, OPS, NUM_OPS) \
308 return storeImpl(new (NUM_OPS) \
309 CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
310 Storage, Context.pImpl->CLASS##s)
312 DISubrange
*DISubrange::getImpl(LLVMContext
&Context
, int64_t Count
, int64_t Lo
,
313 StorageType Storage
, bool ShouldCreate
) {
314 auto *CountNode
= ConstantAsMetadata::get(
315 ConstantInt::getSigned(Type::getInt64Ty(Context
), Count
));
316 return getImpl(Context
, CountNode
, Lo
, Storage
, ShouldCreate
);
319 DISubrange
*DISubrange::getImpl(LLVMContext
&Context
, Metadata
*CountNode
,
320 int64_t Lo
, StorageType Storage
,
322 DEFINE_GETIMPL_LOOKUP(DISubrange
, (CountNode
, Lo
));
323 Metadata
*Ops
[] = { CountNode
};
324 DEFINE_GETIMPL_STORE(DISubrange
, (CountNode
, Lo
), Ops
);
327 DIEnumerator
*DIEnumerator::getImpl(LLVMContext
&Context
, int64_t Value
,
328 bool IsUnsigned
, MDString
*Name
,
329 StorageType Storage
, bool ShouldCreate
) {
330 assert(isCanonical(Name
) && "Expected canonical MDString");
331 DEFINE_GETIMPL_LOOKUP(DIEnumerator
, (Value
, IsUnsigned
, Name
));
332 Metadata
*Ops
[] = {Name
};
333 DEFINE_GETIMPL_STORE(DIEnumerator
, (Value
, IsUnsigned
), Ops
);
336 DIBasicType
*DIBasicType::getImpl(LLVMContext
&Context
, unsigned Tag
,
337 MDString
*Name
, uint64_t SizeInBits
,
338 uint32_t AlignInBits
, unsigned Encoding
,
339 DIFlags Flags
, StorageType Storage
,
341 assert(isCanonical(Name
) && "Expected canonical MDString");
342 DEFINE_GETIMPL_LOOKUP(DIBasicType
,
343 (Tag
, Name
, SizeInBits
, AlignInBits
, Encoding
, Flags
));
344 Metadata
*Ops
[] = {nullptr, nullptr, Name
};
345 DEFINE_GETIMPL_STORE(DIBasicType
, (Tag
, SizeInBits
, AlignInBits
, Encoding
,
349 Optional
<DIBasicType::Signedness
> DIBasicType::getSignedness() const {
350 switch (getEncoding()) {
351 case dwarf::DW_ATE_signed
:
352 case dwarf::DW_ATE_signed_char
:
353 return Signedness::Signed
;
354 case dwarf::DW_ATE_unsigned
:
355 case dwarf::DW_ATE_unsigned_char
:
356 return Signedness::Unsigned
;
362 DIDerivedType
*DIDerivedType::getImpl(
363 LLVMContext
&Context
, unsigned Tag
, MDString
*Name
, Metadata
*File
,
364 unsigned Line
, Metadata
*Scope
, Metadata
*BaseType
, uint64_t SizeInBits
,
365 uint32_t AlignInBits
, uint64_t OffsetInBits
,
366 Optional
<unsigned> DWARFAddressSpace
, DIFlags Flags
, Metadata
*ExtraData
,
367 StorageType Storage
, bool ShouldCreate
) {
368 assert(isCanonical(Name
) && "Expected canonical MDString");
369 DEFINE_GETIMPL_LOOKUP(DIDerivedType
,
370 (Tag
, Name
, File
, Line
, Scope
, BaseType
, SizeInBits
,
371 AlignInBits
, OffsetInBits
, DWARFAddressSpace
, Flags
,
373 Metadata
*Ops
[] = {File
, Scope
, Name
, BaseType
, ExtraData
};
374 DEFINE_GETIMPL_STORE(
375 DIDerivedType
, (Tag
, Line
, SizeInBits
, AlignInBits
, OffsetInBits
,
376 DWARFAddressSpace
, Flags
), Ops
);
379 DICompositeType
*DICompositeType::getImpl(
380 LLVMContext
&Context
, unsigned Tag
, MDString
*Name
, Metadata
*File
,
381 unsigned Line
, Metadata
*Scope
, Metadata
*BaseType
, uint64_t SizeInBits
,
382 uint32_t AlignInBits
, uint64_t OffsetInBits
, DIFlags Flags
,
383 Metadata
*Elements
, unsigned RuntimeLang
, Metadata
*VTableHolder
,
384 Metadata
*TemplateParams
, MDString
*Identifier
, Metadata
*Discriminator
,
385 StorageType Storage
, bool ShouldCreate
) {
386 assert(isCanonical(Name
) && "Expected canonical MDString");
388 // Keep this in sync with buildODRType.
389 DEFINE_GETIMPL_LOOKUP(
390 DICompositeType
, (Tag
, Name
, File
, Line
, Scope
, BaseType
, SizeInBits
,
391 AlignInBits
, OffsetInBits
, Flags
, Elements
, RuntimeLang
,
392 VTableHolder
, TemplateParams
, Identifier
, Discriminator
));
393 Metadata
*Ops
[] = {File
, Scope
, Name
, BaseType
,
394 Elements
, VTableHolder
, TemplateParams
, Identifier
,
396 DEFINE_GETIMPL_STORE(DICompositeType
, (Tag
, Line
, RuntimeLang
, SizeInBits
,
397 AlignInBits
, OffsetInBits
, Flags
),
401 DICompositeType
*DICompositeType::buildODRType(
402 LLVMContext
&Context
, MDString
&Identifier
, unsigned Tag
, MDString
*Name
,
403 Metadata
*File
, unsigned Line
, Metadata
*Scope
, Metadata
*BaseType
,
404 uint64_t SizeInBits
, uint32_t AlignInBits
, uint64_t OffsetInBits
,
405 DIFlags Flags
, Metadata
*Elements
, unsigned RuntimeLang
,
406 Metadata
*VTableHolder
, Metadata
*TemplateParams
, Metadata
*Discriminator
) {
407 assert(!Identifier
.getString().empty() && "Expected valid identifier");
408 if (!Context
.isODRUniquingDebugTypes())
410 auto *&CT
= (*Context
.pImpl
->DITypeMap
)[&Identifier
];
412 return CT
= DICompositeType::getDistinct(
413 Context
, Tag
, Name
, File
, Line
, Scope
, BaseType
, SizeInBits
,
414 AlignInBits
, OffsetInBits
, Flags
, Elements
, RuntimeLang
,
415 VTableHolder
, TemplateParams
, &Identifier
, Discriminator
);
417 // Only mutate CT if it's a forward declaration and the new operands aren't.
418 assert(CT
->getRawIdentifier() == &Identifier
&& "Wrong ODR identifier?");
419 if (!CT
->isForwardDecl() || (Flags
& DINode::FlagFwdDecl
))
422 // Mutate CT in place. Keep this in sync with getImpl.
423 CT
->mutate(Tag
, Line
, RuntimeLang
, SizeInBits
, AlignInBits
, OffsetInBits
,
425 Metadata
*Ops
[] = {File
, Scope
, Name
, BaseType
,
426 Elements
, VTableHolder
, TemplateParams
, &Identifier
,
428 assert((std::end(Ops
) - std::begin(Ops
)) == (int)CT
->getNumOperands() &&
429 "Mismatched number of operands");
430 for (unsigned I
= 0, E
= CT
->getNumOperands(); I
!= E
; ++I
)
431 if (Ops
[I
] != CT
->getOperand(I
))
432 CT
->setOperand(I
, Ops
[I
]);
436 DICompositeType
*DICompositeType::getODRType(
437 LLVMContext
&Context
, MDString
&Identifier
, unsigned Tag
, MDString
*Name
,
438 Metadata
*File
, unsigned Line
, Metadata
*Scope
, Metadata
*BaseType
,
439 uint64_t SizeInBits
, uint32_t AlignInBits
, uint64_t OffsetInBits
,
440 DIFlags Flags
, Metadata
*Elements
, unsigned RuntimeLang
,
441 Metadata
*VTableHolder
, Metadata
*TemplateParams
, Metadata
*Discriminator
) {
442 assert(!Identifier
.getString().empty() && "Expected valid identifier");
443 if (!Context
.isODRUniquingDebugTypes())
445 auto *&CT
= (*Context
.pImpl
->DITypeMap
)[&Identifier
];
447 CT
= DICompositeType::getDistinct(
448 Context
, Tag
, Name
, File
, Line
, Scope
, BaseType
, SizeInBits
,
449 AlignInBits
, OffsetInBits
, Flags
, Elements
, RuntimeLang
, VTableHolder
,
450 TemplateParams
, &Identifier
, Discriminator
);
454 DICompositeType
*DICompositeType::getODRTypeIfExists(LLVMContext
&Context
,
455 MDString
&Identifier
) {
456 assert(!Identifier
.getString().empty() && "Expected valid identifier");
457 if (!Context
.isODRUniquingDebugTypes())
459 return Context
.pImpl
->DITypeMap
->lookup(&Identifier
);
462 DISubroutineType
*DISubroutineType::getImpl(LLVMContext
&Context
, DIFlags Flags
,
463 uint8_t CC
, Metadata
*TypeArray
,
466 DEFINE_GETIMPL_LOOKUP(DISubroutineType
, (Flags
, CC
, TypeArray
));
467 Metadata
*Ops
[] = {nullptr, nullptr, nullptr, TypeArray
};
468 DEFINE_GETIMPL_STORE(DISubroutineType
, (Flags
, CC
), Ops
);
471 // FIXME: Implement this string-enum correspondence with a .def file and macros,
472 // so that the association is explicit rather than implied.
473 static const char *ChecksumKindName
[DIFile::CSK_Last
] = {
478 StringRef
DIFile::getChecksumKindAsString(ChecksumKind CSKind
) {
479 assert(CSKind
<= DIFile::CSK_Last
&& "Invalid checksum kind");
480 // The first space was originally the CSK_None variant, which is now
481 // obsolete, but the space is still reserved in ChecksumKind, so we account
483 return ChecksumKindName
[CSKind
- 1];
486 Optional
<DIFile::ChecksumKind
> DIFile::getChecksumKind(StringRef CSKindStr
) {
487 return StringSwitch
<Optional
<DIFile::ChecksumKind
>>(CSKindStr
)
488 .Case("CSK_MD5", DIFile::CSK_MD5
)
489 .Case("CSK_SHA1", DIFile::CSK_SHA1
)
493 DIFile
*DIFile::getImpl(LLVMContext
&Context
, MDString
*Filename
,
495 Optional
<DIFile::ChecksumInfo
<MDString
*>> CS
,
496 Optional
<MDString
*> Source
, StorageType Storage
,
498 assert(isCanonical(Filename
) && "Expected canonical MDString");
499 assert(isCanonical(Directory
) && "Expected canonical MDString");
500 assert((!CS
|| isCanonical(CS
->Value
)) && "Expected canonical MDString");
501 assert((!Source
|| isCanonical(*Source
)) && "Expected canonical MDString");
502 DEFINE_GETIMPL_LOOKUP(DIFile
, (Filename
, Directory
, CS
, Source
));
503 Metadata
*Ops
[] = {Filename
, Directory
, CS
? CS
->Value
: nullptr,
504 Source
.getValueOr(nullptr)};
505 DEFINE_GETIMPL_STORE(DIFile
, (CS
, Source
), Ops
);
508 DICompileUnit
*DICompileUnit::getImpl(
509 LLVMContext
&Context
, unsigned SourceLanguage
, Metadata
*File
,
510 MDString
*Producer
, bool IsOptimized
, MDString
*Flags
,
511 unsigned RuntimeVersion
, MDString
*SplitDebugFilename
,
512 unsigned EmissionKind
, Metadata
*EnumTypes
, Metadata
*RetainedTypes
,
513 Metadata
*GlobalVariables
, Metadata
*ImportedEntities
, Metadata
*Macros
,
514 uint64_t DWOId
, bool SplitDebugInlining
, bool DebugInfoForProfiling
,
515 unsigned NameTableKind
, bool RangesBaseAddress
, StorageType Storage
,
517 assert(Storage
!= Uniqued
&& "Cannot unique DICompileUnit");
518 assert(isCanonical(Producer
) && "Expected canonical MDString");
519 assert(isCanonical(Flags
) && "Expected canonical MDString");
520 assert(isCanonical(SplitDebugFilename
) && "Expected canonical MDString");
523 File
, Producer
, Flags
, SplitDebugFilename
,
524 EnumTypes
, RetainedTypes
, GlobalVariables
, ImportedEntities
,
526 return storeImpl(new (array_lengthof(Ops
)) DICompileUnit(
527 Context
, Storage
, SourceLanguage
, IsOptimized
,
528 RuntimeVersion
, EmissionKind
, DWOId
, SplitDebugInlining
,
529 DebugInfoForProfiling
, NameTableKind
, RangesBaseAddress
,
534 Optional
<DICompileUnit::DebugEmissionKind
>
535 DICompileUnit::getEmissionKind(StringRef Str
) {
536 return StringSwitch
<Optional
<DebugEmissionKind
>>(Str
)
537 .Case("NoDebug", NoDebug
)
538 .Case("FullDebug", FullDebug
)
539 .Case("LineTablesOnly", LineTablesOnly
)
540 .Case("DebugDirectivesOnly", DebugDirectivesOnly
)
544 Optional
<DICompileUnit::DebugNameTableKind
>
545 DICompileUnit::getNameTableKind(StringRef Str
) {
546 return StringSwitch
<Optional
<DebugNameTableKind
>>(Str
)
547 .Case("Default", DebugNameTableKind::Default
)
548 .Case("GNU", DebugNameTableKind::GNU
)
549 .Case("None", DebugNameTableKind::None
)
553 const char *DICompileUnit::emissionKindString(DebugEmissionKind EK
) {
555 case NoDebug
: return "NoDebug";
556 case FullDebug
: return "FullDebug";
557 case LineTablesOnly
: return "LineTablesOnly";
558 case DebugDirectivesOnly
: return "DebugDirectivesOnly";
563 const char *DICompileUnit::nameTableKindString(DebugNameTableKind NTK
) {
565 case DebugNameTableKind::Default
:
567 case DebugNameTableKind::GNU
:
569 case DebugNameTableKind::None
:
575 DISubprogram
*DILocalScope::getSubprogram() const {
576 if (auto *Block
= dyn_cast
<DILexicalBlockBase
>(this))
577 return Block
->getScope()->getSubprogram();
578 return const_cast<DISubprogram
*>(cast
<DISubprogram
>(this));
581 DILocalScope
*DILocalScope::getNonLexicalBlockFileScope() const {
582 if (auto *File
= dyn_cast
<DILexicalBlockFile
>(this))
583 return File
->getScope()->getNonLexicalBlockFileScope();
584 return const_cast<DILocalScope
*>(this);
587 DISubprogram::DISPFlags
DISubprogram::getFlag(StringRef Flag
) {
588 return StringSwitch
<DISPFlags
>(Flag
)
589 #define HANDLE_DISP_FLAG(ID, NAME) .Case("DISPFlag" #NAME, SPFlag##NAME)
590 #include "llvm/IR/DebugInfoFlags.def"
591 .Default(SPFlagZero
);
594 StringRef
DISubprogram::getFlagString(DISPFlags Flag
) {
596 // Appease a warning.
597 case SPFlagVirtuality
:
599 #define HANDLE_DISP_FLAG(ID, NAME) \
601 return "DISPFlag" #NAME;
602 #include "llvm/IR/DebugInfoFlags.def"
607 DISubprogram::DISPFlags
608 DISubprogram::splitFlags(DISPFlags Flags
,
609 SmallVectorImpl
<DISPFlags
> &SplitFlags
) {
610 // Multi-bit fields can require special handling. In our case, however, the
611 // only multi-bit field is virtuality, and all its values happen to be
612 // single-bit values, so the right behavior just falls out.
613 #define HANDLE_DISP_FLAG(ID, NAME) \
614 if (DISPFlags Bit = Flags & SPFlag##NAME) { \
615 SplitFlags.push_back(Bit); \
618 #include "llvm/IR/DebugInfoFlags.def"
622 DISubprogram
*DISubprogram::getImpl(
623 LLVMContext
&Context
, Metadata
*Scope
, MDString
*Name
,
624 MDString
*LinkageName
, Metadata
*File
, unsigned Line
, Metadata
*Type
,
625 unsigned ScopeLine
, Metadata
*ContainingType
, unsigned VirtualIndex
,
626 int ThisAdjustment
, DIFlags Flags
, DISPFlags SPFlags
, Metadata
*Unit
,
627 Metadata
*TemplateParams
, Metadata
*Declaration
, Metadata
*RetainedNodes
,
628 Metadata
*ThrownTypes
, StorageType Storage
, bool ShouldCreate
) {
629 assert(isCanonical(Name
) && "Expected canonical MDString");
630 assert(isCanonical(LinkageName
) && "Expected canonical MDString");
631 DEFINE_GETIMPL_LOOKUP(DISubprogram
,
632 (Scope
, Name
, LinkageName
, File
, Line
, Type
, ScopeLine
,
633 ContainingType
, VirtualIndex
, ThisAdjustment
, Flags
,
634 SPFlags
, Unit
, TemplateParams
, Declaration
,
635 RetainedNodes
, ThrownTypes
));
636 SmallVector
<Metadata
*, 11> Ops
= {
637 File
, Scope
, Name
, LinkageName
, Type
, Unit
,
638 Declaration
, RetainedNodes
, ContainingType
, TemplateParams
, ThrownTypes
};
641 if (!TemplateParams
) {
647 DEFINE_GETIMPL_STORE_N(
649 (Line
, ScopeLine
, VirtualIndex
, ThisAdjustment
, Flags
, SPFlags
), Ops
,
653 bool DISubprogram::describes(const Function
*F
) const {
654 assert(F
&& "Invalid function");
655 if (F
->getSubprogram() == this)
657 StringRef Name
= getLinkageName();
660 return F
->getName() == Name
;
663 DILexicalBlock
*DILexicalBlock::getImpl(LLVMContext
&Context
, Metadata
*Scope
,
664 Metadata
*File
, unsigned Line
,
665 unsigned Column
, StorageType Storage
,
668 adjustColumn(Column
);
670 assert(Scope
&& "Expected scope");
671 DEFINE_GETIMPL_LOOKUP(DILexicalBlock
, (Scope
, File
, Line
, Column
));
672 Metadata
*Ops
[] = {File
, Scope
};
673 DEFINE_GETIMPL_STORE(DILexicalBlock
, (Line
, Column
), Ops
);
676 DILexicalBlockFile
*DILexicalBlockFile::getImpl(LLVMContext
&Context
,
677 Metadata
*Scope
, Metadata
*File
,
678 unsigned Discriminator
,
681 assert(Scope
&& "Expected scope");
682 DEFINE_GETIMPL_LOOKUP(DILexicalBlockFile
, (Scope
, File
, Discriminator
));
683 Metadata
*Ops
[] = {File
, Scope
};
684 DEFINE_GETIMPL_STORE(DILexicalBlockFile
, (Discriminator
), Ops
);
687 DINamespace
*DINamespace::getImpl(LLVMContext
&Context
, Metadata
*Scope
,
688 MDString
*Name
, bool ExportSymbols
,
689 StorageType Storage
, bool ShouldCreate
) {
690 assert(isCanonical(Name
) && "Expected canonical MDString");
691 DEFINE_GETIMPL_LOOKUP(DINamespace
, (Scope
, Name
, ExportSymbols
));
692 // The nullptr is for DIScope's File operand. This should be refactored.
693 Metadata
*Ops
[] = {nullptr, Scope
, Name
};
694 DEFINE_GETIMPL_STORE(DINamespace
, (ExportSymbols
), Ops
);
697 DIModule
*DIModule::getImpl(LLVMContext
&Context
, Metadata
*Scope
,
698 MDString
*Name
, MDString
*ConfigurationMacros
,
699 MDString
*IncludePath
, MDString
*ISysRoot
,
700 StorageType Storage
, bool ShouldCreate
) {
701 assert(isCanonical(Name
) && "Expected canonical MDString");
702 DEFINE_GETIMPL_LOOKUP(
703 DIModule
, (Scope
, Name
, ConfigurationMacros
, IncludePath
, ISysRoot
));
704 Metadata
*Ops
[] = {Scope
, Name
, ConfigurationMacros
, IncludePath
, ISysRoot
};
705 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIModule
, Ops
);
708 DITemplateTypeParameter
*DITemplateTypeParameter::getImpl(LLVMContext
&Context
,
713 assert(isCanonical(Name
) && "Expected canonical MDString");
714 DEFINE_GETIMPL_LOOKUP(DITemplateTypeParameter
, (Name
, Type
));
715 Metadata
*Ops
[] = {Name
, Type
};
716 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DITemplateTypeParameter
, Ops
);
719 DITemplateValueParameter
*DITemplateValueParameter::getImpl(
720 LLVMContext
&Context
, unsigned Tag
, MDString
*Name
, Metadata
*Type
,
721 Metadata
*Value
, StorageType Storage
, bool ShouldCreate
) {
722 assert(isCanonical(Name
) && "Expected canonical MDString");
723 DEFINE_GETIMPL_LOOKUP(DITemplateValueParameter
, (Tag
, Name
, Type
, Value
));
724 Metadata
*Ops
[] = {Name
, Type
, Value
};
725 DEFINE_GETIMPL_STORE(DITemplateValueParameter
, (Tag
), Ops
);
729 DIGlobalVariable::getImpl(LLVMContext
&Context
, Metadata
*Scope
, MDString
*Name
,
730 MDString
*LinkageName
, Metadata
*File
, unsigned Line
,
731 Metadata
*Type
, bool IsLocalToUnit
, bool IsDefinition
,
732 Metadata
*StaticDataMemberDeclaration
,
733 Metadata
*TemplateParams
, uint32_t AlignInBits
,
734 StorageType Storage
, bool ShouldCreate
) {
735 assert(isCanonical(Name
) && "Expected canonical MDString");
736 assert(isCanonical(LinkageName
) && "Expected canonical MDString");
737 DEFINE_GETIMPL_LOOKUP(DIGlobalVariable
, (Scope
, Name
, LinkageName
, File
, Line
,
738 Type
, IsLocalToUnit
, IsDefinition
,
739 StaticDataMemberDeclaration
,
740 TemplateParams
, AlignInBits
));
741 Metadata
*Ops
[] = {Scope
,
747 StaticDataMemberDeclaration
,
749 DEFINE_GETIMPL_STORE(DIGlobalVariable
,
750 (Line
, IsLocalToUnit
, IsDefinition
, AlignInBits
), Ops
);
753 DILocalVariable
*DILocalVariable::getImpl(LLVMContext
&Context
, Metadata
*Scope
,
754 MDString
*Name
, Metadata
*File
,
755 unsigned Line
, Metadata
*Type
,
756 unsigned Arg
, DIFlags Flags
,
757 uint32_t AlignInBits
,
760 // 64K ought to be enough for any frontend.
761 assert(Arg
<= UINT16_MAX
&& "Expected argument number to fit in 16-bits");
763 assert(Scope
&& "Expected scope");
764 assert(isCanonical(Name
) && "Expected canonical MDString");
765 DEFINE_GETIMPL_LOOKUP(DILocalVariable
,
766 (Scope
, Name
, File
, Line
, Type
, Arg
, Flags
,
768 Metadata
*Ops
[] = {Scope
, Name
, File
, Type
};
769 DEFINE_GETIMPL_STORE(DILocalVariable
, (Line
, Arg
, Flags
, AlignInBits
), Ops
);
772 Optional
<uint64_t> DIVariable::getSizeInBits() const {
773 // This is used by the Verifier so be mindful of broken types.
774 const Metadata
*RawType
= getRawType();
776 // Try to get the size directly.
777 if (auto *T
= dyn_cast
<DIType
>(RawType
))
778 if (uint64_t Size
= T
->getSizeInBits())
781 if (auto *DT
= dyn_cast
<DIDerivedType
>(RawType
)) {
782 // Look at the base type.
783 RawType
= DT
->getRawBaseType();
787 // Missing type or size.
795 DILabel
*DILabel::getImpl(LLVMContext
&Context
, Metadata
*Scope
,
796 MDString
*Name
, Metadata
*File
, unsigned Line
,
799 assert(Scope
&& "Expected scope");
800 assert(isCanonical(Name
) && "Expected canonical MDString");
801 DEFINE_GETIMPL_LOOKUP(DILabel
,
802 (Scope
, Name
, File
, Line
));
803 Metadata
*Ops
[] = {Scope
, Name
, File
};
804 DEFINE_GETIMPL_STORE(DILabel
, (Line
), Ops
);
807 DIExpression
*DIExpression::getImpl(LLVMContext
&Context
,
808 ArrayRef
<uint64_t> Elements
,
809 StorageType Storage
, bool ShouldCreate
) {
810 DEFINE_GETIMPL_LOOKUP(DIExpression
, (Elements
));
811 DEFINE_GETIMPL_STORE_NO_OPS(DIExpression
, (Elements
));
814 unsigned DIExpression::ExprOperand::getSize() const {
816 case dwarf::DW_OP_LLVM_fragment
:
818 case dwarf::DW_OP_constu
:
819 case dwarf::DW_OP_plus_uconst
:
826 bool DIExpression::isValid() const {
827 for (auto I
= expr_op_begin(), E
= expr_op_end(); I
!= E
; ++I
) {
828 // Check that there's space for the operand.
829 if (I
->get() + I
->getSize() > E
->get())
832 // Check that the operand is valid.
833 switch (I
->getOp()) {
836 case dwarf::DW_OP_LLVM_fragment
:
837 // A fragment operator must appear at the end.
838 return I
->get() + I
->getSize() == E
->get();
839 case dwarf::DW_OP_stack_value
: {
840 // Must be the last one or followed by a DW_OP_LLVM_fragment.
841 if (I
->get() + I
->getSize() == E
->get())
844 if ((++J
)->getOp() != dwarf::DW_OP_LLVM_fragment
)
848 case dwarf::DW_OP_swap
: {
849 // Must be more than one implicit element on the stack.
851 // FIXME: A better way to implement this would be to add a local variable
852 // that keeps track of the stack depth and introduce something like a
853 // DW_LLVM_OP_implicit_location as a placeholder for the location this
854 // DIExpression is attached to, or else pass the number of implicit stack
855 // elements into isValid.
856 if (getNumElements() == 1)
860 case dwarf::DW_OP_constu
:
861 case dwarf::DW_OP_plus_uconst
:
862 case dwarf::DW_OP_plus
:
863 case dwarf::DW_OP_minus
:
864 case dwarf::DW_OP_mul
:
865 case dwarf::DW_OP_div
:
866 case dwarf::DW_OP_mod
:
867 case dwarf::DW_OP_or
:
868 case dwarf::DW_OP_and
:
869 case dwarf::DW_OP_xor
:
870 case dwarf::DW_OP_shl
:
871 case dwarf::DW_OP_shr
:
872 case dwarf::DW_OP_shra
:
873 case dwarf::DW_OP_deref
:
874 case dwarf::DW_OP_xderef
:
875 case dwarf::DW_OP_lit0
:
876 case dwarf::DW_OP_not
:
877 case dwarf::DW_OP_dup
:
884 Optional
<DIExpression::FragmentInfo
>
885 DIExpression::getFragmentInfo(expr_op_iterator Start
, expr_op_iterator End
) {
886 for (auto I
= Start
; I
!= End
; ++I
)
887 if (I
->getOp() == dwarf::DW_OP_LLVM_fragment
) {
888 DIExpression::FragmentInfo Info
= {I
->getArg(1), I
->getArg(0)};
894 void DIExpression::appendOffset(SmallVectorImpl
<uint64_t> &Ops
,
897 Ops
.push_back(dwarf::DW_OP_plus_uconst
);
898 Ops
.push_back(Offset
);
899 } else if (Offset
< 0) {
900 Ops
.push_back(dwarf::DW_OP_constu
);
901 Ops
.push_back(-Offset
);
902 Ops
.push_back(dwarf::DW_OP_minus
);
906 bool DIExpression::extractIfOffset(int64_t &Offset
) const {
907 if (getNumElements() == 0) {
912 if (getNumElements() == 2 && Elements
[0] == dwarf::DW_OP_plus_uconst
) {
913 Offset
= Elements
[1];
917 if (getNumElements() == 3 && Elements
[0] == dwarf::DW_OP_constu
) {
918 if (Elements
[2] == dwarf::DW_OP_plus
) {
919 Offset
= Elements
[1];
922 if (Elements
[2] == dwarf::DW_OP_minus
) {
923 Offset
= -Elements
[1];
931 const DIExpression
*DIExpression::extractAddressClass(const DIExpression
*Expr
,
932 unsigned &AddrClass
) {
933 const unsigned PatternSize
= 4;
934 if (Expr
->Elements
.size() >= PatternSize
&&
935 Expr
->Elements
[PatternSize
- 4] == dwarf::DW_OP_constu
&&
936 Expr
->Elements
[PatternSize
- 2] == dwarf::DW_OP_swap
&&
937 Expr
->Elements
[PatternSize
- 1] == dwarf::DW_OP_xderef
) {
938 AddrClass
= Expr
->Elements
[PatternSize
- 3];
940 if (Expr
->Elements
.size() == PatternSize
)
942 return DIExpression::get(Expr
->getContext(),
943 makeArrayRef(&*Expr
->Elements
.begin(),
944 Expr
->Elements
.size() - PatternSize
));
949 DIExpression
*DIExpression::prepend(const DIExpression
*Expr
, bool DerefBefore
,
950 int64_t Offset
, bool DerefAfter
,
952 SmallVector
<uint64_t, 8> Ops
;
954 Ops
.push_back(dwarf::DW_OP_deref
);
956 appendOffset(Ops
, Offset
);
958 Ops
.push_back(dwarf::DW_OP_deref
);
960 return prependOpcodes(Expr
, Ops
, StackValue
);
963 DIExpression
*DIExpression::prependOpcodes(const DIExpression
*Expr
,
964 SmallVectorImpl
<uint64_t> &Ops
,
966 assert(Expr
&& "Can't prepend ops to this expression");
968 // If there are no ops to prepend, do not even add the DW_OP_stack_value.
971 for (auto Op
: Expr
->expr_ops()) {
972 // A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment.
974 if (Op
.getOp() == dwarf::DW_OP_stack_value
)
976 else if (Op
.getOp() == dwarf::DW_OP_LLVM_fragment
) {
977 Ops
.push_back(dwarf::DW_OP_stack_value
);
981 Op
.appendToVector(Ops
);
984 Ops
.push_back(dwarf::DW_OP_stack_value
);
985 return DIExpression::get(Expr
->getContext(), Ops
);
988 DIExpression
*DIExpression::append(const DIExpression
*Expr
,
989 ArrayRef
<uint64_t> Ops
) {
990 assert(Expr
&& !Ops
.empty() && "Can't append ops to this expression");
992 // Copy Expr's current op list.
993 SmallVector
<uint64_t, 16> NewOps
;
994 for (auto Op
: Expr
->expr_ops()) {
995 // Append new opcodes before DW_OP_{stack_value, LLVM_fragment}.
996 if (Op
.getOp() == dwarf::DW_OP_stack_value
||
997 Op
.getOp() == dwarf::DW_OP_LLVM_fragment
) {
998 NewOps
.append(Ops
.begin(), Ops
.end());
1000 // Ensure that the new opcodes are only appended once.
1003 Op
.appendToVector(NewOps
);
1006 NewOps
.append(Ops
.begin(), Ops
.end());
1007 return DIExpression::get(Expr
->getContext(), NewOps
);
1010 DIExpression
*DIExpression::appendToStack(const DIExpression
*Expr
,
1011 ArrayRef
<uint64_t> Ops
) {
1012 assert(Expr
&& !Ops
.empty() && "Can't append ops to this expression");
1015 return Op
== dwarf::DW_OP_stack_value
||
1016 Op
== dwarf::DW_OP_LLVM_fragment
;
1018 "Can't append this op");
1020 // Append a DW_OP_deref after Expr's current op list if it's non-empty and
1021 // has no DW_OP_stack_value.
1023 // Match .* DW_OP_stack_value (DW_OP_LLVM_fragment A B)?.
1024 Optional
<FragmentInfo
> FI
= Expr
->getFragmentInfo();
1025 unsigned DropUntilStackValue
= FI
.hasValue() ? 3 : 0;
1026 ArrayRef
<uint64_t> ExprOpsBeforeFragment
=
1027 Expr
->getElements().drop_back(DropUntilStackValue
);
1028 bool NeedsDeref
= (Expr
->getNumElements() > DropUntilStackValue
) &&
1029 (ExprOpsBeforeFragment
.back() != dwarf::DW_OP_stack_value
);
1030 bool NeedsStackValue
= NeedsDeref
|| ExprOpsBeforeFragment
.empty();
1032 // Append a DW_OP_deref after Expr's current op list if needed, then append
1033 // the new ops, and finally ensure that a single DW_OP_stack_value is present.
1034 SmallVector
<uint64_t, 16> NewOps
;
1036 NewOps
.push_back(dwarf::DW_OP_deref
);
1037 NewOps
.append(Ops
.begin(), Ops
.end());
1038 if (NeedsStackValue
)
1039 NewOps
.push_back(dwarf::DW_OP_stack_value
);
1040 return DIExpression::append(Expr
, NewOps
);
1043 Optional
<DIExpression
*> DIExpression::createFragmentExpression(
1044 const DIExpression
*Expr
, unsigned OffsetInBits
, unsigned SizeInBits
) {
1045 SmallVector
<uint64_t, 8> Ops
;
1046 // Copy over the expression, but leave off any trailing DW_OP_LLVM_fragment.
1048 for (auto Op
: Expr
->expr_ops()) {
1049 switch (Op
.getOp()) {
1051 case dwarf::DW_OP_plus
:
1052 case dwarf::DW_OP_minus
:
1053 // We can't safely split arithmetic into multiple fragments because we
1054 // can't express carry-over between fragments.
1056 // FIXME: We *could* preserve the lowest fragment of a constant offset
1057 // operation if the offset fits into SizeInBits.
1059 case dwarf::DW_OP_LLVM_fragment
: {
1060 // Make the new offset point into the existing fragment.
1061 uint64_t FragmentOffsetInBits
= Op
.getArg(0);
1062 uint64_t FragmentSizeInBits
= Op
.getArg(1);
1063 (void)FragmentSizeInBits
;
1064 assert((OffsetInBits
+ SizeInBits
<= FragmentSizeInBits
) &&
1065 "new fragment outside of original fragment");
1066 OffsetInBits
+= FragmentOffsetInBits
;
1070 Op
.appendToVector(Ops
);
1073 Ops
.push_back(dwarf::DW_OP_LLVM_fragment
);
1074 Ops
.push_back(OffsetInBits
);
1075 Ops
.push_back(SizeInBits
);
1076 return DIExpression::get(Expr
->getContext(), Ops
);
1079 bool DIExpression::isConstant() const {
1080 // Recognize DW_OP_constu C DW_OP_stack_value (DW_OP_LLVM_fragment Len Ofs)?.
1081 if (getNumElements() != 3 && getNumElements() != 6)
1083 if (getElement(0) != dwarf::DW_OP_constu
||
1084 getElement(2) != dwarf::DW_OP_stack_value
)
1086 if (getNumElements() == 6 && getElement(3) != dwarf::DW_OP_LLVM_fragment
)
1091 DIGlobalVariableExpression
*
1092 DIGlobalVariableExpression::getImpl(LLVMContext
&Context
, Metadata
*Variable
,
1093 Metadata
*Expression
, StorageType Storage
,
1094 bool ShouldCreate
) {
1095 DEFINE_GETIMPL_LOOKUP(DIGlobalVariableExpression
, (Variable
, Expression
));
1096 Metadata
*Ops
[] = {Variable
, Expression
};
1097 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIGlobalVariableExpression
, Ops
);
1100 DIObjCProperty
*DIObjCProperty::getImpl(
1101 LLVMContext
&Context
, MDString
*Name
, Metadata
*File
, unsigned Line
,
1102 MDString
*GetterName
, MDString
*SetterName
, unsigned Attributes
,
1103 Metadata
*Type
, StorageType Storage
, bool ShouldCreate
) {
1104 assert(isCanonical(Name
) && "Expected canonical MDString");
1105 assert(isCanonical(GetterName
) && "Expected canonical MDString");
1106 assert(isCanonical(SetterName
) && "Expected canonical MDString");
1107 DEFINE_GETIMPL_LOOKUP(DIObjCProperty
, (Name
, File
, Line
, GetterName
,
1108 SetterName
, Attributes
, Type
));
1109 Metadata
*Ops
[] = {Name
, File
, GetterName
, SetterName
, Type
};
1110 DEFINE_GETIMPL_STORE(DIObjCProperty
, (Line
, Attributes
), Ops
);
1113 DIImportedEntity
*DIImportedEntity::getImpl(LLVMContext
&Context
, unsigned Tag
,
1114 Metadata
*Scope
, Metadata
*Entity
,
1115 Metadata
*File
, unsigned Line
,
1116 MDString
*Name
, StorageType Storage
,
1117 bool ShouldCreate
) {
1118 assert(isCanonical(Name
) && "Expected canonical MDString");
1119 DEFINE_GETIMPL_LOOKUP(DIImportedEntity
,
1120 (Tag
, Scope
, Entity
, File
, Line
, Name
));
1121 Metadata
*Ops
[] = {Scope
, Entity
, Name
, File
};
1122 DEFINE_GETIMPL_STORE(DIImportedEntity
, (Tag
, Line
), Ops
);
1125 DIMacro
*DIMacro::getImpl(LLVMContext
&Context
, unsigned MIType
,
1126 unsigned Line
, MDString
*Name
, MDString
*Value
,
1127 StorageType Storage
, bool ShouldCreate
) {
1128 assert(isCanonical(Name
) && "Expected canonical MDString");
1129 DEFINE_GETIMPL_LOOKUP(DIMacro
, (MIType
, Line
, Name
, Value
));
1130 Metadata
*Ops
[] = { Name
, Value
};
1131 DEFINE_GETIMPL_STORE(DIMacro
, (MIType
, Line
), Ops
);
1134 DIMacroFile
*DIMacroFile::getImpl(LLVMContext
&Context
, unsigned MIType
,
1135 unsigned Line
, Metadata
*File
,
1136 Metadata
*Elements
, StorageType Storage
,
1137 bool ShouldCreate
) {
1138 DEFINE_GETIMPL_LOOKUP(DIMacroFile
,
1139 (MIType
, Line
, File
, Elements
));
1140 Metadata
*Ops
[] = { File
, Elements
};
1141 DEFINE_GETIMPL_STORE(DIMacroFile
, (MIType
, Line
), Ops
);