r335255 - [DebugInfo] Inline for without DebugLocation
Anastasis Grammenos via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 21 09:53:48 PDT 2018
Author: gramanas
Date: Thu Jun 21 09:53:48 2018
New Revision: 335255
URL: http://llvm.org/viewvc/llvm-project?rev=335255&view=rev
Log:
[DebugInfo] Inline for without DebugLocation
Summary:
This test is a strip down version of a function inside the
amalgamated sqlite source. When converted to IR clang produces
a phi instruction without debug location.
This patch fixes the above issue.
Differential Revision: https://reviews.llvm.org/D47720
Added:
cfe/trunk/test/CodeGen/debug-info-inline-for.c
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=335255&r1=335254&r2=335255&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Jun 21 09:53:48 2018
@@ -3431,6 +3431,12 @@ Value *ScalarExprEmitter::VisitBinLAnd(c
// 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");
}
Added: cfe/trunk/test/CodeGen/debug-info-inline-for.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-inline-for.c?rev=335255&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/debug-info-inline-for.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-inline-for.c Thu Jun 21 09:53:48 2018
@@ -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
More information about the cfe-commits
mailing list