From 74287c876757bed00c3e55dce623f4f169ae6987 Mon Sep 17 00:00:00 2001 From: Alexey Sachkov Date: Mon, 15 Nov 2021 15:17:03 +0300 Subject: [PATCH 1/2] [SYCL] Fix module changes detection in LowerWGScope pass --- llvm/lib/SYCLLowerIR/LowerWGScope.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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, From 4658b4fa3e2e20d4eb1e21821d70b723d1bd87ba Mon Sep 17 00:00:00 2001 From: Mikhail Lychkov Date: Thu, 13 Jan 2022 08:54:14 +0300 Subject: [PATCH 2/2] Update LIT tests affected by incorrect changes detection in new PM Signed-off-by: Mikhail Lychkov --- llvm/test/SYCLLowerIR/byval_arg.ll | 3 ++- llvm/test/SYCLLowerIR/convergent.ll | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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 }