Skip to content

Commit c019149

Browse files
committed
[SYCL] Fix group local memory sharing when opts disabled
Group local memory functions depend on inlining pass. When all optimizations are disabled then those functions are not inlined. If a user adds several group local memory calls with the same template argument then only one group local memory function is specialized and then one memory buffer is allocated. Thus all variables that save a result of the group local memory call point to the same buffer. Enable AlwaysInliner pass even when all llvm passes are disabled as a workaround. A More accurate solution with call graph analysis will be added later. Signed-off-by: Mikhail Lychkov <[email protected]>
1 parent 9f9ba38 commit c019149

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,14 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
990990
}
991991

992992
// Allocate static local memory in SYCL kernel scope for each allocation call.
993-
if (LangOpts.SYCLIsDevice)
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+
// TODO: Remove this workaround when dependency on inlining is eliminated.
997+
if (CodeGenOpts.DisableLLVMPasses)
998+
PerModulePasses.add(createAlwaysInlinerLegacyPass(false));
994999
PerModulePasses.add(createSYCLLowerWGLocalMemoryLegacyPass());
1000+
}
9951001

9961002
switch (Action) {
9971003
case Backend_EmitNothing:

0 commit comments

Comments
 (0)