Skip to content

Commit 5e3e47f

Browse files
committed
Turn back the first version of the fix.
This reverts commit 40b659d.
1 parent fe78c89 commit 5e3e47f

File tree

3 files changed

+40
-35
lines changed

3 files changed

+40
-35
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -860,17 +860,6 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM,
860860

861861
PMBuilder.populateFunctionPassManager(FPM);
862862
PMBuilder.populateModulePassManager(MPM);
863-
864-
if (LangOpts.SYCLIsDevice) {
865-
// Eliminate dead arguments from SPIR kernels in SYCL environment.
866-
// Run DAE when LLVM optimizations are applied as well.
867-
if (LangOpts.EnableDAEInSpirKernels)
868-
MPM.add(createDeadArgEliminationSYCLPass());
869-
870-
// Allocate static local memory in SYCL kernel scope for each allocation
871-
// call.
872-
MPM.add(createSYCLLowerWGLocalMemoryLegacyPass());
873-
}
874863
}
875864

876865
static void setCommandLineOpts(const CodeGenOptions &CodeGenOpts) {
@@ -984,6 +973,12 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
984973

985974
std::unique_ptr<llvm::ToolOutputFile> ThinLinkOS, DwoOS;
986975

976+
// Eliminate dead arguments from SPIR kernels in SYCL environment.
977+
// Run DAE when LLVM optimizations are applied as well.
978+
if (LangOpts.SYCLIsDevice && !CodeGenOpts.DisableLLVMPasses &&
979+
LangOpts.EnableDAEInSpirKernels)
980+
PerModulePasses.add(createDeadArgEliminationSYCLPass());
981+
987982
// Add SPIRITTAnnotations pass to the pass manager if
988983
// -fsycl-instrument-device-code option was passed. This option can be
989984
// used only with spir triple.
@@ -994,6 +989,16 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
994989
PerModulePasses.add(createSPIRITTAnnotationsPass());
995990
}
996991

992+
// Allocate static local memory in SYCL kernel scope for each allocation call.
993+
if (LangOpts.SYCLIsDevice) {
994+
// Group local memory pass depends on inlining. Turn it on even in case if
995+
// all llvm passes or SYCL early optimizations are disabled.
996+
// FIXME: Remove this workaround when dependency on inlining is eliminated.
997+
if (CodeGenOpts.DisableLLVMPasses)
998+
PerModulePasses.add(createAlwaysInlinerLegacyPass(false));
999+
PerModulePasses.add(createSYCLLowerWGLocalMemoryLegacyPass());
1000+
}
1001+
9971002
switch (Action) {
9981003
case Backend_EmitNothing:
9991004
break;

clang/test/CodeGenSYCL/group-local-memory-inlining.cpp

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1-
// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown-sycldevice \
2-
// RUN: -S -emit-llvm -mllvm -debug-pass=Structure -o - %s 2>&1 \
3-
// RUN: | FileCheck %s
1+
// Check that SYCLLowerWGLocalMemory pass is added to the SYCL device
2+
// compilation pipeline with the inliner pass.
43

4+
// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm \
5+
// RUN: -mllvm -debug-pass=Structure %s -o - 2>&1 \
6+
// RUN: | FileCheck %s
7+
// CHECK: Function Integration/Inlining
58
// CHECK: Replace __sycl_allocateLocalMemory with allocation of memory in local address space
9+
10+
// Check that AlwaysInliner pass is always run for compilation of SYCL device
11+
// target code, even if all optimizations are disabled.
12+
13+
// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm \
14+
// RUN: -mllvm -debug-pass=Structure %s -o - -disable-llvm-passes 2>&1 \
15+
// RUN: | FileCheck %s --check-prefix=CHECK-NOPASSES
16+
// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm \
17+
// RUN: -mllvm -debug-pass=Structure %s -o - -fno-sycl-early-optimizations 2>&1 \
18+
// RUN: | FileCheck %s --check-prefix=CHECK-NOPASSES
19+
// CHECK-NOPASSES: Inliner for always_inline functions
20+
// CHECK-NOPASSES: Replace __sycl_allocateLocalMemory with allocation of memory in local address space
21+
22+
// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm \
23+
// RUN: -mllvm -debug-pass=Structure %s -o - -O0 2>&1 \
24+
// RUN: | FileCheck %s --check-prefix=CHECK-O0opt
25+
// CHECK-O0opt: Inliner for always_inline functions
26+
// CHECK-O0opt: Replace __sycl_allocateLocalMemory with allocation of memory in local address space

0 commit comments

Comments
 (0)