Skip to content

Commit 3a859b1

Browse files
committed
[VPlan] Set and use debug location for VPScalarIVStepsRecipe.
This adds missing debug location for VPscalarIVStepsRecipe. The location of the corresponding phi is used.
1 parent b518242 commit 3a859b1

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,10 @@ class VPBuilder {
263263
VPScalarIVStepsRecipe *
264264
createScalarIVSteps(Instruction::BinaryOps InductionOpcode,
265265
FPMathOperator *FPBinOp, VPValue *IV, VPValue *Step,
266-
VPValue *VF) {
266+
VPValue *VF, DebugLoc DL) {
267267
return tryInsertInstruction(new VPScalarIVStepsRecipe(
268268
IV, Step, VF, InductionOpcode,
269-
FPBinOp ? FPBinOp->getFastMathFlags() : FastMathFlags()));
269+
FPBinOp ? FPBinOp->getFastMathFlags() : FastMathFlags(), DL));
270270
}
271271

272272
//===--------------------------------------------------------------------===//

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,25 +3076,28 @@ class VPScalarIVStepsRecipe : public VPRecipeWithIRFlags,
30763076

30773077
public:
30783078
VPScalarIVStepsRecipe(VPValue *IV, VPValue *Step, VPValue *VF,
3079-
Instruction::BinaryOps Opcode, FastMathFlags FMFs)
3079+
Instruction::BinaryOps Opcode, FastMathFlags FMFs,
3080+
DebugLoc DL)
30803081
: VPRecipeWithIRFlags(VPDef::VPScalarIVStepsSC,
3081-
ArrayRef<VPValue *>({IV, Step, VF}), FMFs),
3082+
ArrayRef<VPValue *>({IV, Step, VF}), FMFs, DL),
30823083
InductionOpcode(Opcode) {}
30833084

30843085
VPScalarIVStepsRecipe(const InductionDescriptor &IndDesc, VPValue *IV,
3085-
VPValue *Step, VPValue *VF)
3086+
VPValue *Step, VPValue *VF, DebugLoc DL = {})
30863087
: VPScalarIVStepsRecipe(
30873088
IV, Step, VF, IndDesc.getInductionOpcode(),
30883089
dyn_cast_or_null<FPMathOperator>(IndDesc.getInductionBinOp())
30893090
? IndDesc.getInductionBinOp()->getFastMathFlags()
3090-
: FastMathFlags()) {}
3091+
: FastMathFlags(),
3092+
DL) {}
30913093

30923094
~VPScalarIVStepsRecipe() override = default;
30933095

30943096
VPScalarIVStepsRecipe *clone() override {
30953097
return new VPScalarIVStepsRecipe(
30963098
getOperand(0), getOperand(1), getOperand(2), InductionOpcode,
3097-
hasFastMathFlags() ? getFastMathFlags() : FastMathFlags());
3099+
hasFastMathFlags() ? getFastMathFlags() : FastMathFlags(),
3100+
getDebugLoc());
30983101
}
30993102

31003103
/// Return true if this VPScalarIVStepsRecipe corresponds to part 0. Note that

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,6 +2029,7 @@ void VPDerivedIVRecipe::print(raw_ostream &O, const Twine &Indent,
20292029
#endif
20302030

20312031
void VPScalarIVStepsRecipe::execute(VPTransformState &State) {
2032+
State.setDebugLocFrom(getDebugLoc());
20322033
// Fast-math-flags propagate from the original induction instruction.
20332034
IRBuilder<>::FastMathFlagGuard FMFG(State.Builder);
20342035
if (hasFastMathFlags())

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind,
576576
Step = Builder.createScalarCast(Instruction::Trunc, Step, ResultTy, DL);
577577
}
578578
return Builder.createScalarIVSteps(InductionOpcode, FPBinOp, BaseIV, Step,
579-
&Plan.getVF());
579+
&Plan.getVF(), DL);
580580
}
581581

582582
static SmallVector<VPUser *> collectUsersRecursively(VPValue *V) {

llvm/test/Transforms/LoopVectorize/debugloc.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,8 @@ define void @test_scalar_steps(ptr nocapture %a, ptr noalias %b, i64 %size) !dbg
175175
; CHECK: vector.body:
176176
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
177177
; CHECK-NEXT: [[OFFSET_IDX:%.*]] = mul i64 [[INDEX]], 2
178-
; CHECK-NEXT: [[TMP6:%.*]] = add i64 [[OFFSET_IDX]], 0
179-
; CHECK-NOT: !dbg
180-
; CHECK-NEXT: [[TMP7:%.*]] = add i64 [[OFFSET_IDX]], 2
178+
; CHECK-NEXT: [[TMP6:%.*]] = add i64 [[OFFSET_IDX]], 0, !dbg [[LOC8:!.+]]
179+
; CHECK-NEXT: [[TMP7:%.*]] = add i64 [[OFFSET_IDX]], 2, !dbg [[LOC8]]
181180
; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[TMP6]]
182181
; CHECK-NEXT: [[TMP9:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[TMP7]]
183182
; CHECK-NEXT: [[TMP10:%.*]] = getelementptr inbounds i32, ptr [[B:%.*]], i64 [[TMP6]]
@@ -215,6 +214,7 @@ exit:
215214
; CHECK: [[LOC5]] = !DILocation(line: 320
216215
; CHECK: [[LOC6]] = !DILocation(line: 430
217216
; CHECK: [[LOC7]] = !DILocation(line: 540
217+
; CHECK: [[LOC8]] = !DILocation(line: 650
218218

219219

220220
declare void @llvm.dbg.declare(metadata, metadata, metadata)

0 commit comments

Comments
 (0)