@@ -860,17 +860,6 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM,
860
860
861
861
PMBuilder.populateFunctionPassManager (FPM);
862
862
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
- }
874
863
}
875
864
876
865
static void setCommandLineOpts (const CodeGenOptions &CodeGenOpts) {
@@ -984,6 +973,12 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
984
973
985
974
std::unique_ptr<llvm::ToolOutputFile> ThinLinkOS, DwoOS;
986
975
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
+
987
982
// Add SPIRITTAnnotations pass to the pass manager if
988
983
// -fsycl-instrument-device-code option was passed. This option can be
989
984
// used only with spir triple.
@@ -994,6 +989,16 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
994
989
PerModulePasses.add (createSPIRITTAnnotationsPass ());
995
990
}
996
991
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
+
997
1002
switch (Action) {
998
1003
case Backend_EmitNothing:
999
1004
break ;
0 commit comments