Skip to content

Commit 2067e60

Browse files
committed
[VPlan] Manage VPWidenPointerInduction debug location via recipe.
Update VPWidenPointerInduction to manage its debug location via recipe. This makes sure we emit a proper debug location for VPWidenPointerInductionRecipes.
1 parent 6c98f70 commit 2067e60

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8466,7 +8466,8 @@ VPHeaderPHIRecipe *VPRecipeBuilder::tryToOptimizeInductionPHI(
84668466
[&](ElementCount VF) {
84678467
return CM.isScalarAfterVectorization(Phi, VF);
84688468
},
8469-
Range));
8469+
Range),
8470+
Phi->getDebugLoc());
84708471
}
84718472
return nullptr;
84728473
}

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,8 +2211,8 @@ class VPWidenPointerInductionRecipe : public VPHeaderPHIRecipe,
22112211
/// Start.
22122212
VPWidenPointerInductionRecipe(PHINode *Phi, VPValue *Start, VPValue *Step,
22132213
const InductionDescriptor &IndDesc,
2214-
bool IsScalarAfterVectorization)
2215-
: VPHeaderPHIRecipe(VPDef::VPWidenPointerInductionSC, Phi),
2214+
bool IsScalarAfterVectorization, DebugLoc DL)
2215+
: VPHeaderPHIRecipe(VPDef::VPWidenPointerInductionSC, Phi, nullptr, DL),
22162216
IndDesc(IndDesc),
22172217
IsScalarAfterVectorization(IsScalarAfterVectorization) {
22182218
addOperand(Start);
@@ -2224,7 +2224,7 @@ class VPWidenPointerInductionRecipe : public VPHeaderPHIRecipe,
22242224
VPWidenPointerInductionRecipe *clone() override {
22252225
return new VPWidenPointerInductionRecipe(
22262226
cast<PHINode>(getUnderlyingInstr()), getOperand(0), getOperand(1),
2227-
IndDesc, IsScalarAfterVectorization);
2227+
IndDesc, IsScalarAfterVectorization, getDebugLoc());
22282228
}
22292229

22302230
VP_CLASSOF_IMPL(VPDef::VPWidenPointerInductionSC)

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,6 +3182,7 @@ void VPWidenPointerInductionRecipe::execute(VPTransformState &State) {
31823182
NewPointerPhi = PHINode::Create(ScStValueType, 2, "pointer.phi",
31833183
CanonicalIV->getIterator());
31843184
NewPointerPhi->addIncoming(ScalarStartValue, VectorPH);
3185+
NewPointerPhi->setDebugLoc(getDebugLoc());
31853186
} else {
31863187
// The recipe has been unrolled. In that case, fetch the single pointer phi
31873188
// shared among all unrolled parts of the recipe.

llvm/test/Transforms/LoopVectorize/preserve-dbg-loc-and-loop-metadata.ll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ for.end: ; preds = %for.body
3131
ret void
3232
}
3333

34-
; FIXME: Missing debug location for pointer induction in vector loop
3534
define void @widen_ptr_induction_dbg(ptr %start, ptr %end) {
3635
; DEBUGLOC-LABEL: define void @widen_ptr_induction_dbg(
3736
; DEBUGLOC: vector.body:
38-
; DEBUGLOC-NOT: = phi ptr {{.+}}, !dbg
37+
; DEBUGLOC-NEXT: = phi ptr {{.+}}, !dbg ![[PTRIVLOC:[0-9]+]]
3938
; DEBUGLOC: = phi i64
4039
;
40+
; DEBUGLOC: loop:
41+
; DEBUGLOC-NEXT: = phi ptr {{.+}}, !dbg ![[PTRIVLOC]]
42+
;
4143
entry:
4244
br label %loop
4345

@@ -59,3 +61,4 @@ exit:
5961
; CHECK: !{!"llvm.loop.isvectorized", i32 1}
6062

6163
; DEBUGLOC: ![[RESUMELOC]] = !DILocation(line: 2
64+
; DEBUGLOC: ![[PTRIVLOC]] = !DILocation(line: 12

0 commit comments

Comments
 (0)