[PATCH] D62657: [OpenCL] Fix OpenCL/SPIR version metadata
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 30 11:10:48 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rC362102: [OpenCL] Fix OpenCL/SPIR version metadata in C++ mode. (authored by stulova, committed by ).
Herald added a project: clang.
Changed prior to commit:
https://reviews.llvm.org/D62657?vs=202169&id=202241#toc
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62657/new/
https://reviews.llvm.org/D62657
Files:
lib/CodeGen/CodeGenModule.cpp
test/CodeGenOpenCL/spir_version.cl
Index: test/CodeGenOpenCL/spir_version.cl
===================================================================
--- test/CodeGenOpenCL/spir_version.cl
+++ test/CodeGenOpenCL/spir_version.cl
@@ -5,6 +5,9 @@
// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - -cl-std=CL1.2 | FileCheck %s --check-prefix=CHECK-SPIR-CL12
// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - -cl-std=CL2.0 | FileCheck %s --check-prefix=CHECK-SPIR-CL20
+
+// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - -cl-std=c++ | FileCheck %s --check-prefix=CHECK-SPIR-CL20
+
// RUN: %clang_cc1 %s -triple "amdgcn--amdhsa" -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-AMDGCN-CL10
// RUN: %clang_cc1 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -cl-std=CL1.2 | FileCheck %s --check-prefix=CHECK-AMDGCN-CL12
// RUN: %clang_cc1 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -cl-std=CL2.0 | FileCheck %s --check-prefix=CHECK-AMDGCN-CL20
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -564,11 +564,13 @@
if (getTriple().isSPIR()) {
// SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the
// opencl.spir.version named metadata.
+ // C++ is backwards compatible with OpenCL v2.0.
+ auto Version = LangOpts.OpenCLCPlusPlus ? 200 : LangOpts.OpenCLVersion;
llvm::Metadata *SPIRVerElts[] = {
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
- Int32Ty, LangOpts.OpenCLVersion / 100)),
+ Int32Ty, Version / 100)),
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
- Int32Ty, (LangOpts.OpenCLVersion / 100 > 1) ? 0 : 2))};
+ Int32Ty, (Version / 100 > 1) ? 0 : 2))};
llvm::NamedMDNode *SPIRVerMD =
TheModule.getOrInsertNamedMetadata("opencl.spir.version");
llvm::LLVMContext &Ctx = TheModule.getContext();
@@ -623,11 +625,14 @@
void CodeGenModule::EmitOpenCLMetadata() {
// SPIR v2.0 s2.13 - The OpenCL version used by the module is stored in the
// opencl.ocl.version named metadata node.
+ // C++ is backwards compatible with OpenCL v2.0.
+ // FIXME: We might need to add CXX version at some point too?
+ auto Version = LangOpts.OpenCLCPlusPlus ? 200 : LangOpts.OpenCLVersion;
llvm::Metadata *OCLVerElts[] = {
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
- Int32Ty, LangOpts.OpenCLVersion / 100)),
+ Int32Ty, Version / 100)),
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
- Int32Ty, (LangOpts.OpenCLVersion % 100) / 10))};
+ Int32Ty, (Version % 100) / 10))};
llvm::NamedMDNode *OCLVerMD =
TheModule.getOrInsertNamedMetadata("opencl.ocl.version");
llvm::LLVMContext &Ctx = TheModule.getContext();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62657.202241.patch
Type: text/x-patch
Size: 2902 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190530/01c2e25e/attachment.bin>
More information about the cfe-commits
mailing list