Skip to content

Commit 34d64cf

Browse files
[SYCL] Fix module changes detection in LowerWGScope pass (#5292)
Also explicitly updated tests, which fail without pipeline adjustments to get better test coverage. Signed-off-by: Mikhail Lychkov <[email protected]> Co-authored-by: Alexey Sachkov <[email protected]>
1 parent e15ac50 commit 34d64cf

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

llvm/lib/SYCLLowerIR/LowerWGScope.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,6 @@ PreservedAnalyses SYCLLowerWGScopePass::run(Function &F,
766766
FunctionAnalysisManager &FAM) {
767767
if (!F.getMetadata(WG_SCOPE_MD))
768768
return PreservedAnalyses::all();
769-
bool Changed = false;
770769
const auto &TT = llvm::Triple(F.getParent()->getTargetTriple());
771770
// Ranges of "side effect" instructions
772771
SmallVector<InstrRange, 16> Ranges;
@@ -827,7 +826,7 @@ PreservedAnalyses SYCLLowerWGScopePass::run(Function &F,
827826
Ranges.push_back(InstrRange{First, Last});
828827
}
829828
}
830-
#ifndef NDEBUG
829+
831830
int NByval = 0;
832831
for (const auto &Arg : F.args()) {
833832
if (Arg.hasByValAttr())
@@ -836,17 +835,17 @@ PreservedAnalyses SYCLLowerWGScopePass::run(Function &F,
836835

837836
bool HaveChanges = (Ranges.size() > 0) || (Allocas.size() > 0) || NByval > 0;
838837

838+
#ifndef NDEBUG
839839
if (HaveChanges && Debug > 1) {
840840
dumpIR(F, "before");
841841
dumpDot(F, "before");
842842
}
843843
#endif // NDEBUG
844844

845845
// Perform the transformation
846-
for (auto &R : Ranges) {
846+
for (auto &R : Ranges)
847847
tformRange(R, TT);
848-
Changed = true;
849-
}
848+
850849
// There can be allocas not corresponding to any variable declared in user
851850
// code but generated by the compiler - e.g. for non-trivially typed
852851
// parameters passed by value. There can be WG scope stores into such
@@ -879,7 +878,7 @@ PreservedAnalyses SYCLLowerWGScopePass::run(Function &F,
879878
dumpDot(F, "after");
880879
}
881880
#endif // NDEBUG
882-
return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all();
881+
return HaveChanges ? PreservedAnalyses::none() : PreservedAnalyses::all();
883882
}
884883

885884
GlobalVariable *spirv::createWGLocalVariable(Module &M, Type *T,

llvm/test/SYCLLowerIR/byval_arg.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
; RUN: opt < %s -LowerWGScope -S | FileCheck %s
1+
; RUN: opt < %s -LowerWGScope -S -enable-new-pm=0 | FileCheck %s
2+
; RUN: opt < %s -passes=LowerWGScope -S | FileCheck %s
23

34
; Check that argument of the function marked with !work_group_scope
45
; attribute passed as byval is shared by leader work item via local

llvm/test/SYCLLowerIR/convergent.ll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
; RUN: opt < %s -LowerWGScope -S | FileCheck %s
2-
; RUN: opt < %s -LowerWGScope --mtriple=nvptx -S | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-PTX
1+
; RUN: opt < %s -LowerWGScope -S -enable-new-pm=0 | FileCheck %s
2+
; RUN: opt < %s -LowerWGScope --mtriple=nvptx -S -enable-new-pm=0 | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-PTX
3+
4+
; RUN: opt < %s -passes=LowerWGScope -S | FileCheck %s
5+
; RUN: opt < %s -passes=LowerWGScope --mtriple=nvptx -S | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-PTX
36

47

58
%struct.baz = type { i64 }

0 commit comments

Comments
 (0)