mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-01 10:46:07 +00:00

Currently there is no way to tell whether an IR module was generated using `-cl-std=cl3.0` or `-cl-std=clc++2021`, i.e., whether the origin was a OpenCL C or C++ for OpenCL source. Add new `opencl.cxx.version` named metadata when compiling C++. Keep the `opencl.ocl.version` metadata to convey the compatible OpenCL C version. Fixes https://github.com/llvm/llvm-project/issues/91912
22 lines
1.1 KiB
Plaintext
22 lines
1.1 KiB
Plaintext
// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - -cl-std=CL2.0 | FileCheck %s --check-prefix=CHECK-NO-CXX
|
|
|
|
// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - -cl-std=clc++1.0 | FileCheck %s --check-prefix=CHECK-CXX100
|
|
// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - -cl-std=clc++2021 | FileCheck %s --check-prefix=CHECK-CXX2021
|
|
|
|
// This test checks that opencl.cxx.version metadata is emitted accordingly.
|
|
// It avoids any C++ features to enable checking that the metadata is not emitted in non-C++ mode.
|
|
|
|
kernel void foo() {}
|
|
|
|
// CHECK-NO-CXX-NOT: opencl.cxx.version
|
|
|
|
// CHECK-CXX100-DAG: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
|
|
// CHECK-CXX100-DAG: !opencl.cxx.version = !{[[CXX:![0-9]+]]}
|
|
// CHECK-CXX100-DAG: [[OCL]] = !{i32 2, i32 0}
|
|
// CHECK-CXX100-DAG: [[CXX]] = !{i32 1, i32 0}
|
|
|
|
// CHECK-CXX2021-DAG: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
|
|
// CHECK-CXX2021-DAG: !opencl.cxx.version = !{[[CXX:![0-9]+]]}
|
|
// CHECK-CXX2021-DAG: [[OCL]] = !{i32 3, i32 0}
|
|
// CHECK-CXX2021-DAG: [[CXX]] = !{i32 2021, i32 0}
|