diff options
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
| -rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 57 |
1 files changed, 16 insertions, 41 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 2a4d0d3a447..830082ffa5f 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -61,52 +61,16 @@ void DebugInfoFinder::reset() { } void DebugInfoFinder::processModule(const Module &M) { - for (auto *CU : M.debug_compile_units()) { - addCompileUnit(CU); - for (auto DIG : CU->getGlobalVariables()) { - if (!addGlobalVariable(DIG)) - continue; - auto *GV = DIG->getVariable(); - processScope(GV->getScope()); - processType(GV->getType().resolve()); - } - for (auto *ET : CU->getEnumTypes()) - processType(ET); - for (auto *RT : CU->getRetainedTypes()) - if (auto *T = dyn_cast<DIType>(RT)) - processType(T); - else - processSubprogram(cast<DISubprogram>(RT)); - for (auto *Import : CU->getImportedEntities()) { - auto *Entity = Import->getEntity().resolve(); - 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()); - else - llvm_unreachable("unexpected imported entity type"); - } - } + for (auto *CU : M.debug_compile_units()) + processCompileUnit(CU); for (auto &F : M.functions()) { if (auto *SP = cast_or_null<DISubprogram>(F.getSubprogram())) processSubprogram(SP); // There could be subprograms from inlined functions referenced from // instructions only. Walk the function to find them. - for (const BasicBlock &BB : F) { - for (const Instruction &I : BB) { - if (auto *DDI = dyn_cast<DbgDeclareInst>(&I)) - processDeclare(M, DDI); - else if (auto *DVI = dyn_cast<DbgValueInst>(&I)) - processValue(M, DVI); - - if (auto DbgLoc = I.getDebugLoc()) - processLocation(M, DbgLoc.get()); - } - } + for (const BasicBlock &BB : F) + for (const Instruction &I : BB) + processInstruction(M, I); } } @@ -142,6 +106,17 @@ void DebugInfoFinder::processCompileUnit(DICompileUnit *CU) { } } +void DebugInfoFinder::processInstruction(const Module &M, + const Instruction &I) { + if (auto *DDI = dyn_cast<DbgDeclareInst>(&I)) + processDeclare(M, DDI); + else if (auto *DVI = dyn_cast<DbgValueInst>(&I)) + processValue(M, DVI); + + if (auto DbgLoc = I.getDebugLoc()) + processLocation(M, DbgLoc.get()); +} + void DebugInfoFinder::processLocation(const Module &M, const DILocation *Loc) { if (!Loc) return; |

