[PATCH] D59417: [GVN] Add default debug location when constructing PHI nodes
Stephen Tozer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 15 09:56:19 PDT 2019
StephenTozer updated this revision to Diff 190844.
StephenTozer added a comment.
Update comment to give more context to the use of a Line 0 debug location.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59417/new/
https://reviews.llvm.org/D59417
Files:
llvm/lib/Transforms/Utils/SSAUpdater.cpp
llvm/test/Transforms/GVN/debugloc.ll
Index: llvm/test/Transforms/GVN/debugloc.ll
===================================================================
--- llvm/test/Transforms/GVN/debugloc.ll
+++ llvm/test/Transforms/GVN/debugloc.ll
@@ -1,10 +1,13 @@
; RUN: opt < %s -gvn -S | FileCheck %s
+; CHECK-LABEL: @foo(
+; CHECK-SAME: !dbg ![[FNDBG:[0-9]+]]
; CHECK: {{^}}for.body:
; CHECK-NEXT: [[VREG1:%[^ ]+]] = phi{{.*}}[[VREG2:%[^ ]+]],{{.*}}%.sink,
-; CHECK-NOT: !dbg
+; CHECK: !dbg ![[DBG:[0-9]+]]
; CHECK-SAME: {{$}}
; CHECK: {{^}}for.inc:
; CHECK-NEXT: [[VREG2]] = phi{{.*}}%inc,{{.*}}[[VREG1]]
+; CHECK: ![[DBG]] = !DILocation(line: 0, scope: ![[FNDBG]]
target triple = "x86_64-unknown-linux-gnu"
Index: llvm/lib/Transforms/Utils/SSAUpdater.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SSAUpdater.cpp
+++ llvm/lib/Transforms/Utils/SSAUpdater.cpp
@@ -19,6 +19,7 @@
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constants.h"
+#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
@@ -279,6 +280,12 @@
SSAUpdater *Updater) {
PHINode *PHI = PHINode::Create(Updater->ProtoType, NumPreds,
Updater->ProtoName, &BB->front());
+ // The PHI nodes created here may not have any reasonable mapping to the
+ // source code; use Line 0 as a default location.
+ if (BB->getParent()->getSubprogram()) {
+ PHI->setDebugLoc(DILocation::get(BB->getContext(), 0, 0,
+ BB->getParent()->getSubprogram()));
+ }
return PHI;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59417.190844.patch
Type: text/x-patch
Size: 1688 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190315/93f9f046/attachment.bin>
More information about the llvm-commits
mailing list