Skip to content

Commit 59831d6

Browse files
committed
[LV] Align debug location of the widen-phi to the orignal phi.
This patch align the debug location of the widen-phi to the debug location of original phi.
1 parent 79231a8 commit 59831d6

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,9 +2310,10 @@ class VPWidenPHIRecipe : public VPSingleDefRecipe {
23102310
SmallVector<VPBasicBlock *, 2> IncomingBlocks;
23112311

23122312
public:
2313-
/// Create a new VPWidenPHIRecipe for \p Phi with start value \p Start.
2314-
VPWidenPHIRecipe(PHINode *Phi, VPValue *Start = nullptr)
2315-
: VPSingleDefRecipe(VPDef::VPWidenPHISC, ArrayRef<VPValue *>(), Phi) {
2313+
/// Create a new VPWidenPHIRecipe for \p Phi with start value \p Start and
2314+
/// debug location \p DL.
2315+
VPWidenPHIRecipe(PHINode *Phi, VPValue *Start = nullptr, DebugLoc DL = {})
2316+
: VPSingleDefRecipe(VPDef::VPWidenPHISC, ArrayRef<VPValue *>(), Phi, DL) {
23162317
if (Start)
23172318
addOperand(Start);
23182319
}

llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ void PlainCFGBuilder::createVPInstructionsForVPBB(VPBasicBlock *VPBB,
308308
// Phi node's operands may have not been visited at this point. We create
309309
// an empty VPInstruction that we will fix once the whole plain CFG has
310310
// been built.
311-
NewVPV = new VPWidenPHIRecipe(Phi);
311+
NewVPV = new VPWidenPHIRecipe(Phi, nullptr, Phi->getDebugLoc());
312312
VPBB->appendRecipe(cast<VPWidenPHIRecipe>(NewVPV));
313313
PhisToFix.push_back(Phi);
314314
} else {

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3547,6 +3547,7 @@ void VPWidenPHIRecipe::execute(VPTransformState &State) {
35473547
assert(EnableVPlanNativePath &&
35483548
"Non-native vplans are not expected to have VPWidenPHIRecipes.");
35493549

3550+
State.setDebugLocFrom(getDebugLoc());
35503551
Value *Op0 = State.get(getOperand(0));
35513552
Type *VecTy = Op0->getType();
35523553
Value *VecPhi = State.Builder.CreatePHI(VecTy, 2, "vec.phi");

llvm/test/Transforms/LoopVectorize/dbg-outer-loop-vect.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ define void @foo(ptr %h) !dbg !4 {
1515
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[FOR_COND_CLEANUP32:%.*]] ]
1616
; CHECK-NEXT: br label [[FOR_COND5_PREHEADER1:%.*]], !dbg [[DBG21]]
1717
; CHECK: for.cond5.preheader1:
18-
; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <4 x i64> [ zeroinitializer, [[VECTOR_BODY]] ], [ [[TMP4:%.*]], [[FOR_COND5_PREHEADER1]] ], !dbg [[DBG21]]
19-
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i32, ptr [[H]], <4 x i64> [[VEC_PHI]], !dbg [[DBG21]]
18+
; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <4 x i64> [ zeroinitializer, [[VECTOR_BODY]] ], [ [[TMP4:%.*]], [[FOR_COND5_PREHEADER1]] ]
19+
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i32, ptr [[H]], <4 x i64> [[VEC_PHI]]
2020
; CHECK-NEXT: call void @llvm.masked.scatter.v4i32.v4p0(<4 x i32> zeroinitializer, <4 x ptr> [[TMP0]], i32 4, <4 x i1> splat (i1 true)), !dbg [[DBG22:![0-9]+]]
2121
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr i32, <4 x ptr> [[TMP0]], i64 1, !dbg [[DBG22]]
2222
; CHECK-NEXT: call void @llvm.masked.scatter.v4i32.v4p0(<4 x i32> splat (i32 1), <4 x ptr> [[TMP1]], i32 4, <4 x i1> splat (i1 true)), !dbg [[DBG22]]

0 commit comments

Comments
 (0)