Skip to content

Commit

Permalink
[SYCL] Fix module changes detection in LowerWGScope pass (#5292)
Browse files Browse the repository at this point in the history
Also explicitly updated tests, which fail without pipeline adjustments to get
better test coverage.

Signed-off-by: Mikhail Lychkov <mikhail.lychkov@intel.com>
Co-authored-by: Alexey Sachkov <alexey.sachkov@intel.com>
  • Loading branch information
mlychkov and AlexeySachkov committed Jan 17, 2022
1 parent e15ac50 commit 34d64cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
11 changes: 5 additions & 6 deletions llvm/lib/SYCLLowerIR/LowerWGScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,6 @@ PreservedAnalyses SYCLLowerWGScopePass::run(Function &F,
FunctionAnalysisManager &FAM) {
if (!F.getMetadata(WG_SCOPE_MD))
return PreservedAnalyses::all();
bool Changed = false;
const auto &TT = llvm::Triple(F.getParent()->getTargetTriple());
// Ranges of "side effect" instructions
SmallVector<InstrRange, 16> Ranges;
Expand Down Expand Up @@ -827,7 +826,7 @@ PreservedAnalyses SYCLLowerWGScopePass::run(Function &F,
Ranges.push_back(InstrRange{First, Last});
}
}
#ifndef NDEBUG

int NByval = 0;
for (const auto &Arg : F.args()) {
if (Arg.hasByValAttr())
Expand All @@ -836,17 +835,17 @@ PreservedAnalyses SYCLLowerWGScopePass::run(Function &F,

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

#ifndef NDEBUG
if (HaveChanges && Debug > 1) {
dumpIR(F, "before");
dumpDot(F, "before");
}
#endif // NDEBUG

// Perform the transformation
for (auto &R : Ranges) {
for (auto &R : Ranges)
tformRange(R, TT);
Changed = true;
}

// There can be allocas not corresponding to any variable declared in user
// code but generated by the compiler - e.g. for non-trivially typed
// parameters passed by value. There can be WG scope stores into such
Expand Down Expand Up @@ -879,7 +878,7 @@ PreservedAnalyses SYCLLowerWGScopePass::run(Function &F,
dumpDot(F, "after");
}
#endif // NDEBUG
return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all();
return HaveChanges ? PreservedAnalyses::none() : PreservedAnalyses::all();
}

GlobalVariable *spirv::createWGLocalVariable(Module &M, Type *T,
Expand Down
3 changes: 2 additions & 1 deletion llvm/test/SYCLLowerIR/byval_arg.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: opt < %s -LowerWGScope -S | FileCheck %s
; RUN: opt < %s -LowerWGScope -S -enable-new-pm=0 | FileCheck %s
; RUN: opt < %s -passes=LowerWGScope -S | FileCheck %s

; Check that argument of the function marked with !work_group_scope
; attribute passed as byval is shared by leader work item via local
Expand Down
7 changes: 5 additions & 2 deletions llvm/test/SYCLLowerIR/convergent.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
; RUN: opt < %s -LowerWGScope -S | FileCheck %s
; RUN: opt < %s -LowerWGScope --mtriple=nvptx -S | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-PTX
; RUN: opt < %s -LowerWGScope -S -enable-new-pm=0 | FileCheck %s
; RUN: opt < %s -LowerWGScope --mtriple=nvptx -S -enable-new-pm=0 | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-PTX

; RUN: opt < %s -passes=LowerWGScope -S | FileCheck %s
; RUN: opt < %s -passes=LowerWGScope --mtriple=nvptx -S | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-PTX


%struct.baz = type { i64 }
Expand Down

0 comments on commit 34d64cf

Please sign in to comment.