Skip to content

Commit c67e6f2

Browse files
committed
Add W/A to translate OpenCL kernel_arg_type_qual metadata
Since constant qualifier stored in the metadata is no longer mapped on NoWrite function parameter attribute we need a another way to save information about it. As work around this patch stores argument qualifier information in OpString under 'preserve-ocl-kernel-arg-type-metadata-through-string' option. This option should be also passed during reversed translation to obtain the metadata. This patch also moves already existing workaround for kernel_arg_type metadata under the option. Signed-off-by: Dmitry Sidorov <[email protected]>
1 parent f9d9902 commit c67e6f2

File tree

12 files changed

+162
-51
lines changed

12 files changed

+162
-51
lines changed

include/LLVMSPIRVOpts.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ class TranslatorOpts {
172172
ReplaceLLVMFmulAddWithOpenCLMad = Value;
173173
}
174174

175+
bool shouldPreserveOCLKernelArgTypeMetadataThroughString() const noexcept {
176+
return PreserveOCLKernelArgTypeMetadataThroughString;
177+
}
178+
179+
void setPreserveOCLKernelArgTypeMetadataThroughString(bool Value) noexcept {
180+
PreserveOCLKernelArgTypeMetadataThroughString = Value;
181+
}
182+
175183
private:
176184
// Common translation options
177185
VersionNumber MaxVersion = VersionNumber::MaximumVersion;
@@ -208,6 +216,10 @@ class TranslatorOpts {
208216
// Controls whether llvm.fmuladd.* should be replaced with mad from OpenCL
209217
// extended instruction set or with a simple fmul + fadd
210218
bool ReplaceLLVMFmulAddWithOpenCLMad = true;
219+
220+
// Add a workaround to preserve OpenCL kernel_arg_type and
221+
// kernel_arg_type_qual metadata through OpString
222+
bool PreserveOCLKernelArgTypeMetadataThroughString = false;
211223
};
212224

213225
} // namespace SPIRV

lib/SPIRV/SPIRVReader.cpp

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,9 +3840,13 @@ bool SPIRVToLLVM::transNonTemporalMetadata(Instruction *I) {
38403840
// generated and 'false' otherwise.
38413841
static bool transKernelArgTypeMedataFromString(LLVMContext *Ctx,
38423842
SPIRVModule *BM,
3843-
Function *Kernel) {
3844-
std::string ArgTypePrefix = std::string(SPIR_MD_KERNEL_ARG_TYPE) + "." +
3845-
Kernel->getName().str() + ".";
3843+
Function *Kernel,
3844+
std::string MDName) {
3845+
// Run W/A translation only if the appropriate option is passed
3846+
if (!BM->shouldPreserveOCLKernelArgTypeMetadataThroughString())
3847+
return false;
3848+
std::string ArgTypePrefix =
3849+
std::string(MDName) + "." + Kernel->getName().str() + ".";
38463850
auto ArgTypeStrIt = std::find_if(
38473851
BM->getStringVec().begin(), BM->getStringVec().end(),
38483852
[=](SPIRVString *S) { return S->getStr().find(ArgTypePrefix) == 0; });
@@ -3874,7 +3878,7 @@ static bool transKernelArgTypeMedataFromString(LLVMContext *Ctx,
38743878
}
38753879
}
38763880

3877-
Kernel->setMetadata(SPIR_MD_KERNEL_ARG_TYPE, MDNode::get(*Ctx, TypeMDs));
3881+
Kernel->setMetadata(MDName, MDNode::get(*Ctx, TypeMDs));
38783882
return true;
38793883
}
38803884

@@ -3993,29 +3997,32 @@ bool SPIRVToLLVM::transOCLMetadata(SPIRVFunction *BF) {
39933997
return MDString::get(*Context, Qual);
39943998
});
39953999
// Generate metadata for kernel_arg_type
3996-
if (!transKernelArgTypeMedataFromString(Context, BM, F))
4000+
if (!transKernelArgTypeMedataFromString(Context, BM, F,
4001+
SPIR_MD_KERNEL_ARG_TYPE))
39974002
addOCLKernelArgumentMetadata(Context, SPIR_MD_KERNEL_ARG_TYPE, BF, F,
39984003
[=](SPIRVFunctionParameter *Arg) {
39994004
return transOCLKernelArgTypeName(Arg);
40004005
});
40014006
// Generate metadata for kernel_arg_type_qual
4002-
addOCLKernelArgumentMetadata(
4003-
Context, SPIR_MD_KERNEL_ARG_TYPE_QUAL, BF, F,
4004-
[=](SPIRVFunctionParameter *Arg) {
4005-
std::string Qual;
4006-
if (Arg->hasDecorate(DecorationVolatile))
4007-
Qual = kOCLTypeQualifierName::Volatile;
4008-
Arg->foreachAttr([&](SPIRVFuncParamAttrKind Kind) {
4009-
Qual += Qual.empty() ? "" : " ";
4010-
if (Kind == FunctionParameterAttributeNoAlias)
4011-
Qual += kOCLTypeQualifierName::Restrict;
4007+
if (!transKernelArgTypeMedataFromString(Context, BM, F,
4008+
SPIR_MD_KERNEL_ARG_TYPE_QUAL))
4009+
addOCLKernelArgumentMetadata(
4010+
Context, SPIR_MD_KERNEL_ARG_TYPE_QUAL, BF, F,
4011+
[=](SPIRVFunctionParameter *Arg) {
4012+
std::string Qual;
4013+
if (Arg->hasDecorate(DecorationVolatile))
4014+
Qual = kOCLTypeQualifierName::Volatile;
4015+
Arg->foreachAttr([&](SPIRVFuncParamAttrKind Kind) {
4016+
Qual += Qual.empty() ? "" : " ";
4017+
if (Kind == FunctionParameterAttributeNoAlias)
4018+
Qual += kOCLTypeQualifierName::Restrict;
4019+
});
4020+
if (Arg->getType()->isTypePipe()) {
4021+
Qual += Qual.empty() ? "" : " ";
4022+
Qual += kOCLTypeQualifierName::Pipe;
4023+
}
4024+
return MDString::get(*Context, Qual);
40124025
});
4013-
if (Arg->getType()->isTypePipe()) {
4014-
Qual += Qual.empty() ? "" : " ";
4015-
Qual += kOCLTypeQualifierName::Pipe;
4016-
}
4017-
return MDString::get(*Context, Qual);
4018-
});
40194026
// Generate metadata for kernel_arg_base_type
40204027
addOCLKernelArgumentMetadata(Context, SPIR_MD_KERNEL_ARG_BASE_TYPE, BF, F,
40214028
[=](SPIRVFunctionParameter *Arg) {

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3345,6 +3345,16 @@ bool LLVMToSPIRVBase::transMetadata() {
33453345
return true;
33463346
}
33473347

3348+
// Work around to translate kernel_arg_type and kernel_arg_type_qual metadata
3349+
static void transKernelArgTypeMD(SPIRVModule *BM, Function *F, MDNode *MD,
3350+
std::string MDName) {
3351+
std::string KernelArgTypesMDStr =
3352+
std::string(MDName) + "." + F->getName().str() + ".";
3353+
for (const auto &TyOp : MD->operands())
3354+
KernelArgTypesMDStr += cast<MDString>(TyOp)->getString().str() + ",";
3355+
BM->getString(KernelArgTypesMDStr);
3356+
}
3357+
33483358
bool LLVMToSPIRVBase::transOCLMetadata() {
33493359
for (auto &F : *M) {
33503360
if (F.getCallingConv() != CallingConv::SPIR_KERNEL)
@@ -3356,13 +3366,9 @@ bool LLVMToSPIRVBase::transOCLMetadata() {
33563366
// Create 'OpString' as a workaround to store information about
33573367
// *orignal* (typedef'ed, unsigned integers) type names of kernel arguments.
33583368
// OpString "kernel_arg_type.%kernel_name%.typename0,typename1,..."
3359-
if (auto *KernelArgType = F.getMetadata(SPIR_MD_KERNEL_ARG_TYPE)) {
3360-
std::string KernelArgTypesStr =
3361-
std::string(SPIR_MD_KERNEL_ARG_TYPE) + "." + F.getName().str() + ".";
3362-
for (const auto &TyOp : KernelArgType->operands())
3363-
KernelArgTypesStr += cast<MDString>(TyOp)->getString().str() + ",";
3364-
BM->getString(KernelArgTypesStr);
3365-
}
3369+
if (auto *KernelArgType = F.getMetadata(SPIR_MD_KERNEL_ARG_TYPE))
3370+
if (BM->shouldPreserveOCLKernelArgTypeMetadataThroughString())
3371+
transKernelArgTypeMD(BM, &F, KernelArgType, SPIR_MD_KERNEL_ARG_TYPE);
33663372

33673373
if (auto *KernelArgTypeQual = F.getMetadata(SPIR_MD_KERNEL_ARG_TYPE_QUAL)) {
33683374
foreachKernelArgMD(
@@ -3375,6 +3381,13 @@ bool LLVMToSPIRVBase::transOCLMetadata() {
33753381
new SPIRVDecorate(DecorationFuncParamAttr, BA,
33763382
FunctionParameterAttributeNoAlias));
33773383
});
3384+
// Create 'OpString' as a workaround to store information about
3385+
// constant qualifiers of pointer kernel arguments. Store empty string
3386+
// for a non constant parameter.
3387+
// OpString "kernel_arg_type_qual.%kernel_name%.qual0,qual1,..."
3388+
if (BM->shouldPreserveOCLKernelArgTypeMetadataThroughString())
3389+
transKernelArgTypeMD(BM, &F, KernelArgTypeQual,
3390+
SPIR_MD_KERNEL_ARG_TYPE_QUAL);
33783391
}
33793392
if (auto *KernelArgName = F.getMetadata(SPIR_MD_KERNEL_ARG_NAME)) {
33803393
foreachKernelArgMD(

lib/SPIRV/libSPIRV/SPIRVModule.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@ class SPIRVModule {
496496
return TranslationOpts.shouldReplaceLLVMFmulAddWithOpenCLMad();
497497
}
498498

499+
bool shouldPreserveOCLKernelArgTypeMetadataThroughString() const noexcept {
500+
return TranslationOpts
501+
.shouldPreserveOCLKernelArgTypeMetadataThroughString();
502+
}
503+
499504
SPIRVExtInstSetKind getDebugInfoEIS() const {
500505
switch (TranslationOpts.getDebugInfoEIS()) {
501506
case DebugInfoEIS::SPIRV_Debug:

test/kernel-arg-ext_int-ptr.spt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@
2525

2626
; RUN: llvm-spirv %s -to-binary -o %t.spv
2727
; Reverse translation shouldn't crash:
28+
; RUN: llvm-spirv -r -preserve-ocl-kernel-arg-type-metadata-through-string %t.spv -o %t.bc
29+
; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-LLVM-STR-WORKAROUND
2830
; RUN: llvm-spirv -r %t.spv -o %t.bc
29-
; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-LLVM
31+
; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-LLVM-NO-WORKAROUND
3032

31-
; CHECK-LLVM: define spir_kernel void @kernel_func1(i31 addrspace(1)* %_arg_){{.*}} !kernel_arg_type ![[ArgTy:[0-9]+]]{{.*}} !kernel_arg_base_type ![[BaseArgTy:[0-9]+]]
32-
; CHECK-LLVM: ![[ArgTy]] = !{!"_ExtInt(31)*"}
33-
; CHECK-LLVM: ![[BaseArgTy]] = !{!"int31_t*"}
33+
; CHECK-LLVM-STR-WORKAROUND: define spir_kernel void @kernel_func1(i31 addrspace(1)* %_arg_){{.*}} !kernel_arg_type ![[ArgTy:[0-9]+]]{{.*}} !kernel_arg_base_type ![[BaseArgTy:[0-9]+]]
34+
; CHECK-LLVM-STR-WORKAROUND: ![[ArgTy]] = !{!"_ExtInt(31)*"}
35+
; CHECK-LLVM-STR-WORKAROUND: ![[BaseArgTy]] = !{!"int31_t*"}
36+
; CHECK-LLVM-NO-WORKAROUND: define spir_kernel void @kernel_func1(i31 addrspace(1)* %_arg_){{.*}} !kernel_arg_type ![[ArgTy:[0-9]+]]{{.*}} !kernel_arg_base_type ![[ArgTy:[0-9]+]]
37+
; CHECK-LLVM-NO-WORKAROUND: ![[ArgTy]] = !{!"int31_t*"}

test/transcoding/KernelArgTypeInOpString.ll

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,31 @@
2121
; OpString "kernel_arg_type.%kernel_name%.typename0,typename1,..."
2222

2323
; RUN: llvm-as %s -o %t.bc
24+
; RUN: llvm-spirv -preserve-ocl-kernel-arg-type-metadata-through-string %t.bc -spirv-text -o %t.spv.txt
25+
; RUN: FileCheck < %t.spv.txt %s --check-prefix=CHECK-SPIRV-WORKAROUND
2426
; RUN: llvm-spirv %t.bc -spirv-text -o %t.spv.txt
25-
; RUN: FileCheck < %t.spv.txt %s --check-prefix=CHECK-SPIRV
27+
; RUN: FileCheck < %t.spv.txt %s --check-prefix=CHECK-SPIRV-WORKAROUND-NEGATIVE
28+
; RUN: llvm-spirv -preserve-ocl-kernel-arg-type-metadata-through-string %t.bc -o %t.spv
29+
; RUN: spirv-val %t.spv
30+
; RUN: llvm-spirv -r -preserve-ocl-kernel-arg-type-metadata-through-string %t.spv -o %t.rev.bc
31+
; RUN: llvm-dis %t.rev.bc
32+
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM-WORKAROUND
2633
; RUN: llvm-spirv %t.bc -o %t.spv
2734
; RUN: spirv-val %t.spv
2835
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
2936
; RUN: llvm-dis %t.rev.bc
30-
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM
37+
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM-WORKAROUND-NEGATIVE
3138

3239
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
3340
target triple = "spir-unknown-unknown"
3441

35-
; CHECK-SPIRV: String 14 "kernel_arg_type.foo.image_kernel_data*,myInt,struct struct_name*,"
42+
; CHECK-SPIRV-WORKAROUND: String 14 "kernel_arg_type.foo.image_kernel_data*,myInt,struct struct_name*,"
43+
; CHECK-SPIRV-WORKAROUND-NEGATIVE-NOT: String 14 "kernel_arg_type.foo.image_kernel_data*,myInt,struct struct_name*,"
3644

37-
; CHECK-LLVM: !kernel_arg_type [[TYPE:![0-9]+]]
38-
; CHECK-LLVM: [[TYPE]] = !{!"image_kernel_data*", !"myInt", !"struct struct_name*"}
45+
; CHECK-LLVM-WORKAROUND: !kernel_arg_type [[TYPE:![0-9]+]]
46+
; CHECK-LLVM-WORKAROUND: [[TYPE]] = !{!"image_kernel_data*", !"myInt", !"struct struct_name*"}
47+
; CHECK-LLVM-WORKAROUND-NEGATIVE: !kernel_arg_type [[TYPE:![0-9]+]]
48+
; CHECK-LLVM-WORKAROUND-NEGATIVE-NOT: [[TYPE]] = !{!"image_kernel_data*", !"myInt", !"struct struct_name*"}
3949

4050
%struct.image_kernel_data = type { i32, i32, i32, i32, i32 }
4151
%struct.struct_name = type { i32, i32 }

test/transcoding/KernelArgTypeInOpString2.ll

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,31 @@
2323
; OpString "kernel_arg_type.%kernel_name%.typename0,typename1,..."
2424

2525
; RUN: llvm-as %s -o %t.bc
26+
; RUN: llvm-spirv -preserve-ocl-kernel-arg-type-metadata-through-string %t.bc -spirv-text -o %t.spv.txt
27+
; RUN: FileCheck < %t.spv.txt %s --check-prefix=CHECK-SPIRV-WORKAROUND
2628
; RUN: llvm-spirv %t.bc -spirv-text -o %t.spv.txt
27-
; RUN: FileCheck < %t.spv.txt %s --check-prefix=CHECK-SPIRV
29+
; RUN: FileCheck < %t.spv.txt %s --check-prefix=CHECK-SPIRV-WORKAROUND-NEGATIVE
30+
; RUN: llvm-spirv -preserve-ocl-kernel-arg-type-metadata-through-string %t.bc -o %t.spv
31+
; RUN: spirv-val %t.spv
32+
; RUN: llvm-spirv -r -preserve-ocl-kernel-arg-type-metadata-through-string %t.spv -o %t.rev.bc
33+
; RUN: llvm-dis %t.rev.bc
34+
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM-WORKAROUND
2835
; RUN: llvm-spirv %t.bc -o %t.spv
2936
; RUN: spirv-val %t.spv
3037
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
3138
; RUN: llvm-dis %t.rev.bc
32-
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM
39+
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM-WORKAROUND-NEGATIVE
3340

3441
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
3542
target triple = "spir"
3643

37-
; CHECK-SPIRV: String 17 "kernel_arg_type.foo.cl::tt::vec<float, 4>*,"
44+
; CHECK-SPIRV-WORKAROUND: String 17 "kernel_arg_type.foo.cl::tt::vec<float, 4>*,"
45+
; CHECK-SPIRV-WORKAROUND-NEGATIVE-NOT: String 17 "kernel_arg_type.foo.cl::tt::vec<float, 4>*,"
3846

39-
; CHECK-LLVM: !kernel_arg_type [[TYPE:![0-9]+]]
40-
; CHECK-LLVM: [[TYPE]] = !{!"cl::tt::vec<float, 4>*"}
47+
; CHECK-LLVM-WORKAROUND: !kernel_arg_type [[TYPE:![0-9]+]]
48+
; CHECK-LLVM-WORKAROUND: [[TYPE]] = !{!"cl::tt::vec<float, 4>*"}
49+
; CHECK-LLVM-WORKAROUND-NEGATIVE: !kernel_arg_type [[TYPE:![0-9]+]]
50+
; CHECK-LLVM-WORKAROUND-NEGATIVE-NOT: [[TYPE]] = !{!"cl::tt::vec<float, 4>*"}
4151

4252
%"class.cl::tt::vec" = type { [4 x float] }
4353

test/transcoding/cl-types.ll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ target triple = "spir-unknown-unknown"
9494
; CHECK-LLVM-SAME: !kernel_arg_access_qual [[AQ:![0-9]+]]
9595
; CHECK-LLVM-SAME: !kernel_arg_type [[TYPE:![0-9]+]]
9696
; CHECK-LLVM-SAME: !kernel_arg_type_qual [[TQ:![0-9]+]]
97-
; CHECK-LLVM-SAME: !kernel_arg_base_type [[BT:![0-9]+]]
97+
; CHECK-LLVM-SAME: !kernel_arg_base_type [[TYPE]]
9898

9999
; Function Attrs: nounwind readnone
100100
define spir_kernel void @foo(
@@ -138,8 +138,7 @@ attributes #0 = { nounwind readnone "less-precise-fpmad"="false" "no-frame-point
138138

139139
; CHECK-LLVM-DAG: [[AS]] = !{i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 0}
140140
; CHECK-LLVM-DAG: [[AQ]] = !{!"read_only", !"write_only", !"read_only", !"read_only", !"read_only", !"read_only", !"read_only", !"write_only", !"read_write", !"none"}
141-
; CHECK-LLVM-DAG: [[TYPE]] = !{!"int", !"int", !"image1d_t", !"image2d_t", !"image3d_t", !"image2d_array_t", !"image1d_buffer_t", !"image1d_t", !"image2d_t", !"sampler_t"}
142-
; CHECK-LLVM-DAG: [[BT]] = !{!"pipe", !"pipe", !"image1d_t", !"image2d_t", !"image3d_t", !"image2d_array_t", !"image1d_buffer_t", !"image1d_t", !"image2d_t", !"sampler_t"}
141+
; CHECK-LLVM-DAG: [[TYPE]] = !{!"pipe", !"pipe", !"image1d_t", !"image2d_t", !"image3d_t", !"image2d_array_t", !"image1d_buffer_t", !"image1d_t", !"image2d_t", !"sampler_t"}
143142
; CHECK-LLVM-DAG: [[TQ]] = !{!"pipe", !"pipe", !"", !"", !"", !"", !"", !"", !"", !""}
144143

145144
!1 = !{i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 0}

test/transcoding/kernel_arg_name.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
; CHECK: spir_kernel void @unnamed_arg(float{{.*}}) {{.*}} !kernel_arg_name ![[MD_unnamed:[0-9]+]]
66
; CHECK: spir_kernel void @one_unnamed_arg(i8 %a, i8 %b, i8{{.*}}) {{.*}} !kernel_arg_name ![[MD_one_unnamed:[0-9]+]]
77

8-
; CHECK: ![[MD_unnamed]] = !{!""}
9-
; CHECK: ![[MD_named]] = !{!"f"}
10-
; CHECK: ![[MD_one_unnamed]] = !{!"a", !"b", !""}
8+
; CHECK-DAG: ![[MD_named]] = !{!"f"}
9+
; CHECK-DAG: ![[MD_unnamed]] = !{!""}
10+
; CHECK-DAG: ![[MD_one_unnamed]] = !{!"a", !"b", !""}
1111

1212
; ModuleID = 'kernel_arg_name.ll'
1313
source_filename = "kernel_arg_name.ll"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
; RUN: llvm-as %s -o %t.bc
2+
; RUN: llvm-spirv -preserve-ocl-kernel-arg-type-metadata-through-string %t.bc -o - -spirv-text | FileCheck %s --check-prefix=CHECK-SPIRV
3+
; RUN: llvm-spirv %t.bc -o - -spirv-text | FileCheck %s --check-prefix=CHECK-SPIRV-NEGATIVE
4+
; RUN: llvm-spirv -preserve-ocl-kernel-arg-type-metadata-through-string %t.bc -o %t.spv
5+
; RUN: llvm-spirv -r -preserve-ocl-kernel-arg-type-metadata-through-string %t.spv -o %t.rev.bc
6+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-WORKAROUND
7+
; RUN: llvm-spirv %t.bc -o %t.spv
8+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
9+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-WORKAROUND-NEGATIVE
10+
11+
; ModuleID = 'test.cl'
12+
source_filename = "test.cl"
13+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
14+
target triple = "spir64-unknown-unknown."
15+
16+
; CHECK-SPIRV: String 12 "kernel_arg_type_qual.test.volatile,const,,"
17+
; CHECK-SPIRV: Name [[ARG:[0-9]+]] "g"
18+
; CHECK-SPIRV: Decorate [[ARG]] Volatile
19+
; CHECK-SPIRV-NEGATIVE-NOT: String 12 "kernel_arg_type_qual.test.volatile,const,,"
20+
21+
; CHECK-LLVM-WORKAROUND: !kernel_arg_type_qual ![[QUAL:[0-9]+]]
22+
; CHECK-LLVM-WORKAROUND: ![[QUAL]] = !{!"volatile", !"const", !""}
23+
; CHECK-LLVM-WORKAROUND-NEGATIVE: !kernel_arg_type_qual
24+
25+
; Function Attrs: convergent noinline norecurse nounwind optnone
26+
define dso_local spir_kernel void @test(float addrspace(1)* %g, float addrspace(1)* %c, float addrspace(1)* %asd) #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !5 !kernel_arg_base_type !5 !kernel_arg_type_qual !6 {
27+
entry:
28+
ret void
29+
}
30+
31+
attributes #1 = { convergent noinline norecurse nounwind optnone }
32+
33+
!llvm.module.flags = !{!0}
34+
!opencl.ocl.version = !{!1}
35+
!llvm.ident = !{!2}
36+
37+
!0 = !{i32 1, !"wchar_size", i32 4}
38+
!1 = !{i32 1, i32 0}
39+
!2 = !{!"clang version 13.0.0"}
40+
!3 = !{i32 1, i32 1}
41+
!4 = !{!"none", !"none"}
42+
!5 = !{!"float*", !"float*"}
43+
!6 = !{!"volatile", !"const", !""}

0 commit comments

Comments
 (0)