Skip to content

Commit 15406a5

Browse files
vmustyapszymich
authored andcommitted
Skip function declarations in the SLM resolution pass
Function declarations have no basic blocks and instructions, so they should be skipped in the SLM resolution pass. (cherry picked from commit 3db59df)
1 parent 6eec809 commit 15406a5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXSLMResolution.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,12 @@ bool GenXSLMResolution::runOnModule(Module &M) {
279279

280280
auto SLMVars = collectSLMVariables(M);
281281
if (!SLMVars.empty())
282-
for (auto &F : M.functions())
282+
for (auto &F : M.functions()) {
283+
if (F.isDeclaration())
284+
continue;
283285
Modified |=
284286
vc::breakConstantExprs(&F, vc::LegalizationStage::NotLegalized);
287+
}
285288

286289
for (auto &F : M.functions())
287290
if (vc::isKernel(&F))

IGC/VectorCompiler/test/GenXSLMResolution/simple.ll

+7
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,20 @@ define dllexport spir_kernel void @kernel() #0 {
3030
; CHECK-OPAQUE-PTRS: %load_struct_i64i8 = load { i64, i8 }, ptr addrspace(3) inttoptr (i32 8 to ptr addrspace(3))
3131
%load_struct_i64i8 = load { i64, i8 }, { i64, i8 } addrspace(3)* @slm_struct_i64i8
3232

33+
; CHECK-TYPED-PTRS: call void @llvm.genx.barrier()
34+
; CHECK-OPAQUE-PTRS: call void @llvm.genx.barrier()
35+
call void @llvm.genx.barrier()
36+
3337
; CHECK-TYPED-PTRS: %load_struct_align = load { i1 }, { i1 } addrspace(3)* inttoptr (i32 268435456 to { i1 } addrspace(3)*)
3438
; CHECK-OPAQUE-PTRS: %load_struct_align = load { i1 }, ptr addrspace(3) inttoptr (i32 268435456 to ptr addrspace(3))
3539
%load_struct_align = load { i1 }, { i1 } addrspace(3)* @slm_struct_align
3640
ret void
3741
}
3842

43+
declare void @llvm.genx.barrier() #1
44+
3945
attributes #0 = { noinline nounwind "CMGenxMain" }
46+
attributes #1 = { nounwind convergent }
4047

4148
!genx.kernels = !{!0}
4249
!genx.kernel.internal = !{!3}

0 commit comments

Comments
 (0)