From 0b0271ef976cec3ee6a1ab2d654e42cf111a68bd Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Tue, 19 Apr 2016 14:55:09 +0000 Subject: 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 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 43 +++++++++++++++++++------------ 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index d454eb1..dba0fd4 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; -- cgit v1.1