Ka-Ka created this revision.
Herald added a subscriber: aprantl.

As no stoppoint was generated the attributed statements got faulty debug 
locations.


https://reviews.llvm.org/D37428

Files:
  lib/CodeGen/CGStmt.cpp
  test/CodeGen/debug-info-attributed-stmt.c


Index: test/CodeGen/debug-info-attributed-stmt.c
===================================================================
--- /dev/null
+++ test/CodeGen/debug-info-attributed-stmt.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-unk-unk -debug-info-kind=limited -emit-llvm 
%s -o - | FileCheck %s
+int data[50] = { 0 };
+
+void foo()
+{
+    int i = 0;
+    int x = 7;
+#pragma nounroll
+    while (i < 50)
+    {
+        data[i] = i;
+        ++i;
+    }
+
+// CHECK: br label %while.cond, !dbg ![[NUM:[0-9]+]]
+// CHECK: br i1 %cmp, label %while.body, label %while.end, !dbg ![[NUM]]
+// CHECK: br label %while.cond, !dbg ![[NUM]], !llvm.loop
+// CHECK: ![[NUM]] = !DILocation(line: 9, scope: !14)
+}
Index: lib/CodeGen/CGStmt.cpp
===================================================================
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -556,6 +556,10 @@
 
 void CodeGenFunction::EmitAttributedStmt(const AttributedStmt &S) {
   const Stmt *SubStmt = S.getSubStmt();
+
+  // Generate a stoppoint if we are emitting debug info.
+  EmitStopPoint(SubStmt);
+
   switch (SubStmt->getStmtClass()) {
   case Stmt::DoStmtClass:
     EmitDoStmt(cast<DoStmt>(*SubStmt), S.getAttrs());


Index: test/CodeGen/debug-info-attributed-stmt.c
===================================================================
--- /dev/null
+++ test/CodeGen/debug-info-attributed-stmt.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-unk-unk -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
+int data[50] = { 0 };
+
+void foo()
+{
+    int i = 0;
+    int x = 7;
+#pragma nounroll
+    while (i < 50)
+    {
+        data[i] = i;
+        ++i;
+    }
+
+// CHECK: br label %while.cond, !dbg ![[NUM:[0-9]+]]
+// CHECK: br i1 %cmp, label %while.body, label %while.end, !dbg ![[NUM]]
+// CHECK: br label %while.cond, !dbg ![[NUM]], !llvm.loop
+// CHECK: ![[NUM]] = !DILocation(line: 9, scope: !14)
+}
Index: lib/CodeGen/CGStmt.cpp
===================================================================
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -556,6 +556,10 @@
 
 void CodeGenFunction::EmitAttributedStmt(const AttributedStmt &S) {
   const Stmt *SubStmt = S.getSubStmt();
+
+  // Generate a stoppoint if we are emitting debug info.
+  EmitStopPoint(SubStmt);
+
   switch (SubStmt->getStmtClass()) {
   case Stmt::DoStmtClass:
     EmitDoStmt(cast<DoStmt>(*SubStmt), S.getAttrs());
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to