aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/DwarfWriter.cpp
diff options
context:
space:
mode:
authorJim Laskey <jlaskey@mac.com>2006-11-29 16:55:57 +0000
committerJim Laskey <jlaskey@mac.com>2006-11-29 16:55:57 +0000
commit36729ddd23fe51e10eabfc7e8ac4d4635a0b7935 (patch)
treebe617035a2b41c81e4a8be7b6f690d6a36f59502 /lib/CodeGen/DwarfWriter.cpp
parent619965d32e2cb961cc315aaece2e32f53f236784 (diff)
Eliminate unnecessary scopes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32020 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/DwarfWriter.cpp')
-rw-r--r--lib/CodeGen/DwarfWriter.cpp48
1 files changed, 27 insertions, 21 deletions
diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp
index 549abf0ec4..f5c854336b 100644
--- a/lib/CodeGen/DwarfWriter.cpp
+++ b/lib/CodeGen/DwarfWriter.cpp
@@ -1872,7 +1872,8 @@ private:
/// ConstructScope - Construct the components of a scope.
///
void ConstructScope(DebugScope *ParentScope,
- DIE *ParentDie, CompileUnit *Unit) {
+ unsigned ParentStartID, unsigned ParentEndID,
+ DIE *ParentDie, CompileUnit *Unit) {
// Add variables to scope.
std::vector<DebugVariable *> &Variables = ParentScope->getVariables();
for (unsigned i = 0, N = Variables.size(); i < N; ++i) {
@@ -1895,27 +1896,32 @@ private:
if (StartID == EndID && StartID != 0) continue;
if (Scope->getScopes().empty() && Scope->getVariables().empty()) continue;
- DIE *ScopeDie = new DIE(DW_TAG_lexical_block);
-
- // Add the scope bounds.
- if (StartID) {
- AddLabel(ScopeDie, DW_AT_low_pc, DW_FORM_addr,
- DWLabel("loc", StartID));
- } else {
- AddLabel(ScopeDie, DW_AT_low_pc, DW_FORM_addr,
- DWLabel("func_begin", SubprogramCount));
- }
- if (EndID) {
- AddLabel(ScopeDie, DW_AT_high_pc, DW_FORM_addr,
- DWLabel("loc", EndID));
+ if (StartID == ParentStartID && EndID == ParentEndID) {
+ // Just add stuff to the parent scope.
+ ConstructScope(Scope, ParentStartID, ParentEndID, ParentDie, Unit);
} else {
- AddLabel(ScopeDie, DW_AT_high_pc, DW_FORM_addr,
- DWLabel("func_end", SubprogramCount));
+ DIE *ScopeDie = new DIE(DW_TAG_lexical_block);
+
+ // Add the scope bounds.
+ if (StartID) {
+ AddLabel(ScopeDie, DW_AT_low_pc, DW_FORM_addr,
+ DWLabel("loc", StartID));
+ } else {
+ AddLabel(ScopeDie, DW_AT_low_pc, DW_FORM_addr,
+ DWLabel("func_begin", SubprogramCount));
+ }
+ if (EndID) {
+ AddLabel(ScopeDie, DW_AT_high_pc, DW_FORM_addr,
+ DWLabel("loc", EndID));
+ } else {
+ AddLabel(ScopeDie, DW_AT_high_pc, DW_FORM_addr,
+ DWLabel("func_end", SubprogramCount));
+ }
+
+ // Add the scope contents.
+ ConstructScope(Scope, StartID, EndID, ScopeDie, Unit);
+ ParentDie->AddChild(ScopeDie);
}
-
- // Add the scope contents.
- ConstructScope(Scope, ScopeDie, Unit);
- ParentDie->AddChild(ScopeDie);
}
}
@@ -1943,7 +1949,7 @@ private:
MachineLocation Location(RI->getFrameRegister(*MF));
AddAddress(SPDie, DW_AT_frame_base, Location);
- ConstructScope(RootScope, SPDie, Unit);
+ ConstructScope(RootScope, 0, 0, SPDie, Unit);
}
/// EmitInitial - Emit initial Dwarf declarations. This is necessary for cc