[PATCH] D37428: Debug info: Fixed faulty debug locations for attributed statements

Karl-Johan Karlsson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 3 10:35:19 PDT 2017


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());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37428.113708.patch
Type: text/x-patch
Size: 1197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170903/b9b49760/attachment.bin>


More information about the cfe-commits mailing list