diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:46:15 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:46:15 +0000 |
commit | dd58ef019b700900793a1eb48b52123db01b654e (patch) | |
tree | fcfbb4df56a744f4ddc6122c50521dd3f1c5e196 /lib/IR/DebugInfo.cpp | |
parent | 2fe5752e3a7c345cdb59e869278d36af33c13fa4 (diff) | |
download | src-dd58ef019b700900793a1eb48b52123db01b654e.tar.gz src-dd58ef019b700900793a1eb48b52123db01b654e.zip |
Vendor import of llvm trunk r256633:
Notes
Notes:
svn path=/vendor/llvm/dist/; revision=292915
Diffstat (limited to 'lib/IR/DebugInfo.cpp')
-rw-r--r-- | lib/IR/DebugInfo.cpp | 55 |
1 files changed, 14 insertions, 41 deletions
diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 9646d1aa4d76..a2443becdd00 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -56,21 +56,6 @@ DISubprogram *llvm::getDISubprogram(const Function *F) { return nullptr; } -DICompositeTypeBase *llvm::getDICompositeType(DIType *T) { - if (auto *C = dyn_cast_or_null<DICompositeTypeBase>(T)) - return C; - - if (auto *D = dyn_cast_or_null<DIDerivedTypeBase>(T)) { - // This function is currently used by dragonegg and dragonegg does - // not generate identifier for types, so using an empty map to resolve - // DerivedFrom should be fine. - DITypeIdentifierMap EmptyMap; - return getDICompositeType(D->getBaseType().resolve(EmptyMap)); - } - - return nullptr; -} - DITypeIdentifierMap llvm::generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes) { DITypeIdentifierMap Map; @@ -164,20 +149,22 @@ void DebugInfoFinder::processType(DIType *DT) { if (!addType(DT)) return; processScope(DT->getScope().resolve(TypeIdentifierMap)); - if (auto *DCT = dyn_cast<DICompositeTypeBase>(DT)) { + if (auto *ST = dyn_cast<DISubroutineType>(DT)) { + for (DITypeRef Ref : ST->getTypeArray()) + processType(Ref.resolve(TypeIdentifierMap)); + return; + } + if (auto *DCT = dyn_cast<DICompositeType>(DT)) { processType(DCT->getBaseType().resolve(TypeIdentifierMap)); - if (auto *ST = dyn_cast<DISubroutineType>(DCT)) { - for (DITypeRef Ref : ST->getTypeArray()) - processType(Ref.resolve(TypeIdentifierMap)); - return; - } for (Metadata *D : DCT->getElements()) { if (auto *T = dyn_cast<DIType>(D)) processType(T); else if (auto *SP = dyn_cast<DISubprogram>(D)) processSubprogram(SP); } - } else if (auto *DDT = dyn_cast<DIDerivedTypeBase>(DT)) { + return; + } + if (auto *DDT = dyn_cast<DIDerivedType>(DT)) { processType(DDT->getBaseType().resolve(TypeIdentifierMap)); } } @@ -313,6 +300,10 @@ bool DebugInfoFinder::addScope(DIScope *Scope) { bool llvm::stripDebugInfo(Function &F) { bool Changed = false; + if (F.getSubprogram()) { + Changed = true; + F.setSubprogram(nullptr); + } for (BasicBlock &BB : F) { for (Instruction &I : BB) { if (I.getDebugLoc()) { @@ -349,7 +340,7 @@ bool llvm::StripDebugInfo(Module &M) { for (Module::named_metadata_iterator NMI = M.named_metadata_begin(), NME = M.named_metadata_end(); NMI != NME;) { - NamedMDNode *NMD = NMI; + NamedMDNode *NMD = &*NMI; ++NMI; if (NMD->getName().startswith("llvm.dbg.")) { NMD->eraseFromParent(); @@ -372,21 +363,3 @@ unsigned llvm::getDebugMetadataVersionFromModule(const Module &M) { return Val->getZExtValue(); return 0; } - -DenseMap<const llvm::Function *, DISubprogram *> -llvm::makeSubprogramMap(const Module &M) { - DenseMap<const Function *, DISubprogram *> R; - - NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu"); - if (!CU_Nodes) - return R; - - for (MDNode *N : CU_Nodes->operands()) { - auto *CUNode = cast<DICompileUnit>(N); - for (auto *SP : CUNode->getSubprograms()) { - if (Function *F = SP->getFunction()) - R.insert(std::make_pair(F, SP)); - } - } - return R; -} |