[llvm] [LV] Align debug location of the widen-phi to the original phi. (PR #120338)

Elvis Wang via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 19 00:21:48 PST 2024


================
@@ -2291,9 +2291,10 @@ class VPWidenPHIRecipe : public VPSingleDefRecipe {
   SmallVector<VPBasicBlock *, 2> IncomingBlocks;
 
 public:
-  /// Create a new VPWidenPHIRecipe for \p Phi with start value \p Start.
-  VPWidenPHIRecipe(PHINode *Phi, VPValue *Start = nullptr)
-      : VPSingleDefRecipe(VPDef::VPWidenPHISC, ArrayRef<VPValue *>(), Phi) {
+  /// Create a new VPWidenPHIRecipe for \p Phi with start value \p Start and
+  /// debug location \p DL.
+  VPWidenPHIRecipe(PHINode *Phi, VPValue *Start = nullptr, DebugLoc DL = {})
+      : VPSingleDefRecipe(VPDef::VPWidenPHISC, ArrayRef<VPValue *>(), Phi, DL) {
----------------
ElvisWang123 wrote:

Good point!  It is fine to use `phi->getDebugLoc()`  since we don't construct VPWidenPHIRecipe with `nullptr` currently. Do we guarantee the `phi` must not be a `nullptr`?

I implemented #120054 similar to your suggested method initially but found that we construct `VPReductionRecipe` in unit-test with `nullptr`. And I opened #120053 to prevent nullptr when create VPReductionRecipe in unit-test.
@fhahn suggested that we could pass the debug information independent of underlying instruction (https://github.com/llvm/llvm-project/pull/120054#discussion_r1886511312) to prevent unit-test changes.

https://github.com/llvm/llvm-project/pull/120338


More information about the llvm-commits mailing list