summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp19
-rw-r--r--clang/test/CodeGen/debug-info-scope.c12
-rw-r--r--clang/test/CodeGenCXX/debug-info-scope.cpp6
-rw-r--r--clang/test/CodeGenObjC/catch-lexical-block.m2
4 files changed, 30 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 489a2032726..0d662372a11 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2606,13 +2606,16 @@ void CGDebugInfo::EmitLexicalBlockStart(CGBuilderTy &Builder,
// 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(CGBuilderTy &Builder,
// 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(CGBuilderTy &Builder) {
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();
}
diff --git a/clang/test/CodeGen/debug-info-scope.c b/clang/test/CodeGen/debug-info-scope.c
index 9decaeafd50..d84fafd018d 100644
--- a/clang/test/CodeGen/debug-info-scope.c
+++ b/clang/test/CodeGen/debug-info-scope.c
@@ -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;
diff --git a/clang/test/CodeGenCXX/debug-info-scope.cpp b/clang/test/CodeGenCXX/debug-info-scope.cpp
index 6fd628cfe49..8957e60d7c7 100644
--- a/clang/test/CodeGenCXX/debug-info-scope.cpp
+++ b/clang/test/CodeGenCXX/debug-info-scope.cpp
@@ -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;
}
diff --git a/clang/test/CodeGenObjC/catch-lexical-block.m b/clang/test/CodeGenObjC/catch-lexical-block.m
index 618d3a22322..d5aeee143be 100644
--- a/clang/test/CodeGenObjC/catch-lexical-block.m
+++ b/clang/test/CodeGenObjC/catch-lexical-block.m
@@ -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
OpenPOWER on IntegriCloud