Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ArgumentAttributeINTEL decoration translation after nocapture attribute change #2983

Merged
merged 5 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/SPIRV/SPIRVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,14 @@ void SPIRVToLLVM::transFunctionPointerCallArgumentAttributes(
std::vector<SPIRVWord> Literals = Dec->getVecLiteral();
SPIRVWord ArgNo = Literals[0];
SPIRVWord SpirvAttr = Literals[1];
// There is no value to rmap SPIR-V FunctionParameterAttributeNoCapture, as
// LLVM does not have Attribute::NoCapture anymore. Adding special handling
// for this case.
if (SpirvAttr == FunctionParameterAttributeNoCapture) {
CI->addParamAttr(ArgNo, Attribute::getWithCaptureInfo(
CI->getContext(), CaptureInfo::none()));
continue;
}
Attribute::AttrKind LlvmAttrKind = SPIRSPIRVFuncParamAttrMap::rmap(
static_cast<SPIRVFuncParamAttrKind>(SpirvAttr));
auto LlvmAttr =
Expand Down
4 changes: 4 additions & 0 deletions lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2740,6 +2740,10 @@ bool LLVMToSPIRVBase::shouldTryToAddMemAliasingDecoration(Instruction *Inst) {
void addFuncPointerCallArgumentAttributes(CallInst *CI,
SPIRVValue *FuncPtrCall) {
for (unsigned ArgNo = 0; ArgNo < CI->arg_size(); ++ArgNo) {
if (CI->doesNotCapture(ArgNo))
FuncPtrCall->addDecorate(new SPIRVDecorate(
spv::internal::DecorationArgumentAttributeINTEL, FuncPtrCall, ArgNo,
FunctionParameterAttributeNoCapture));
for (const auto &I : CI->getAttributes().getParamAttrs(ArgNo)) {
spv::FunctionParameterAttribute Attr = spv::FunctionParameterAttributeMax;
SPIRSPIRVFuncParamAttrMap::find(I.getKindAsEnum(), &Attr);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
; TODO: update for nocapture -> captures(none) LLVM change.
; XFAIL: *

; RUN: llvm-as %s -o %t.bc
; RUN: llvm-spirv %t.bc -o %t.spt -spirv-text -spirv-ext=+SPV_INTEL_function_pointers
; RUN: FileCheck < %t.spt %s --check-prefix CHECK-SPIRV
Expand All @@ -13,13 +10,13 @@
; CHECK-SPIRV: Capability FunctionPointersINTEL
; CHECK-SPIRV: Extension "SPV_INTEL_function_pointers"

; CHECK-SPIRV: Decorate [[#TargetId:]] ArgumentAttributeINTEL 0 4
; CHECK-SPIRV: Decorate [[#TargetId]] ArgumentAttributeINTEL 0 5
; CHECK-SPIRV: Decorate [[#TargetId:]] ArgumentAttributeINTEL 0 5
; CHECK-SPIRV: Decorate [[#TargetId]] ArgumentAttributeINTEL 0 4
; CHECK-SPIRV: Decorate [[#TargetId]] ArgumentAttributeINTEL 0 2
; CHECK-SPIRV: FunctionPointerCallINTEL
; CHECK-SPIRV-SAME: [[#TargetId]]

; CHECK-LLVM: call spir_func addrspace(9) void %cond.i.i(ptr noalias captures(none) byval(%multi_ptr) %agg.tmp.i.i)
; CHECK-LLVM: call spir_func addrspace(9) void %cond.i.i(ptr noalias byval(%multi_ptr) captures(none) %agg.tmp.i.i)

; ModuleID = 'sycl_test.cpp'
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
; TODO: update for nocapture -> captures(none) LLVM change.
; XFAIL: *

; RUN: llvm-as %s -o %t.bc
; RUN: llvm-spirv %t.bc -o %t.spt -spirv-text -spirv-ext=+SPV_INTEL_function_pointers
; RUN: FileCheck < %t.spt %s --check-prefix CHECK-SPIRV
Expand All @@ -13,13 +10,13 @@
; CHECK-SPIRV: Capability FunctionPointersINTEL
; CHECK-SPIRV: Extension "SPV_INTEL_function_pointers"

; CHECK-SPIRV: Decorate [[#TargetId:]] ArgumentAttributeINTEL 0 4
; CHECK-SPIRV: Decorate [[#TargetId]] ArgumentAttributeINTEL 0 5
; CHECK-SPIRV: Decorate [[#TargetId:]] ArgumentAttributeINTEL 0 5
; CHECK-SPIRV: Decorate [[#TargetId]] ArgumentAttributeINTEL 0 4
; CHECK-SPIRV: Decorate [[#TargetId]] ArgumentAttributeINTEL 0 2
; CHECK-SPIRV: FunctionPointerCallINTEL
; CHECK-SPIRV-SAME: [[#TargetId]]

; CHECK-LLVM: call spir_func void %cond.i.i(ptr noalias captures(none) byval(%multi_ptr) %agg.tmp.i.i)
; CHECK-LLVM: call spir_func void %cond.i.i(ptr noalias byval(%multi_ptr) captures(none) %agg.tmp.i.i)

; ModuleID = 'sycl_test.cpp'
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
Expand Down
Loading