]> granicus.if.org Git - clang/commitdiff
The end of a block doesn't necessarily need a line table entry unless
authorEric Christopher <echristo@apple.com>
Wed, 11 Jul 2012 01:49:26 +0000 (01:49 +0000)
committerEric Christopher <echristo@apple.com>
Wed, 11 Jul 2012 01:49:26 +0000 (01:49 +0000)
there's something going on there. Remove the unconditional line entry
and only add one if we're emitting cleanups (any other statements
would be handled normally).

Fixes rdar://9199234

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160033 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CodeGenFunction.h
test/CodeGen/debug-info-block-end.c [new file with mode: 0644]

index c604e5653916f4a663743b538e988defa7533af0..11a5ddc7ceb8bab19e185cae926aaffb7b2a0c0c 100644 (file)
@@ -2135,10 +2135,6 @@ void CGDebugInfo::EmitLexicalBlockStart(CGBuilderTy &Builder, SourceLocation Loc
 /// region - end of a DW_TAG_lexical_block.
 void CGDebugInfo::EmitLexicalBlockEnd(CGBuilderTy &Builder, SourceLocation Loc) {
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
-
-  // Provide an entry in the line table for the end of the block.
-  EmitLocation(Builder, Loc);
-
   LexicalBlockStack.pop_back();
 }
 
index b737a9ed7ab739d5a404967875ae36849af0a81a..8740fd06df7389b576afb581d7254fcc521910c9 100644 (file)
@@ -854,8 +854,11 @@ public:
     /// cleanups.
     ~LexicalScope() {
       if (PopDebugStack) {
-        CGDebugInfo *DI = CGF.getDebugInfo();
-        if (DI) DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd());
+        if (CGDebugInfo *DI = CGF.getDebugInfo()) {
+          if (RunCleanupsScope::requiresCleanups())
+            DI->EmitLocation(CGF.Builder, Range.getEnd());
+          DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd());
+        }
       }
     }
 
@@ -864,6 +867,8 @@ public:
     void ForceCleanup() {
       RunCleanupsScope::ForceCleanup();
       if (CGDebugInfo *DI = CGF.getDebugInfo()) {
+        if (RunCleanupsScope::requiresCleanups())
+          DI->EmitLocation(CGF.Builder, Range.getEnd());
         DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd());
         PopDebugStack = false;
       }
diff --git a/test/CodeGen/debug-info-block-end.c b/test/CodeGen/debug-info-block-end.c
new file mode 100644 (file)
index 0000000..72e8868
--- /dev/null
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -g -S -emit-llvm %s -o - | FileCheck %s
+
+int bar();
+
+int foo(int i) {
+  int j = 0;
+  if (i) {
+    j = bar();
+  }
+  else {
+    j = bar() + 2;
+  }
+  return j;
+}
+
+// Make sure we don't have a line table entry for a block with no cleanups.
+// CHECK-NOT: i32 9, i32 3, metadata