summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter
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/CodeGen/AsmPrinter
parentb24f4fb6171eaf2caa8f3cf6adcf11821ec1d27c (diff)
downloadbcm5719-llvm-5992a72b4d21f3ea15a0ecbb593d92c9bc4fe1a0.tar.gz
bcm5719-llvm-5992a72b4d21f3ea15a0ecbb593d92c9bc4fe1a0.zip
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/CodeGen/AsmPrinter')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 296a799d33c..d9d265ef2b9 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -466,15 +466,18 @@ void DwarfDebug::beginModule() {
const Module *M = MMI->getModule();
- NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
- if (!CU_Nodes)
- return;
- TypeIdentifierMap = generateDITypeIdentifierMap(CU_Nodes);
+ TypeIdentifierMap = generateDITypeIdentifierMap(*M);
+ unsigned NumDebugCUs = 0;
+ for (DICompileUnit *CUNode : M->debug_compile_units()) {
+ (void)CUNode;
+ ++NumDebugCUs;
+ }
- SingleCU = CU_Nodes->getNumOperands() == 1;
+ // Tell MMI whether we have debug info.
+ MMI->setDebugInfoAvailability(NumDebugCUs > 0);
+ SingleCU = NumDebugCUs == 1;
- for (MDNode *N : CU_Nodes->operands()) {
- auto *CUNode = cast<DICompileUnit>(N);
+ for (DICompileUnit *CUNode : M->debug_compile_units()) {
DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);
for (auto *IE : CUNode->getImportedEntities())
CU.addImportedEntity(IE);
@@ -500,9 +503,6 @@ void DwarfDebug::beginModule() {
for (auto *IE : CUNode->getImportedEntities())
constructAndAddImportedEntityDIE(CU, IE);
}
-
- // Tell MMI that we have debug info.
- MMI->setDebugInfoAvailability(true);
}
void DwarfDebug::finishVariableDefinitions() {
@@ -538,6 +538,9 @@ void DwarfDebug::collectDeadVariables() {
if (NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu")) {
for (MDNode *N : CU_Nodes->operands()) {
auto *TheCU = cast<DICompileUnit>(N);
+ if (TheCU->getEmissionKind() == DICompileUnit::NoDebug)
+ continue;
+
// Construct subprogram DIE and add variables DIEs.
DwarfCompileUnit *SPCU =
static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU));
@@ -1090,7 +1093,10 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
// includes the directory of the cpp file being built, even when the file name
// is absolute (such as an <> lookup header)))
DwarfCompileUnit *TheCU = SPMap.lookup(FnScope->getScopeNode());
- assert(TheCU && "Unable to find compile unit!");
+ if (!TheCU)
+ // Once DISubprogram points to the owning CU, we can assert that the CU has
+ // a NoDebug EmissionKind here.
+ return;
if (Asm->OutStreamer->hasRawTextSupport())
// Use a single line table if we are generating assembly.
Asm->OutStreamer->getContext().setDwarfCompileUnitID(0);
@@ -1113,7 +1119,10 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
"endFunction should be called with the same function as beginFunction");
if (!MMI->hasDebugInfo() || LScopes.empty() ||
- !MF->getFunction()->getSubprogram()) {
+ !MF->getFunction()->getSubprogram() ||
+ // Once DISubprogram points to the owning CU, we can check for a
+ // CU with a NoDebug EmissionKind here.
+ !SPMap.lookup(MF->getFunction()->getSubprogram())) {
// If we don't have a lexical scope for this function then there will
// be a hole in the range information. Keep note of this by setting the
// previously used section to nullptr.
OpenPOWER on IntegriCloud