File tree 3 files changed +42
-0
lines changed
modules/compiler/spirv-ll
3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -2583,6 +2583,11 @@ cargo::optional<Error> Builder::create<OpVariable>(const OpVariable *op) {
2583
2583
case spv::StorageClassFunction: {
2584
2584
// Visible only within the declaring function of the current
2585
2585
// invocation. Regular function memory.
2586
+ if (!IRBuilder.GetInsertBlock ()) {
2587
+ return Error{
2588
+ " invalid SPIR-V: variables can not have a function[7] "
2589
+ " storage class outside of a function" };
2590
+ }
2586
2591
value = IRBuilder.CreateAlloca (varTy);
2587
2592
value->setName (name);
2588
2593
if (initializer) {
Original file line number Diff line number Diff line change @@ -2362,6 +2362,7 @@ set(SPVASM_FILES
2362
2362
op_opencl_arg_md.spvasm
2363
2363
unsupported_capability.spvasm
2364
2364
op_get_kernel_preferred_work_group_size_multiple.spvasm
2365
+ invalid_storage_class.spvasm
2365
2366
)
2366
2367
2367
2368
if (SpirvAsVersionYear GREATER 2019)
Original file line number Diff line number Diff line change
1
+ ; Copyright (C) Codeplay Software Limited
2
+ ;
3
+ ; Licensed under the Apache License, Version 2.0 (the "License") with LLVM
4
+ ; Exceptions; you may not use this file except in compliance with the License.
5
+ ; You may obtain a copy of the License at
6
+ ;
7
+ ; https://github.com/codeplaysoftware/oneapi-construction-kit/blob/main/LICENSE.txt
8
+ ;
9
+ ; Unless required by applicable law or agreed to in writing, software
10
+ ; distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ ; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ ; License for the specific language governing permissions and limitations
13
+ ; under the License.
14
+ ;
15
+ ; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
16
+
17
+ ; It is invalid to use the 'Function' storage class outside of a function.
18
+ ; Ensure we gracefully fail when we encounter this.
19
+
20
+ ; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
21
+ ; RUN: not spirv-ll-tool -a OpenCL -b 64 %spv_file_s 2>&1 | FileCheck %s
22
+
23
+ ; CHECK: variables can not have a function[7] storage class outside of a function
24
+
25
+ OpCapability Addresses
26
+ OpCapability Linkage
27
+ OpCapability Kernel
28
+ OpCapability Int64
29
+ OpCapability Int8
30
+ %1 = OpExtInstImport "OpenCL.std"
31
+ OpMemoryModel Physical64 OpenCL
32
+ OpEntryPoint Kernel %54 "_ZTSZN24kernel_bundle_spec_constL22CATCH2_INTERNAL_TEST_4EvE13simple_kernel"
33
+ OpSource OpenCL_CPP 100000
34
+ %uint = OpTypeInt 32 0
35
+ %_ptr_Function_uint = OpTypePointer Function %uint
36
+ %my_ptr = OpVariable %_ptr_Function_uint Function
You can’t perform that action at this time.
0 commit comments