Skip to content

[SYCL] Fix module changes detection in LowerWGScope pass #5292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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