Skip to content

Commit 46286b9

Browse files
mshelegosys-cmllvm
authored andcommitted
Restore types of byval kernel arguments
Before introduction of full opaque pointers support in situations when the frontend uses opaque pointers, but the backend still uses typed the information about original kernel arguments pointer element types was lost by spirv-translator and i8* was used instead. This is critical for byval arguments, so these types must be restored using information from genx.convert intrinsics.
1 parent 60cea75 commit 46286b9

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

GenXIntrinsics/lib/GenXIntrinsics/GenXSPIRVReaderAdaptor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,10 @@ transformKernelSignature(Function &F, const std::vector<SPIRVArgDesc> &Descs) {
481481
return PointerType::get(Type::getInt8Ty(Ctx), AddrSpace);
482482
}
483483
#endif
484+
if (!VCINTR::Type::isOpaquePointerTy(ArgTy) &&
485+
Arg.hasByValAttr())
486+
return OrigTy;
487+
484488
return ArgTy;
485489
}
486490
if (OrigTy->isPointerTy() && ArgTy->isPointerTy())

GenXIntrinsics/test/Adaptors/args_attributes_transform_reader.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,14 @@ define spir_kernel void @test(%foo addrspace(1)* byval(%foo) %arg) #0 {
2020
ret void
2121
}
2222

23+
; CHECK: define dllexport spir_kernel void @test_restore(
24+
; CHECK-SAME: %foo* byval(%foo)
25+
; CHECK-SAME: [[ARG:%[^)]+]])
26+
define spir_kernel void @test_restore(i8 addrspace(1)* byval(i8) %arg) #0 {
27+
%conv = call %foo* @llvm.genx.address.convert.p0foo.p1i8(i8 addrspace(1)* %arg)
28+
ret void
29+
}
30+
31+
declare %foo* @llvm.genx.address.convert.p0foo.p1i8(i8 addrspace(1)*) #0
32+
2333
attributes #0 = { "VCFunction" }

0 commit comments

Comments
 (0)