[PATCH] Proposed fix for PR23076 (conditional branch debug line info)

Wolfgang Pieb wolfgang_pieb at playstation.sony.com
Wed Apr 15 15:59:09 PDT 2015


Sorry for the delay. David's feedback made me realize that by associating ALL conditional branches with the same line number as the condition my previous proposal would have degraded the stepping experience for conditional expressions. We would no longer step to the line with the ‘&&’ in the above example after evaluating ‘a’.

Instead, we associate only the conditional expression’s final branch with the condition’s end location to avoid stepping back to the ‘if’.


http://reviews.llvm.org/D8822

Files:
  lib/CodeGen/CGStmt.cpp
  test/CodeGenCXX/debug-info-line.cpp

Index: lib/CodeGen/CGStmt.cpp
===================================================================
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -549,7 +549,10 @@
   if (S.getElse())
     ElseBlock = createBasicBlock("if.else");
 
-  EmitBranchOnBoolExpr(S.getCond(), ThenBlock, ElseBlock, Cnt.getCount());
+  {
+    ApplyDebugLocation DL(*this, S.getCond()->getSourceRange().getEnd());
+    EmitBranchOnBoolExpr(S.getCond(), ThenBlock, ElseBlock, Cnt.getCount());
+  }
 
   // Emit the 'then' code.
   EmitBlock(ThenBlock);
Index: test/CodeGenCXX/debug-info-line.cpp
===================================================================
--- test/CodeGenCXX/debug-info-line.cpp
+++ test/CodeGenCXX/debug-info-line.cpp
@@ -217,6 +217,8 @@
 void f18(int a, int b) {
 // CHECK: icmp {{.*}}, !dbg [[DBG_F18_1:![0-9]*]]
 // CHECK: br {{.*}}, !dbg [[DBG_F18_2:![0-9]*]]
+// CHECK: icmp {{.*}}, !dbg [[DBG_F18_3:![0-9]*]]
+// CHECK: br {{.*}}, !dbg [[DBG_F18_3]]
 #line 2000
   if (a  //
       && //
@@ -228,6 +230,8 @@
 void f19(int a, int b) {
 // CHECK: icmp {{.*}}, !dbg [[DBG_F19_1:![0-9]*]]
 // CHECK: br {{.*}}, !dbg [[DBG_F19_2:![0-9]*]]
+// CHECK: icmp {{.*}}, !dbg [[DBG_F19_3:![0-9]*]]
+// CHECK: br {{.*}}, !dbg [[DBG_F19_3]]
 #line 2100
   if (a  //
       || //
@@ -317,8 +321,10 @@
 // CHECK: [[DBG_F17]] = !MDLocation(line: 1900,
 // CHECK: [[DBG_F18_1]] = !MDLocation(line: 2000,
 // CHECK: [[DBG_F18_2]] = !MDLocation(line: 2001,
+// CHECK: [[DBG_F18_3]] = !MDLocation(line: 2002,
 // CHECK: [[DBG_F19_1]] = !MDLocation(line: 2100,
 // CHECK: [[DBG_F19_2]] = !MDLocation(line: 2101,
+// CHECK: [[DBG_F19_3]] = !MDLocation(line: 2102,
 // CHECK: [[DBG_F20_1]] = !MDLocation(line: 2200,
 // CHECK: [[DBG_F23]] = !MDLocation(line: 2500,
 // CHECK: [[DBG_F24]] = !MDLocation(line: 2600,

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8822.23807.patch
Type: text/x-patch
Size: 1803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150415/a8bff340/attachment.bin>


More information about the cfe-commits mailing list