Skip to content

Commit abc91de

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:bc23ef3feba9 into amd-gfx:0060b1beee69
Local branch amd-gfx 0060b1b Merged main:fd784726db70 into amd-gfx:1c4d2a5930bb Remote branch main bc23ef3 [LV] Add test showing incorrect debug location for scalar casts.
2 parents 0060b1b + bc23ef3 commit abc91de

File tree

6 files changed

+65
-9
lines changed

6 files changed

+65
-9
lines changed

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 522215
19+
#define LLVM_MAIN_REVISION 522217
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,12 +2839,12 @@ class VPPredInstPHIRecipe : public VPSingleDefRecipe {
28392839
public:
28402840
/// Construct a VPPredInstPHIRecipe given \p PredInst whose value needs a phi
28412841
/// nodes after merging back from a Branch-on-Mask.
2842-
VPPredInstPHIRecipe(VPValue *PredV)
2843-
: VPSingleDefRecipe(VPDef::VPPredInstPHISC, PredV) {}
2842+
VPPredInstPHIRecipe(VPValue *PredV, DebugLoc DL)
2843+
: VPSingleDefRecipe(VPDef::VPPredInstPHISC, PredV, DL) {}
28442844
~VPPredInstPHIRecipe() override = default;
28452845

28462846
VPPredInstPHIRecipe *clone() override {
2847-
return new VPPredInstPHIRecipe(getOperand(0));
2847+
return new VPPredInstPHIRecipe(getOperand(0), getDebugLoc());
28482848
}
28492849

28502850
VP_CLASSOF_IMPL(VPDef::VPPredInstPHISC)

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,6 +2392,7 @@ InstructionCost VPBranchOnMaskRecipe::computeCost(ElementCount VF,
23922392
}
23932393

23942394
void VPPredInstPHIRecipe::execute(VPTransformState &State) {
2395+
State.setDebugLocFrom(getDebugLoc());
23952396
assert(State.Lane && "Predicated instruction PHI works per instance.");
23962397
Instruction *ScalarPredInst =
23972398
cast<Instruction>(State.get(getOperand(0), *State.Lane));

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ static VPRegionBlock *createReplicateRegion(VPReplicateRecipe *PredRecipe,
322322

323323
VPPredInstPHIRecipe *PHIRecipe = nullptr;
324324
if (PredRecipe->getNumUsers() != 0) {
325-
PHIRecipe = new VPPredInstPHIRecipe(RecipeWithoutMask);
325+
PHIRecipe = new VPPredInstPHIRecipe(RecipeWithoutMask,
326+
RecipeWithoutMask->getDebugLoc());
326327
PredRecipe->replaceAllUsesWith(PHIRecipe);
327328
PHIRecipe->setOperand(0, RecipeWithoutMask);
328329
}

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

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
; RUN: opt < %s -passes=loop-vectorize -force-vector-width=4 -S 2>&1 | FileCheck %s
2-
; RUN: opt < %s -passes=debugify,loop-vectorize -force-vector-width=4 -S | FileCheck %s -check-prefix DEBUGLOC
3-
; RUN: opt < %s -passes=debugify,loop-vectorize -force-vector-width=4 -S --try-experimental-debuginfo-iterators | FileCheck %s -check-prefix DEBUGLOC
1+
; RUN: opt < %s -passes=loop-vectorize -force-vector-width=4 -force-widen-divrem-via-safe-divisor=0 -S 2>&1 | FileCheck %s
2+
; RUN: opt < %s -passes=debugify,loop-vectorize -force-vector-width=4 -force-widen-divrem-via-safe-divisor=0 -S | FileCheck %s -check-prefix DEBUGLOC
3+
; RUN: opt < %s -passes=debugify,loop-vectorize -force-vector-width=4 -force-widen-divrem-via-safe-divisor=0 -S --try-experimental-debuginfo-iterators | FileCheck %s -check-prefix DEBUGLOC
44
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
55

66
; This test makes sure we don't duplicate the loop vectorizer's metadata
@@ -54,6 +54,60 @@ exit:
5454
ret void
5555
}
5656

57+
define void @predicated_phi_dbg(i64 %n, ptr %x) {
58+
; DEBUGLOC-LABEL: define void @predicated_phi_dbg(
59+
; DEBUGLOC: pred.udiv.continue{{.+}}:
60+
; DEBUGLOC-NEXT: = phi <4 x i64> {{.+}}, !dbg [[PREDPHILOC:![0-9]+]]
61+
;
62+
; DEBUGLOC: for.body:
63+
; DEBUGLOC: %tmp4 = udiv i64 %n, %i, !dbg [[PREDPHILOC]]
64+
;
65+
entry:
66+
br label %for.body
67+
68+
for.body:
69+
%i = phi i64 [ 0, %entry ], [ %i.next, %for.inc ]
70+
%cmp = icmp ult i64 %i, 5
71+
br i1 %cmp, label %if.then, label %for.inc
72+
73+
if.then:
74+
%tmp4 = udiv i64 %n, %i
75+
br label %for.inc
76+
77+
for.inc:
78+
%d = phi i64 [ 0, %for.body ], [ %tmp4, %if.then ]
79+
%idx = getelementptr i64, ptr %x, i64 %i
80+
store i64 %d, ptr %idx
81+
%i.next = add nuw nsw i64 %i, 1
82+
%cond = icmp slt i64 %i.next, %n
83+
br i1 %cond, label %for.body, label %for.end
84+
85+
for.end:
86+
ret void
87+
}
88+
89+
define void @scalar_cast_dbg(ptr nocapture %a, i32 %start, i64 %k) {
90+
; DEBUGLOC-LABEL: define void @scalar_cast_dbg(
91+
; DEBUGLOC: = trunc i64 %index to i32, !dbg [[CASTLOC:![0-9]+]]
92+
;
93+
; DEBUGLOC: loop:
94+
; DEBUGLOC-NOT: %trunc.iv = trunc i64 %iv to i32, !dbg [[CASTLOC]]
95+
;
96+
entry:
97+
br label %loop
98+
99+
loop:
100+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
101+
%trunc.iv = trunc i64 %iv to i32
102+
%arrayidx = getelementptr inbounds i32, ptr %a, i32 %trunc.iv
103+
store i32 %trunc.iv, ptr %arrayidx, align 4
104+
%iv.next = add nuw nsw i64 %iv, 1
105+
%exitcond = icmp eq i64 %iv.next, %k
106+
br i1 %exitcond, label %exit, label %loop
107+
108+
exit:
109+
ret void
110+
}
57111

58112
!0 = !{!0, !1}
59113
!1 = !{!"llvm.loop.vectorize.width", i32 4}

llvm/unittests/Transforms/Vectorize/VPlanTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ TEST(VPRecipeTest, MayHaveSideEffectsAndMayReadWriteMemory) {
12871287
}
12881288
{
12891289
VPValue Op1;
1290-
VPPredInstPHIRecipe Recipe(&Op1);
1290+
VPPredInstPHIRecipe Recipe(&Op1, {});
12911291
EXPECT_FALSE(Recipe.mayHaveSideEffects());
12921292
EXPECT_FALSE(Recipe.mayReadFromMemory());
12931293
EXPECT_FALSE(Recipe.mayWriteToMemory());

0 commit comments

Comments
 (0)