aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2016-04-08 22:43:03 +0000
committerAdrian Prantl <aprantl@apple.com>2016-04-08 22:43:03 +0000
commit5992a72b4d21f3ea15a0ecbb593d92c9bc4fe1a0 (patch)
treee369ac2ee392142837ebf0b460286e0fe2bdda0a /llvm/lib/IR/DebugInfo.cpp
parentb24f4fb6171eaf2caa8f3cf6adcf11821ec1d27c (diff)
downloadllvm-5992a72b4d21f3ea15a0ecbb593d92c9bc4fe1a0.zip
llvm-5992a72b4d21f3ea15a0ecbb593d92c9bc4fe1a0.tar.gz
llvm-5992a72b4d21f3ea15a0ecbb593d92c9bc4fe1a0.tar.bz2
Support the Nodebug emission kind for DICompileUnits.
Sample-based profiling and optimization remarks currently remove DICompileUnits from llvm.dbg.cu to suppress the emission of debug info from them. This is somewhat of a hack and only borderline legal IR. This patch uses the recently introduced NoDebug emission kind in DICompileUnit to achieve the same result without breaking the Verifier. A nice side-effect of this change is that it is now possible to combine NoDebug and regular compile units under LTO. http://reviews.llvm.org/D18808 <rdar://problem/25427165> llvm-svn: 265861
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp61
1 files changed, 28 insertions, 33 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 2a60af4..e63c254 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -39,10 +39,9 @@ DISubprogram *llvm::getDISubprogram(const MDNode *Scope) {
}
DITypeIdentifierMap
-llvm::generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes) {
+llvm::generateDITypeIdentifierMap(const Module &M) {
DITypeIdentifierMap Map;
- for (unsigned CUi = 0, CUe = CU_Nodes->getNumOperands(); CUi != CUe; ++CUi) {
- auto *CU = cast<DICompileUnit>(CU_Nodes->getOperand(CUi));
+ for (DICompileUnit *CU : M.debug_compile_units()) {
DINodeArray Retain = CU->getRetainedTypes();
for (unsigned Ti = 0, Te = Retain.size(); Ti != Te; ++Ti) {
if (!isa<DICompositeType>(Retain[Ti]))
@@ -79,42 +78,38 @@ void DebugInfoFinder::reset() {
}
void DebugInfoFinder::InitializeTypeMap(const Module &M) {
- if (!TypeMapInitialized)
- if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
- TypeIdentifierMap = generateDITypeIdentifierMap(CU_Nodes);
- TypeMapInitialized = true;
- }
+ if (TypeMapInitialized)
+ return;
+ TypeIdentifierMap = generateDITypeIdentifierMap(M);
+ TypeMapInitialized = true;
}
void DebugInfoFinder::processModule(const Module &M) {
InitializeTypeMap(M);
- if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
- for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
- auto *CU = cast<DICompileUnit>(CU_Nodes->getOperand(i));
- addCompileUnit(CU);
- for (auto *DIG : CU->getGlobalVariables()) {
- if (addGlobalVariable(DIG)) {
- processScope(DIG->getScope());
- processType(DIG->getType().resolve(TypeIdentifierMap));
- }
+ for (auto *CU : M.debug_compile_units()) {
+ addCompileUnit(CU);
+ for (auto *DIG : CU->getGlobalVariables()) {
+ if (addGlobalVariable(DIG)) {
+ processScope(DIG->getScope());
+ processType(DIG->getType().resolve(TypeIdentifierMap));
}
- for (auto *SP : CU->getSubprograms())
+ }
+ for (auto *SP : CU->getSubprograms())
+ processSubprogram(SP);
+ for (auto *ET : CU->getEnumTypes())
+ processType(ET);
+ for (auto *RT : CU->getRetainedTypes())
+ processType(RT);
+ for (auto *Import : CU->getImportedEntities()) {
+ auto *Entity = Import->getEntity().resolve(TypeIdentifierMap);
+ if (auto *T = dyn_cast<DIType>(Entity))
+ processType(T);
+ else if (auto *SP = dyn_cast<DISubprogram>(Entity))
processSubprogram(SP);
- for (auto *ET : CU->getEnumTypes())
- processType(ET);
- for (auto *RT : CU->getRetainedTypes())
- processType(RT);
- for (auto *Import : CU->getImportedEntities()) {
- auto *Entity = Import->getEntity().resolve(TypeIdentifierMap);
- 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 if (auto *NS = dyn_cast<DINamespace>(Entity))
+ processScope(NS->getScope());
+ else if (auto *M = dyn_cast<DIModule>(Entity))
+ processScope(M->getScope());
}
}
}