================
@@ -2178,46 +2183,97 @@ Error
MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
}
Metadata *CUorFn = getMDOrNull(Record[12 + OffsetB]);
- DISubprogram *SP = GET_OR_DISTINCT(
- DISubprogram,
- (Context,
- getDITypeRefOrNull(Record[1]), // scope
- getMDString(Record[2]), // name
- getMDString(Record[3]), // linkageName
- getMDOrNull(Record[4]), // file
- Record[5], // line
- getMDOrNull(Record[6]), // type
- Record[7 + OffsetA], // scopeLine
- getDITypeRefOrNull(Record[8 + OffsetA]), // containingType
- Record[10 + OffsetA], // virtualIndex
- HasThisAdj ? Record[16 + OffsetB] : 0, // thisAdjustment
- Flags, // flags
- SPFlags, // SPFlags
- HasUnit ? CUorFn : nullptr, // unit
- getMDOrNull(Record[13 + OffsetB]), // templateParams
- getMDOrNull(Record[14 + OffsetB]), // declaration
- getMDOrNull(Record[15 + OffsetB]), // retainedNodes
- HasThrownTypes ? getMDOrNull(Record[17 + OffsetB])
- : nullptr, // thrownTypes
- HasAnnotations ? getMDOrNull(Record[18 + OffsetB])
- : nullptr, // annotations
- HasTargetFuncName ? getMDString(Record[19 + OffsetB])
- : nullptr, // targetFuncName
- UsesKeyInstructions));
- MetadataList.assignValue(SP, NextMetadataNo);
- NextMetadataNo++;
- if (IsDistinct)
- NewDistinctSPs.push_back(SP);
+ DISubprogram *SP = nullptr;
+ Metadata *Scope = getDITypeRefOrNull(Record[1]);
+ bool MaybeODRUnique = Context.isODRUniquingDebugTypes() && !IsDistinct &&
+ !(SPFlags & DISubprogram::SPFlagDefinition) &&
+ getMDString(Record[3]) && Scope;
+
+ if (MaybeODRUnique && !isa<DIScope>(Scope)) {
+ // The scope is a temporary forward reference, meaning we can't perform
+ // ODR-uniquing yet. In order to perform ODR uniquing later the SP must
+ // be replacable, so create a temporary one.
+ TempDISubprogram Tmp = DISubprogram::getTemporary(
+ Context,
+ getDITypeRefOrNull(Record[1]), // scope
+ getMDString(Record[2]), // name
+ getMDString(Record[3]), // linkageName
+ getMDOrNull(Record[4]), // file
+ Record[5], // line
+ getMDOrNull(Record[6]), // type
+ Record[7 + OffsetA], // scopeLine
+ getDITypeRefOrNull(Record[8 + OffsetA]), // containingType
+ Record[10 + OffsetA], // virtualIndex
+ HasThisAdj ? Record[16 + OffsetB] : 0, // thisAdjustment
+ Flags, // flags
+ SPFlags, // SPFlags
+ HasUnit ? CUorFn : nullptr, // unit
+ getMDOrNull(Record[13 + OffsetB]), // templateParams
+ getMDOrNull(Record[14 + OffsetB]), // declaration
+ getMDOrNull(Record[15 + OffsetB]), // retainedNodes
+ HasThrownTypes ? getMDOrNull(Record[17 + OffsetB])
+ : nullptr, // thrownTypes
+ HasAnnotations ? getMDOrNull(Record[18 + OffsetB])
+ : nullptr, // annotations
+ HasTargetFuncName ? getMDString(Record[19 + OffsetB])
+ : nullptr, // targetFuncName
+ UsesKeyInstructions);
+ Context.getDebugTypeODRUniquer()->addUnresolvedODRSubprogramDecl(
+ std::move(Tmp));
+ SP = Tmp.get();
----------------
chbessonova wrote:
`Tmp` was moved on the previous line, so it is always a nullptr.
Are there any tests that reach this branch?
https://github.com/llvm/llvm-project/pull/217042
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits