diff --git a/llvm/lib/SYCLLowerIR/LowerWGScope.cpp b/llvm/lib/SYCLLowerIR/LowerWGScope.cpp index 845ae4f389aa9..880d87d919055 100644 --- a/llvm/lib/SYCLLowerIR/LowerWGScope.cpp +++ b/llvm/lib/SYCLLowerIR/LowerWGScope.cpp @@ -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 Ranges; @@ -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()) @@ -836,6 +835,7 @@ 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"); @@ -843,10 +843,9 @@ PreservedAnalyses SYCLLowerWGScopePass::run(Function &F, #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 @@ -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, diff --git a/llvm/test/SYCLLowerIR/byval_arg.ll b/llvm/test/SYCLLowerIR/byval_arg.ll index df3cc8062a796..57b29cb58359a 100644 --- a/llvm/test/SYCLLowerIR/byval_arg.ll +++ b/llvm/test/SYCLLowerIR/byval_arg.ll @@ -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 diff --git a/llvm/test/SYCLLowerIR/convergent.ll b/llvm/test/SYCLLowerIR/convergent.ll index be9c9bd687776..93a7e4a520c58 100644 --- a/llvm/test/SYCLLowerIR/convergent.ll +++ b/llvm/test/SYCLLowerIR/convergent.ll @@ -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 }