Skip to content

Commit 8bbb5fa

Browse files
committed
[SYCL] Move SYCLLowerWGLocalMemoryPass to OptimizerEarlyEPCallback
The pass transforms __sycl_allocateLocalMemory call to access of global variable @WGLocalMem . Move the transform to beginning of the optimizer since the access could enable more optimization than the function call. In addition, intel gpu compiler has a pass to transform global variable in addrspace(3) to alloca, we must run SYCLLowerWGLocalMemoryPass before it.
1 parent f0ee2da commit 8bbb5fa

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
10281028
// configure the pipeline.
10291029
OptimizationLevel Level = mapToLevel(CodeGenOpts);
10301030

1031-
if (LangOpts.SYCLIsDevice)
1031+
if (LangOpts.SYCLIsDevice) {
10321032
PB.registerPipelineStartEPCallback([&](ModulePassManager &MPM,
10331033
OptimizationLevel Level) {
10341034
MPM.addPass(SYCLVirtualFunctionsAnalysisPass());
@@ -1043,7 +1043,14 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
10431043
/*ExcludeAspects=*/{"fp64"}));
10441044
MPM.addPass(SYCLPropagateJointMatrixUsagePass());
10451045
});
1046-
else if (LangOpts.SYCLIsHost && !LangOpts.SYCLESIMDBuildHostCode)
1046+
PB.registerOptimizerEarlyEPCallback([](ModulePassManager &MPM,
1047+
OptimizationLevel Level,
1048+
ThinOrFullLTOPhase) {
1049+
// Allocate static local memory in SYCL kernel scope for each allocation
1050+
// call.
1051+
MPM.addPass(SYCLLowerWGLocalMemoryPass());
1052+
});
1053+
} else if (LangOpts.SYCLIsHost && !LangOpts.SYCLESIMDBuildHostCode)
10471054
PB.registerPipelineStartEPCallback(
10481055
[&](ModulePassManager &MPM, OptimizationLevel Level) {
10491056
MPM.addPass(ESIMDRemoveHostCodePass());
@@ -1191,10 +1198,6 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
11911198
MPM.addPass(SPIRITTAnnotationsPass());
11921199
}
11931200

1194-
// Allocate static local memory in SYCL kernel scope for each allocation
1195-
// call.
1196-
MPM.addPass(SYCLLowerWGLocalMemoryPass());
1197-
11981201
// Process properties and annotations
11991202
MPM.addPass(CompileTimePropertiesPass());
12001203

0 commit comments

Comments
 (0)