@@ -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
876865static 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 ;
0 commit comments