diff options
author | Anastasia Stulova <anastasia.stulova@arm.com> | 2019-05-30 15:18:07 +0000 |
---|---|---|
committer | Anastasia Stulova <anastasia.stulova@arm.com> | 2019-05-30 15:18:07 +0000 |
commit | 3fe47eab4520a5fdfe3b83aa88ef6a9f46bc5330 (patch) | |
tree | 436a149540513d11da81038f2ef8b039817ea333 /lib/CodeGen/CodeGenModule.cpp | |
parent | 97024bd353aed8d47cfabd3b7a329b1668d2bdde (diff) | |
download | clang-3fe47eab4520a5fdfe3b83aa88ef6a9f46bc5330.tar.gz |
[OpenCL] Fix OpenCL/SPIR version metadata in C++ mode.
C++ is derived from OpenCL v2.0 therefore set the versions
identically.
Differential Revision: https://reviews.llvm.org/D62657
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@362102 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 8cfb4e60e0..e79eb71b79 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -564,11 +564,13 @@ void CodeGenModule::Release() { 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::Release() { 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(); |