r220408 - DebugInfo: Omit scopes in -gmlt to reduce metadata size (on disk and in memory)
David Blaikie
dblaikie at gmail.com
Wed Oct 22 12:34:33 PDT 2014
Author: dblaikie
Date: Wed Oct 22 14:34:33 2014
New Revision: 220408
URL: http://llvm.org/viewvc/llvm-project?rev=220408&view=rev
Log:
DebugInfo: Omit scopes in -gmlt to reduce metadata size (on disk and in memory)
I haven't done any actual impact analysis of this change as it's a
strict improvement, but I'd be curious to know how much it helps.
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGen/debug-info-scope.c
cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp
cfe/trunk/test/CodeGenObjC/catch-lexical-block.m
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=220408&r1=220407&r2=220408&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Oct 22 14:34:33 2014
@@ -2606,13 +2606,16 @@ void CGDebugInfo::EmitLexicalBlockStart(
// Set our current location.
setLocation(Loc);
- // Create a new lexical block and push it on the stack.
- CreateLexicalBlock(Loc);
-
// Emit a line table change for the current location inside the new scope.
Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(getLineNumber(Loc),
getColumnNumber(Loc),
LexicalBlockStack.back()));
+
+ if (DebugKind <= CodeGenOptions::DebugLineTablesOnly)
+ return;
+
+ // Create a new lexical block and push it on the stack.
+ CreateLexicalBlock(Loc);
}
/// EmitLexicalBlockEnd - Constructs the debug code for exiting a declarative
@@ -2624,6 +2627,9 @@ void CGDebugInfo::EmitLexicalBlockEnd(CG
// Provide an entry in the line table for the end of the block.
EmitLocation(Builder, Loc);
+ if (DebugKind <= CodeGenOptions::DebugLineTablesOnly)
+ return;
+
LexicalBlockStack.pop_back();
}
@@ -2634,8 +2640,11 @@ void CGDebugInfo::EmitFunctionEnd(CGBuil
assert(RCount <= LexicalBlockStack.size() && "Region stack mismatch");
// Pop all regions for this function.
- while (LexicalBlockStack.size() != RCount)
- EmitLexicalBlockEnd(Builder, CurLoc);
+ while (LexicalBlockStack.size() != RCount) {
+ // Provide an entry in the line table for the end of the block.
+ EmitLocation(Builder, CurLoc);
+ LexicalBlockStack.pop_back();
+ }
FnBeginRegionCount.pop_back();
}
Modified: cfe/trunk/test/CodeGen/debug-info-scope.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-scope.c?rev=220408&r1=220407&r2=220408&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/debug-info-scope.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-scope.c Wed Oct 22 14:34:33 2014
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -g -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -gline-tables-only -emit-llvm < %s | FileCheck --check-prefix=GMLT %s
// Two variables with same name in separate scope.
// Radar 8330217.
int main() {
@@ -6,10 +7,21 @@ int main() {
int k = 0;
// CHECK: DW_TAG_auto_variable ] [i]
// CHECK-NEXT: DW_TAG_lexical_block
+
+// FIXME: Looks like we don't actually need both these lexical blocks (disc 2
+// just refers to disc 1, nothing actually uses disc 2).
+// GMLT-NOT: DW_TAG_lexical_block
+// GMLT: "0xb\002", {{.*}}} ; [ DW_TAG_lexical_block ]
+// GMLT-NOT: DW_TAG_lexical_block
+// GMLT: "0xb\001", {{.*}}} ; [ DW_TAG_lexical_block ]
+// Make sure we don't have any more lexical blocks because we don't need them in
+// -gmlt.
+// GMLT-NOT: DW_TAG_lexical_block
for (int i = 0; i < 10; i++)
j++;
// CHECK: DW_TAG_auto_variable ] [i]
// CHECK-NEXT: DW_TAG_lexical_block
+// GMLT-NOT: DW_TAG_lexical_block
for (int i = 0; i < 10; i++)
k++;
return 0;
Modified: cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp?rev=220408&r1=220407&r2=220408&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp Wed Oct 22 14:34:33 2014
@@ -39,9 +39,9 @@ void func() {
// FIXME: Do not include scopes that have only other scopes (and no variables
// or using declarations) as direct children, they just waste
// space/relocations/etc.
- // CHECK: [[FOR_BODY:![0-9]+]] = metadata !{metadata !"0xb\00[[@LINE-4]]\00{{.*}}", metadata !{{[0-9]+}}, metadata [[FOR]]} ; [ DW_TAG_lexical_block ]
- // CHECK: = metadata !{metadata !"0x100\00{{.*}}", metadata [[FOR_COMPOUND:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [b] [line [[@LINE+2]]]
- // CHECK: [[FOR_COMPOUND]] = metadata !{metadata !"0xb\00[[@LINE-6]]\00{{.*}}", metadata !{{[0-9]+}}, metadata [[FOR_BODY]]} ; [ DW_TAG_lexical_block ]
+ // CHECK: = metadata !{metadata !"0x100\00{{.*}}", metadata [[FOR_COMPOUND:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [b] [line [[@LINE+3]]]
+ // CHECK: [[FOR_COMPOUND]] = metadata !{metadata !"0xb\00[[@LINE-5]]\00{{.*}}", metadata !{{[0-9]+}}, metadata [[FOR_BODY:![0-9]+]]} ; [ DW_TAG_lexical_block ]
+ // CHECK: [[FOR_BODY]] = metadata !{metadata !"0xb\00[[@LINE-6]]\00{{.*}}", metadata !{{[0-9]+}}, metadata [[FOR]]} ; [ DW_TAG_lexical_block ]
bool b = i % 2;
}
Modified: cfe/trunk/test/CodeGenObjC/catch-lexical-block.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/catch-lexical-block.m?rev=220408&r1=220407&r2=220408&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/catch-lexical-block.m (original)
+++ cfe/trunk/test/CodeGenObjC/catch-lexical-block.m Wed Oct 22 14:34:33 2014
@@ -10,6 +10,6 @@ void f0() {
// We should have 3 lexical blocks here at the moment, including one
// for the catch block.
// CHECK: lexical_block
-// CHECK: lexical_block
// CHECK: auto_variable
// CHECK: lexical_block
+// CHECK: lexical_block
More information about the cfe-commits
mailing list