diff options
author | Hans Wennborg <hans@chromium.org> | 2023-09-29 14:09:04 +0200 |
---|---|---|
committer | Hans Wennborg <hans@chromium.org> | 2023-09-29 14:23:31 +0200 |
commit | eee1f7cef856241ad7d66b715c584d29b1c89ca9 (patch) | |
tree | 8201bea81903f1dc28b2921b79611efc1f5e39b0 /llvm/lib/IR/DIBuilder.cpp | |
parent | 00f2d9b0ebcd3a4d56945c5260b8e891087a7861 (diff) | |
download | llvm-eee1f7cef856241ad7d66b715c584d29b1c89ca9.zip llvm-eee1f7cef856241ad7d66b715c584d29b1c89ca9.tar.gz llvm-eee1f7cef856241ad7d66b715c584d29b1c89ca9.tar.bz2 |
Revert "[DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)"
This caused asserts:
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2331:
virtual void llvm::DwarfDebug::endFunctionImpl(const llvm::MachineFunction *):
Assertion `LScopes.getAbstractScopesList().size() == NumAbstractSubprograms &&
"getOrCreateAbstractScope() inserted an abstract subprogram scope"' failed.
See comment on the code review for reproducer.
> RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544
>
> Similar to imported declarations, the patch tracks function-local types in
> DISubprogram's 'retainedNodes' field. DwarfDebug is adjusted in accordance with
> the aforementioned metadata change and provided a support of function-local
> types scoped within a lexical block.
>
> The patch assumes that DICompileUnit's 'enums field' no longer tracks local
> types and DwarfDebug would assert if any locally-scoped types get placed there.
>
> Reviewed By: jmmartinez
>
> Differential Revision: https://reviews.llvm.org/D144006
This reverts commit f8aab289b5549086062588fba627b0e4d3a5ab15.
Diffstat (limited to 'llvm/lib/IR/DIBuilder.cpp')
-rw-r--r-- | llvm/lib/IR/DIBuilder.cpp | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index d3e618b..1ce8c17 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -31,7 +31,7 @@ DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes, DICompileUnit *CU) AllowUnresolvedNodes(AllowUnresolvedNodes) { if (CUNode) { if (const auto &ETs = CUNode->getEnumTypes()) - EnumTypes.assign(ETs.begin(), ETs.end()); + AllEnumTypes.assign(ETs.begin(), ETs.end()); if (const auto &RTs = CUNode->getRetainedTypes()) AllRetainTypes.assign(RTs.begin(), RTs.end()); if (const auto &GVs = CUNode->getGlobalVariables()) @@ -68,10 +68,10 @@ void DIBuilder::finalize() { return; } - if (!EnumTypes.empty()) + if (!AllEnumTypes.empty()) CUNode->replaceEnumTypes(MDTuple::get( - VMContext, SmallVector<Metadata *, 16>(EnumTypes.begin(), - EnumTypes.end()))); + VMContext, SmallVector<Metadata *, 16>(AllEnumTypes.begin(), + AllEnumTypes.end()))); SmallVector<Metadata *, 16> RetainValues; // Declarations and definitions of the same type may be retained. Some @@ -336,13 +336,10 @@ DIDerivedType *DIBuilder::createTypedef(DIType *Ty, StringRef Name, DIScope *Context, uint32_t AlignInBits, DINode::DIFlags Flags, DINodeArray Annotations) { - auto *T = - DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File, LineNo, - getNonCompileUnitScope(Context), Ty, 0, AlignInBits, 0, - std::nullopt, Flags, nullptr, Annotations); - if (isa_and_nonnull<DILocalScope>(Context)) - getSubprogramNodesTrackingVector(Context).emplace_back(T); - return T; + return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File, + LineNo, getNonCompileUnitScope(Context), Ty, 0, + AlignInBits, 0, std::nullopt, Flags, nullptr, + Annotations); } DIDerivedType *DIBuilder::createFriend(DIType *Ty, DIType *FriendTy) { @@ -490,8 +487,6 @@ DICompositeType *DIBuilder::createClassType( OffsetInBits, Flags, Elements, 0, VTableHolder, cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier); trackIfUnresolved(R); - if (isa_and_nonnull<DILocalScope>(Context)) - getSubprogramNodesTrackingVector(Context).emplace_back(R); return R; } @@ -505,8 +500,6 @@ DICompositeType *DIBuilder::createStructType( getNonCompileUnitScope(Context), DerivedFrom, SizeInBits, AlignInBits, 0, Flags, Elements, RunTimeLang, VTableHolder, nullptr, UniqueIdentifier); trackIfUnresolved(R); - if (isa_and_nonnull<DILocalScope>(Context)) - getSubprogramNodesTrackingVector(Context).emplace_back(R); return R; } @@ -519,8 +512,6 @@ DICompositeType *DIBuilder::createUnionType( getNonCompileUnitScope(Scope), nullptr, SizeInBits, AlignInBits, 0, Flags, Elements, RunTimeLang, nullptr, nullptr, UniqueIdentifier); trackIfUnresolved(R); - if (isa_and_nonnull<DILocalScope>(Scope)) - getSubprogramNodesTrackingVector(Scope).emplace_back(R); return R; } @@ -553,10 +544,7 @@ DICompositeType *DIBuilder::createEnumerationType( getNonCompileUnitScope(Scope), UnderlyingType, SizeInBits, AlignInBits, 0, IsScoped ? DINode::FlagEnumClass : DINode::FlagZero, Elements, 0, nullptr, nullptr, UniqueIdentifier); - if (isa_and_nonnull<DILocalScope>(Scope)) - getSubprogramNodesTrackingVector(Scope).emplace_back(CTy); - else - EnumTypes.emplace_back(CTy); + AllEnumTypes.emplace_back(CTy); trackIfUnresolved(CTy); return CTy; } @@ -637,8 +625,7 @@ void DIBuilder::retainType(DIScope *T) { assert((isa<DIType>(T) || (isa<DISubprogram>(T) && cast<DISubprogram>(T)->isDefinition() == false)) && "Expected type or subprogram declaration"); - if (!isa_and_nonnull<DILocalScope>(T->getScope())) - AllRetainTypes.emplace_back(T); + AllRetainTypes.emplace_back(T); } DIBasicType *DIBuilder::createUnspecifiedParameter() { return nullptr; } @@ -655,8 +642,6 @@ DIBuilder::createForwardDecl(unsigned Tag, StringRef Name, DIScope *Scope, SizeInBits, AlignInBits, 0, DINode::FlagFwdDecl, nullptr, RuntimeLang, nullptr, nullptr, UniqueIdentifier); trackIfUnresolved(RetTy); - if (isa_and_nonnull<DILocalScope>(Scope)) - getSubprogramNodesTrackingVector(Scope).emplace_back(RetTy); return RetTy; } @@ -673,8 +658,6 @@ DICompositeType *DIBuilder::createReplaceableCompositeType( nullptr, Annotations) .release(); trackIfUnresolved(RetTy); - if (isa_and_nonnull<DILocalScope>(Scope)) - getSubprogramNodesTrackingVector(Scope).emplace_back(RetTy); return RetTy; } |