[PATCH] D27300: [OpenCL] Fix SPIR version generation.

Egor Churaev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 2 00:24:20 PST 2016


echuraev updated this revision to Diff 80034.
echuraev marked 3 inline comments as done.

https://reviews.llvm.org/D27300

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenOpenCL/spir_version.cl


Index: test/CodeGenOpenCL/spir_version.cl
===================================================================
--- test/CodeGenOpenCL/spir_version.cl
+++ test/CodeGenOpenCL/spir_version.cl
@@ -13,12 +13,12 @@
 
 // CHECK-SPIR-CL10: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
 // CHECK-SPIR-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-SPIR-CL10: [[SPIR]] = !{i32 2, i32 0}
+// CHECK-SPIR-CL10: [[SPIR]] = !{i32 1, i32 2}
 // CHECK-SPIR-CL10: [[OCL]] = !{i32 1, i32 0}
-// CHECK-SPIR-CL12: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
-// CHECK-SPIR-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-SPIR-CL12: [[SPIR]] = !{i32 2, i32 0}
-// CHECK-SPIR-CL12: [[OCL]] = !{i32 1, i32 2}
+// CHECK-SPIR-CL12: !opencl.spir.version = !{[[VER:![0-9]+]]}
+// CHECK-SPIR-CL12: !opencl.ocl.version = !{[[VER]]}
+// CHECK-SPIR-CL12: [[VER]] = !{i32 1, i32 2}
+
 // CHECK-SPIR-CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
 // CHECK-SPIR-CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]}
 // CHECK-SPIR-CL20: [[SPIR]] = !{i32 2, i32 0}
@@ -28,4 +28,4 @@
 // CHECK-AMDGCN-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
 // CHECK-AMDGCN-CL12: [[OCL]] = !{i32 1, i32 2}
 // CHECK-AMDGCN-CL20: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0}
\ No newline at end of file
+// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0}
Index: lib/CodeGen/TargetInfo.cpp
===================================================================
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7778,8 +7778,10 @@
   // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the
   // opencl.spir.version named metadata.
   llvm::Metadata *SPIRVerElts[] = {
-      llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 2)),
-      llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 0))};
+      llvm::ConstantAsMetadata::get(
+          llvm::ConstantInt::get(Int32Ty, CGM.getLangOpts().OpenCLVersion / 100)),
+      llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
+          Int32Ty, (CGM.getLangOpts().OpenCLVersion / 100 > 1) ? 0 : 2))};
   llvm::NamedMDNode *SPIRVerMD =
       M.getOrInsertNamedMetadata("opencl.spir.version");
   SPIRVerMD->addOperand(llvm::MDNode::get(Ctx, SPIRVerElts));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27300.80034.patch
Type: text/x-patch
Size: 2268 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161202/3da462d2/attachment.bin>


More information about the cfe-commits mailing list