summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnastasis Grammenos <anastasis.gramm2@gmail.com>2018-06-21 16:53:48 +0000
committerAnastasis Grammenos <anastasis.gramm2@gmail.com>2018-06-21 16:53:48 +0000
commitdfe8fe503cbef3164d8cf3ff2eff5c7b76fb548c (patch)
tree636c4b497ff450b79dac9e8879d8989ea057e5ea
parent547adcaaac64d2f4802e194c38309ad4e48a158f (diff)
downloadbcm5719-llvm-dfe8fe503cbef3164d8cf3ff2eff5c7b76fb548c.tar.gz
bcm5719-llvm-dfe8fe503cbef3164d8cf3ff2eff5c7b76fb548c.zip
[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 llvm-svn: 335255
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp6
-rw-r--r--clang/test/CodeGen/debug-info-inline-for.c13
2 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index f4c0c75c256..10c59a2cb87 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -3431,6 +3431,12 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
// 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");
}
diff --git a/clang/test/CodeGen/debug-info-inline-for.c b/clang/test/CodeGen/debug-info-inline-for.c
new file mode 100644
index 00000000000..55066b28a1f
--- /dev/null
+++ b/clang/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
OpenPOWER on IntegriCloud