diff options
author | Vladislav Dzhidzhoev <vdzhidzhoev@accesssoftek.com> | 2025-05-20 14:53:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-20 14:53:15 +0200 |
commit | f057a58be39937b2ce8b4a02a13fb1bee3b1f2a2 (patch) | |
tree | 4a9b286ff63bd571d61acf2411f54fd122eaee94 /llvm/lib/IR/DebugInfo.cpp | |
parent | 01d9c7f2ac095707b0cc01b75878b9e25b20a909 (diff) | |
download | llvm-f057a58be39937b2ce8b4a02a13fb1bee3b1f2a2.zip llvm-f057a58be39937b2ce8b4a02a13fb1bee3b1f2a2.tar.gz llvm-f057a58be39937b2ce8b4a02a13fb1bee3b1f2a2.tar.bz2 |
[DebugInfo] Update DebugInfoFinder to take retainedNodes into account (#140285)
Since https://reviews.llvm.org/D144004, DISubprogram's retainedNodes
field is used to track DIImportedEntities, in addition to local
variables and labels.
However, the corresponding update for DebugInfoFinder, to make it visit
DISubprogram's retainedNodes, was missing.
This is the fix for it.
This change is separated from
https://github.com/llvm/llvm-project/pull/119001 to simplify it.
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index dff9a08..7db9891 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -241,23 +241,14 @@ void DebugInfoFinder::processCompileUnit(DICompileUnit *CU) { processType(T); else processSubprogram(cast<DISubprogram>(RT)); - for (auto *Import : CU->getImportedEntities()) { - auto *Entity = Import->getEntity(); - if (auto *T = dyn_cast<DIType>(Entity)) - processType(T); - else if (auto *SP = dyn_cast<DISubprogram>(Entity)) - processSubprogram(SP); - else if (auto *NS = dyn_cast<DINamespace>(Entity)) - processScope(NS->getScope()); - else if (auto *M = dyn_cast<DIModule>(Entity)) - processScope(M->getScope()); - } + for (auto *Import : CU->getImportedEntities()) + processImportedEntity(Import); } void DebugInfoFinder::processInstruction(const Module &M, const Instruction &I) { if (auto *DVI = dyn_cast<DbgVariableIntrinsic>(&I)) - processVariable(M, DVI->getVariable()); + processVariable(DVI->getVariable()); if (auto DbgLoc = I.getDebugLoc()) processLocation(M, DbgLoc.get()); @@ -275,7 +266,7 @@ void DebugInfoFinder::processLocation(const Module &M, const DILocation *Loc) { void DebugInfoFinder::processDbgRecord(const Module &M, const DbgRecord &DR) { if (const DbgVariableRecord *DVR = dyn_cast<const DbgVariableRecord>(&DR)) - processVariable(M, DVR->getVariable()); + processVariable(DVR->getVariable()); processLocation(M, DR.getDebugLoc().get()); } @@ -303,6 +294,18 @@ void DebugInfoFinder::processType(DIType *DT) { } } +void DebugInfoFinder::processImportedEntity(DIImportedEntity *Import) { + auto *Entity = Import->getEntity(); + if (auto *T = dyn_cast<DIType>(Entity)) + processType(T); + else if (auto *SP = dyn_cast<DISubprogram>(Entity)) + processSubprogram(SP); + else if (auto *NS = dyn_cast<DINamespace>(Entity)) + processScope(NS->getScope()); + else if (auto *M = dyn_cast<DIModule>(Entity)) + processScope(M->getScope()); +} + void DebugInfoFinder::processScope(DIScope *Scope) { if (!Scope) return; @@ -350,10 +353,16 @@ void DebugInfoFinder::processSubprogram(DISubprogram *SP) { processType(TVal->getType()); } } + + for (auto *N : SP->getRetainedNodes()) { + if (auto *Var = dyn_cast_or_null<DILocalVariable>(N)) + processVariable(Var); + else if (auto *Import = dyn_cast_or_null<DIImportedEntity>(N)) + processImportedEntity(Import); + } } -void DebugInfoFinder::processVariable(const Module &M, - const DILocalVariable *DV) { +void DebugInfoFinder::processVariable(DILocalVariable *DV) { if (!NodesSeen.insert(DV).second) return; processScope(DV->getScope()); |