[PATCH] D47720: [DebugInfo] Inline for without DebugLocation

Anastasis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 21 09:58:22 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL335255: [DebugInfo] Inline for without DebugLocation (authored by gramanas, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47720

Files:
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/test/CodeGen/debug-info-inline-for.c


Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -3431,6 +3431,12 @@
   // Insert an entry into the phi node for the edge with the value of RHSCond.
   PN->addIncoming(RHSCond, RHSBlock);
 
+  // Artificial location to preserve the scope information
+  {
+    auto NL = ApplyDebugLocation::CreateArtificial(CGF);
+    PN->setDebugLoc(Builder.getCurrentDebugLocation());
+  }
+
   // ZExt result to int.
   return Builder.CreateZExtOrBitCast(PN, ResTy, "land.ext");
 }
Index: cfe/trunk/test/CodeGen/debug-info-inline-for.c
===================================================================
--- cfe/trunk/test/CodeGen/debug-info-inline-for.c
+++ cfe/trunk/test/CodeGen/debug-info-inline-for.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+// Check that clang emits Debug location in the phi instruction
+
+int func(int n) {
+  int a;
+  for(a = 10; a>0 && n++; a--);
+  return n;
+}
+
+// CHECK: land.end:
+// CHECK-NEXT: {{.*}} = phi i1 {{.*}} !dbg ![[DbgLoc:[0-9]+]]
+
+// CHECK: ![[DbgLoc]] = !DILocation(line: 0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47720.152332.patch
Type: text/x-patch
Size: 1220 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180621/ab081111/attachment.bin>


More information about the llvm-commits mailing list