Skip to content

Commit

Permalink
[DebugInfo] Inline for without DebugLocation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gramanas committed Jun 21, 2018
1 parent 547adca commit dfe8fe5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clang/lib/CodeGen/CGExprScalar.cpp
Expand Up @@ -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");
}
Expand Down
13 changes: 13 additions & 0 deletions 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

0 comments on commit dfe8fe5

Please sign in to comment.