summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-19 14:55:09 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-19 14:55:09 +0000
commit0b0271ef976cec3ee6a1ab2d654e42cf111a68bd (patch)
treeb4425f350e69c433c823dfc993711143958a25fd /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent171b92f1e159be30fbc29871fefcb09fd05a9016 (diff)
downloadbcm5719-llvm-0b0271ef976cec3ee6a1ab2d654e42cf111a68bd.tar.gz
bcm5719-llvm-0b0271ef976cec3ee6a1ab2d654e42cf111a68bd.zip
IR: getOrInsertODRUniquedType => DICompositeType::getODRType, NFC
Lift the API for debug info ODR type uniquing up a layer. Instead of clients managing the map directly on the LLVMContext, add a static method to DICompositeType called getODRType and handle the map in the background. Also adds DICompositeType::getODRTypeIfExists, so far just for convenience in the unit tests. This simplifies the logic in LLParser and BitcodeReader. Because of argument spam there are actually a few more lines of code now; I'll see if I come up with a reasonable way to clean that up. llvm-svn: 266742
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp43
1 files changed, 27 insertions, 16 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index d454eb1fd4c..dba0fd41755 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2190,25 +2190,36 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
// If we have a UUID and this is not a forward declaration, lookup the
// mapping.
+ bool IsDistinct = Record[0];
+ unsigned Tag = Record[1];
+ MDString *Name = getMDString(Record[2]);
+ Metadata *File = getMDOrNull(Record[3]);
+ unsigned Line = Record[4];
+ Metadata *Scope = getMDOrNull(Record[5]);
+ Metadata *BaseType = getMDOrNull(Record[6]);
+ uint64_t SizeInBits = Record[7];
+ uint64_t AlignInBits = Record[8];
+ uint64_t OffsetInBits = Record[9];
unsigned Flags = Record[10];
+ Metadata *Elements = getMDOrNull(Record[11]);
+ unsigned RuntimeLang = Record[12];
+ Metadata *VTableHolder = getMDOrNull(Record[13]);
+ Metadata *TemplateParams = getMDOrNull(Record[14]);
auto *Identifier = getMDString(Record[15]);
- DICompositeType **MappedT = nullptr;
+ DICompositeType *CT = nullptr;
if (!(Flags & DINode::FlagFwdDecl) && Identifier)
- MappedT = Context.getOrInsertODRUniquedType(*Identifier);
-
- // Use the mapped type node, or create a new one if necessary.
- DICompositeType *CT = MappedT ? *MappedT : nullptr;
- if (!CT) {
- CT = GET_OR_DISTINCT(
- DICompositeType, Record[0],
- (Context, Record[1], getMDString(Record[2]), getMDOrNull(Record[3]),
- Record[4], getMDOrNull(Record[5]), getMDOrNull(Record[6]),
- Record[7], Record[8], Record[9], Flags, getMDOrNull(Record[11]),
- Record[12], getMDOrNull(Record[13]), getMDOrNull(Record[14]),
- Identifier));
- if (MappedT)
- *MappedT = CT;
- }
+ CT = DICompositeType::getODRType(
+ Context, *Identifier, Tag, Name, File, Line, Scope, BaseType,
+ SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
+ VTableHolder, TemplateParams);
+
+ // Create a node if we didn't get a lazy ODR type.
+ if (!CT)
+ CT = GET_OR_DISTINCT(DICompositeType, IsDistinct,
+ (Context, Tag, Name, File, Line, Scope, BaseType,
+ SizeInBits, AlignInBits, OffsetInBits, Flags,
+ Elements, RuntimeLang, VTableHolder,
+ TemplateParams, Identifier));
MetadataList.assignValue(CT, NextMetadataNo++);
break;
OpenPOWER on IntegriCloud