[cfe-commits] r160033 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CodeGenFunction.h test/CodeGen/debug-info-block-end.c

Eric Christopher echristo at apple.com
Tue Jul 10 18:49:27 PDT 2012


Author: echristo
Date: Tue Jul 10 20:49:26 2012
New Revision: 160033

URL: http://llvm.org/viewvc/llvm-project?rev=160033&view=rev
Log:
The end of a block doesn't necessarily need a line table entry unless
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

Added:
    cfe/trunk/test/CodeGen/debug-info-block-end.c
Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=160033&r1=160032&r2=160033&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Jul 10 20:49:26 2012
@@ -2135,10 +2135,6 @@
 /// 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();
 }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=160033&r1=160032&r2=160033&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Jul 10 20:49:26 2012
@@ -854,8 +854,11 @@
     /// 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 @@
     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;
       }

Added: cfe/trunk/test/CodeGen/debug-info-block-end.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-block-end.c?rev=160033&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/debug-info-block-end.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-block-end.c Tue Jul 10 20:49:26 2012
@@ -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





More information about the cfe-commits mailing list