Skip to content

Commit 40b659d

Browse files
authored
Update BackendUtil.cpp
Move passes to CreatePasses function. NOTE: `createSYCLLowerWGLocalMemoryLegacyPass` is not added to the the pipeline if CodeGenOpts.DisableLLVMPasses is ON.
1 parent 20739b6 commit 40b659d

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,16 @@ 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 call.
871+
MPM.add(createSYCLLowerWGLocalMemoryLegacyPass());
872+
}
863873
}
864874

865875
static void setCommandLineOpts(const CodeGenOptions &CodeGenOpts) {
@@ -973,12 +983,6 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
973983

974984
std::unique_ptr<llvm::ToolOutputFile> ThinLinkOS, DwoOS;
975985

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-
982986
// Add SPIRITTAnnotations pass to the pass manager if
983987
// -fsycl-instrument-device-code option was passed. This option can be
984988
// used only with spir triple.
@@ -989,16 +993,6 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
989993
PerModulePasses.add(createSPIRITTAnnotationsPass());
990994
}
991995

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-
1002996
switch (Action) {
1003997
case Backend_EmitNothing:
1004998
break;

0 commit comments

Comments
 (0)