diff options
author | Vladislav Dzhidzhoev <vdzhidzhoev@accesssoftek.com> | 2023-06-15 19:36:36 +0200 |
---|---|---|
committer | Vladislav Dzhidzhoev <vdzhidzhoev@accesssoftek.com> | 2023-06-15 19:36:36 +0200 |
commit | b8ea03a4be0123cbff958711ec6d89e1ddaa347a (patch) | |
tree | 5b2e4f4c8a1ec8d3a79ffbcaf4f3f3b2125a720a /llvm/lib/Bitcode/Reader/MetadataLoader.cpp | |
parent | daba24ee7bd3d80f085e2e5f057af6b873a78a24 (diff) | |
download | llvm-b8ea03a4be0123cbff958711ec6d89e1ddaa347a.zip llvm-b8ea03a4be0123cbff958711ec6d89e1ddaa347a.tar.gz llvm-b8ea03a4be0123cbff958711ec6d89e1ddaa347a.tar.bz2 |
Revert "Reland "[DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local imported entities (3/7)""
This reverts commit fcc3981626821addc6c77b98006d02030b8ceb7f,
since Bitcode-upgrading code doesn't seem to be deterministic.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/MetadataLoader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/MetadataLoader.cpp | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp index f13c26e..4b5cfed 100644 --- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp @@ -15,7 +15,6 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/STLFunctionalExtras.h" -#include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" @@ -54,7 +53,6 @@ #include <deque> #include <iterator> #include <limits> -#include <map> #include <optional> #include <string> #include <tuple> @@ -465,9 +463,6 @@ class MetadataLoader::MetadataLoaderImpl { bool NeedUpgradeToDIGlobalVariableExpression = false; bool NeedDeclareExpressionUpgrade = false; - /// Map DILocalScope to the enclosing DISubprogram, if any. - DenseMap<DILocalScope *, DISubprogram *> ParentSubprogram; - /// True if metadata is being parsed for a module being ThinLTO imported. bool IsImporting = false; @@ -526,84 +521,6 @@ class MetadataLoader::MetadataLoaderImpl { } } - DISubprogram *findEnclosingSubprogram(DILocalScope *S) { - if (!S) - return nullptr; - if (auto *SP = ParentSubprogram[S]) { - return SP; - } - - DILocalScope *InitialScope = S; - DenseSet<DILocalScope *> Visited; - while (S && !isa<DISubprogram>(S)) { - S = dyn_cast_or_null<DILocalScope>(S->getScope()); - if (Visited.contains(S)) - break; - Visited.insert(S); - } - ParentSubprogram[InitialScope] = llvm::dyn_cast_or_null<DISubprogram>(S); - - return ParentSubprogram[InitialScope]; - } - - /// Move local imports from DICompileUnit's 'imports' field to - /// DISubprogram's retainedNodes. - void upgradeCULocals() { - if (NamedMDNode *CUNodes = TheModule.getNamedMetadata("llvm.dbg.cu")) { - for (unsigned I = 0, E = CUNodes->getNumOperands(); I != E; ++I) { - auto *CU = dyn_cast<DICompileUnit>(CUNodes->getOperand(I)); - if (!CU) - continue; - - if (auto *RawImported = CU->getRawImportedEntities()) { - // Collect a set of imported entities to be moved. - SmallPtrSet<Metadata *, 8> EntitiesToRemove; - for (Metadata *Op : CU->getImportedEntities()->operands()) { - auto *IE = cast<DIImportedEntity>(Op); - if (auto *S = dyn_cast_or_null<DILocalScope>(IE->getScope())) { - EntitiesToRemove.insert(IE); - } - } - - if (!EntitiesToRemove.empty()) { - // Make a new list of CU's 'imports'. - SmallVector<Metadata *> NewImports; - for (Metadata *Op : CU->getImportedEntities()->operands()) { - if (!EntitiesToRemove.contains(cast<DIImportedEntity>(Op))) { - NewImports.push_back(Op); - } - } - - // Find DISubprogram corresponding to each entity. - std::map<DISubprogram *, SmallVector<Metadata *>> SPToEntities; - for (auto *I : EntitiesToRemove) { - auto *Entity = cast<DIImportedEntity>(I); - if (auto *SP = findEnclosingSubprogram( - cast<DILocalScope>(Entity->getScope()))) { - SPToEntities[SP].push_back(Entity); - } - } - - // Update DISubprograms' retainedNodes. - for (auto I = SPToEntities.begin(); I != SPToEntities.end(); ++I) { - auto *SP = I->first; - auto RetainedNodes = SP->getRetainedNodes(); - SmallVector<Metadata *> MDs(RetainedNodes.begin(), - RetainedNodes.end()); - MDs.append(I->second); - SP->replaceRetainedNodes(MDNode::get(Context, MDs)); - } - - // Remove entities with local scope from CU. - CU->replaceImportedEntities(MDTuple::get(Context, NewImports)); - } - } - } - } - - ParentSubprogram.clear(); - } - /// Remove a leading DW_OP_deref from DIExpressions in a dbg.declare that /// describes a function argument. void upgradeDeclareExpressions(Function &F) { @@ -708,7 +625,6 @@ class MetadataLoader::MetadataLoaderImpl { void upgradeDebugInfo() { upgradeCUSubprograms(); upgradeCUVariables(); - upgradeCULocals(); } void callMDTypeCallback(Metadata **Val, unsigned TypeID); |