summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2013-09-11 19:40:28 +0000
committerManman Ren <manman.ren@gmail.com>2013-09-11 19:40:28 +0000
commit995de6cddf74cdd7fb46b1ba53f4442df28be8ed (patch)
treece967b01e3ec12ae8a7af39cb43bbd9f7b61e5b7
parent4f7e2c38e864d7eaeb407ac501478e9579624d1b (diff)
Debug info: add more comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190544 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 6f6a7de5daa..61c02b84079 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -424,10 +424,13 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(CompileUnit *SPCU,
return SPDie;
}
+/// Check whether we should create a DIE for the given Scope, return true
+/// if we don't create a DIE (the corresponding DIE is null).
bool DwarfDebug::isLexicalScopeDIENull(LexicalScope *Scope) {
if (Scope->isAbstractScope())
return false;
+ // We don't create a DIE if there is no Range.
const SmallVectorImpl<InsnRange> &Ranges = Scope->getRanges();
if (Ranges.empty())
return true;
@@ -435,6 +438,8 @@ bool DwarfDebug::isLexicalScopeDIENull(LexicalScope *Scope) {
if (Ranges.size() > 1)
return false;
+ // We don't create a DIE if we have a single Range and the end label
+ // is null.
SmallVectorImpl<InsnRange>::const_iterator RI = Ranges.begin();
MCSymbol *End = getLabelAfterInsn(RI->second);
return !End;
@@ -595,6 +600,9 @@ DIE *DwarfDebug::constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope) {
DIE *ObjectPointer = NULL;
bool ChildrenCreated = false;
+ // We try to create the scope DIE first, then the children DIEs. This will
+ // avoid creating un-used children then removing them later when we find out
+ // the scope DIE is null.
DIE *ScopeDIE = NULL;
if (Scope->getInlinedAt())
ScopeDIE = constructInlinedScopeDIE(TheCU, Scope);
@@ -610,12 +618,15 @@ DIE *DwarfDebug::constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope) {
ScopeDIE = updateSubprogramScopeDIE(TheCU, DS);
}
else {
+ // Early exit when we know the scope DIE is going to be null.
if (isLexicalScopeDIENull(Scope))
return NULL;
- // We create children only when we know the scope DIE is not going to be
- // null.
+
+ // We create children here when we know the scope DIE is not going to be
+ // null and the children will be added to the scope DIE.
ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children);
ChildrenCreated = true;
+
// There is no need to emit empty lexical block DIE.
std::pair<ImportedEntityMap::const_iterator,
ImportedEntityMap::const_iterator> Range = std::equal_range(
@@ -637,6 +648,7 @@ DIE *DwarfDebug::constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope) {
return NULL;
}
if (!ChildrenCreated)
+ // We create children when the scope DIE is not null.
ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children);
// Add children