Skip to content

Commit dc5c061

Browse files
committed
[VPlan] Set debug loc for VPReduction/VPWidenPHI/VPWidenIntrinsicRecipe.
This patch add missing debug location for VPReduction/VPWidenIntrinsicRecipe and align the debug location for VPWidenPHIRecipe to its scalar counterpart.
1 parent 7508a6d commit dc5c061

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags {
16731673
VPWidenIntrinsicRecipe(Intrinsic::ID VectorIntrinsicID,
16741674
ArrayRef<VPValue *> CallArguments, Type *Ty,
16751675
DebugLoc DL = {})
1676-
: VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments),
1676+
: VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments, DL),
16771677
VectorIntrinsicID(VectorIntrinsicID), ResultTy(Ty) {
16781678
LLVMContext &Ctx = Ty->getContext();
16791679
AttributeList Attrs = Intrinsic::getAttributes(Ctx, VectorIntrinsicID);
@@ -2313,7 +2313,8 @@ class VPWidenPHIRecipe : public VPSingleDefRecipe {
23132313
public:
23142314
/// Create a new VPWidenPHIRecipe for \p Phi with start value \p Start.
23152315
VPWidenPHIRecipe(PHINode *Phi, VPValue *Start = nullptr)
2316-
: VPSingleDefRecipe(VPDef::VPWidenPHISC, ArrayRef<VPValue *>(), Phi) {
2316+
: VPSingleDefRecipe(VPDef::VPWidenPHISC, ArrayRef<VPValue *>(), Phi,
2317+
Phi->getDebugLoc()) {
23172318
if (Start)
23182319
addOperand(Start);
23192320
}
@@ -2615,7 +2616,8 @@ class VPReductionRecipe : public VPSingleDefRecipe {
26152616
VPReductionRecipe(const unsigned char SC, const RecurrenceDescriptor &R,
26162617
Instruction *I, ArrayRef<VPValue *> Operands,
26172618
VPValue *CondOp, bool IsOrdered)
2618-
: VPSingleDefRecipe(SC, Operands, I), RdxDesc(R), IsOrdered(IsOrdered) {
2619+
: VPSingleDefRecipe(SC, Operands, I, I->getDebugLoc()), RdxDesc(R),
2620+
IsOrdered(IsOrdered) {
26192621
if (CondOp) {
26202622
IsConditional = true;
26212623
addOperand(CondOp);

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,6 +2114,7 @@ void VPReductionRecipe::execute(VPTransformState &State) {
21142114
// Propagate the fast-math flags carried by the underlying instruction.
21152115
IRBuilderBase::FastMathFlagGuard FMFGuard(State.Builder);
21162116
State.Builder.setFastMathFlags(RdxDesc.getFastMathFlags());
2117+
State.setDebugLocFrom(getDebugLoc());
21172118
Value *NewVecOp = State.get(getVecOp());
21182119
if (VPValue *Cond = getCondOp()) {
21192120
Value *NewCond = State.get(Cond, State.VF.isScalar());
@@ -3456,6 +3457,7 @@ void VPWidenPHIRecipe::execute(VPTransformState &State) {
34563457
assert(EnableVPlanNativePath &&
34573458
"Non-native vplans are not expected to have VPWidenPHIRecipes.");
34583459

3460+
State.setDebugLocFrom(getDebugLoc());
34593461
Value *Op0 = State.get(getOperand(0));
34603462
Type *VecTy = Op0->getType();
34613463
Value *VecPhi = State.Builder.CreatePHI(VecTy, 2, "vec.phi");

llvm/test/Transforms/LoopVectorize/RISCV/preserve-dbg-loc.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
; DEBUGLOC-LABEL: define void @vp_select(
1010
define void @vp_select(ptr noalias %a, ptr noalias %b, ptr noalias %c, i64 %N) {
1111
; DEBUGLOC: vector.body:
12-
; DEBUGLOC: %[[VPSel:[0-9]+]] = call <vscale x 4 x i32> @llvm.vp.select.nxv4i32(<vscale x 4 x i1> %15, <vscale x 4 x i32> %vp.op.load1, <vscale x 4 x i32> %vp.op, i32 %9)
12+
; DEBUGLOC: %[[VPSel:[0-9]+]] = call <vscale x 4 x i32> @llvm.vp.select.nxv4i32(<vscale x 4 x i1> %15, <vscale x 4 x i32> %vp.op.load1, <vscale x 4 x i32> %vp.op, i32 %9), !dbg ![[SelLoc:[0-9]+]]
1313
; DEBUGLOC: for.body:
14-
; DEBUGLOC: %cond.p = select i1 %cmp4, i32 %22, i32 %23, !dbg !39
14+
; DEBUGLOC: %cond.p = select i1 %cmp4, i32 %22, i32 %23, !dbg ![[SelLoc]]
1515
entry:
1616
br label %for.body
1717

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]]

llvm/test/Transforms/LoopVectorize/preserve-dbg-loc.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
88
define i32 @reduction_sum(ptr noalias nocapture %A, ptr noalias nocapture %B) {
99
; DEBUGLOC: vector.body:
1010
; DEBUGLOC: %[[VecLoad:.*]] = load <4 x i32>, ptr %2, align 4, !dbg ![[LoadLoc0:[0-9]+]]
11-
; DEBUGLOC: %[[VecRed:.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %wide.load), !dbg ![[LoadLoc0]]
11+
; DEBUGLOC: %[[VecRed:.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %wide.load), !dbg ![[RedLoc0:[0-9]+]]
1212
; DEBUGLOC: .lr.ph:
1313
; DEBUGLOC: %l3 = load i32, ptr %l2, align 4, !dbg ![[LoadLoc0]]
14-
; DEBUGLOC: %l7 = add i32 %sum.02, %l3, !dbg ![[RedLoc0:[0-9]+]]
14+
; DEBUGLOC: %l7 = add i32 %sum.02, %l3, !dbg ![[RedLoc0]]
1515
entry:
1616
br label %.lr.ph
1717

0 commit comments

Comments
 (0)