[llvm] 2067e60 - [VPlan] Manage VPWidenPointerInduction debug location via recipe.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 15 06:41:28 PST 2024
Author: Florian Hahn
Date: 2024-12-15T14:41:07Z
New Revision: 2067e604a49d49ce054d61a0109ec12a724e3db2
URL: https://github.com/llvm/llvm-project/commit/2067e604a49d49ce054d61a0109ec12a724e3db2
DIFF: https://github.com/llvm/llvm-project/commit/2067e604a49d49ce054d61a0109ec12a724e3db2.diff
LOG: [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.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
llvm/test/Transforms/LoopVectorize/preserve-dbg-loc-and-loop-metadata.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 6ac73af90ffa01..d37e8264120040 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8466,7 +8466,8 @@ VPHeaderPHIRecipe *VPRecipeBuilder::tryToOptimizeInductionPHI(
[&](ElementCount VF) {
return CM.isScalarAfterVectorization(Phi, VF);
},
- Range));
+ Range),
+ Phi->getDebugLoc());
}
return nullptr;
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index afedbccf5ae34f..e8902009455ef4 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -2211,8 +2211,8 @@ class VPWidenPointerInductionRecipe : public VPHeaderPHIRecipe,
/// Start.
VPWidenPointerInductionRecipe(PHINode *Phi, VPValue *Start, VPValue *Step,
const InductionDescriptor &IndDesc,
- bool IsScalarAfterVectorization)
- : VPHeaderPHIRecipe(VPDef::VPWidenPointerInductionSC, Phi),
+ bool IsScalarAfterVectorization, DebugLoc DL)
+ : VPHeaderPHIRecipe(VPDef::VPWidenPointerInductionSC, Phi, nullptr, DL),
IndDesc(IndDesc),
IsScalarAfterVectorization(IsScalarAfterVectorization) {
addOperand(Start);
@@ -2224,7 +2224,7 @@ class VPWidenPointerInductionRecipe : public VPHeaderPHIRecipe,
VPWidenPointerInductionRecipe *clone() override {
return new VPWidenPointerInductionRecipe(
cast<PHINode>(getUnderlyingInstr()), getOperand(0), getOperand(1),
- IndDesc, IsScalarAfterVectorization);
+ IndDesc, IsScalarAfterVectorization, getDebugLoc());
}
VP_CLASSOF_IMPL(VPDef::VPWidenPointerInductionSC)
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 2f7047beaa48a5..022c0f5a173a6b 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -3182,6 +3182,7 @@ void VPWidenPointerInductionRecipe::execute(VPTransformState &State) {
NewPointerPhi = PHINode::Create(ScStValueType, 2, "pointer.phi",
CanonicalIV->getIterator());
NewPointerPhi->addIncoming(ScalarStartValue, VectorPH);
+ NewPointerPhi->setDebugLoc(getDebugLoc());
} else {
// The recipe has been unrolled. In that case, fetch the single pointer phi
// shared among all unrolled parts of the recipe.
diff --git a/llvm/test/Transforms/LoopVectorize/preserve-dbg-loc-and-loop-metadata.ll b/llvm/test/Transforms/LoopVectorize/preserve-dbg-loc-and-loop-metadata.ll
index 7da389a4fb2d21..2eec61b859f13e 100644
--- a/llvm/test/Transforms/LoopVectorize/preserve-dbg-loc-and-loop-metadata.ll
+++ b/llvm/test/Transforms/LoopVectorize/preserve-dbg-loc-and-loop-metadata.ll
@@ -31,13 +31,15 @@ for.end: ; preds = %for.body
ret void
}
-; FIXME: Missing debug location for pointer induction in vector loop
define void @widen_ptr_induction_dbg(ptr %start, ptr %end) {
; DEBUGLOC-LABEL: define void @widen_ptr_induction_dbg(
; DEBUGLOC: vector.body:
-; DEBUGLOC-NOT: = phi ptr {{.+}}, !dbg
+; DEBUGLOC-NEXT: = phi ptr {{.+}}, !dbg ![[PTRIVLOC:[0-9]+]]
; DEBUGLOC: = phi i64
;
+; DEBUGLOC: loop:
+; DEBUGLOC-NEXT: = phi ptr {{.+}}, !dbg ![[PTRIVLOC]]
+;
entry:
br label %loop
@@ -59,3 +61,4 @@ exit:
; CHECK: !{!"llvm.loop.isvectorized", i32 1}
; DEBUGLOC: ![[RESUMELOC]] = !DILocation(line: 2
+; DEBUGLOC: ![[PTRIVLOC]] = !DILocation(line: 12
More information about the llvm-commits
mailing list