Author: bader Date: Wed Dec 7 02:38:24 2016 New Revision: 288890 URL: http://llvm.org/viewvc/llvm-project?rev=288890&view=rev Log: [OpenCL] Fix SPIR version generation.
Patch by Egor Churaev (echuraev). Reviewers: Anastasia Subscribers: bader, yaxunl, cfe-commits Differential Revision: https://reviews.llvm.org/D27300 Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/test/CodeGenOpenCL/spir_version.cl Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=288890&r1=288889&r2=288890&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Dec 7 02:38:24 2016 @@ -7801,8 +7801,10 @@ void SPIRTargetCodeGenInfo::emitTargetMD // 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)); Modified: cfe/trunk/test/CodeGenOpenCL/spir_version.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/spir_version.cl?rev=288890&r1=288889&r2=288890&view=diff ============================================================================== --- cfe/trunk/test/CodeGenOpenCL/spir_version.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/spir_version.cl Wed Dec 7 02:38:24 2016 @@ -13,19 +13,22 @@ kernel void foo() {} // 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-CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]} -// CHECK-SPIR-CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]} -// CHECK-SPIR-CL20: [[SPIR]] = !{i32 2, i32 0} +// 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 = !{[[VER:![0-9]+]]} +// CHECK-SPIR-CL20: !opencl.ocl.version = !{[[VER]]} +// CHECK-SPIR-CL20: [[VER]] = !{i32 2, i32 0} + +// CHECK-AMDGCN-CL10-NOT: !opencl.spir.version // CHECK-AMDGCN-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]} // CHECK-AMDGCN-CL10: [[OCL]] = !{i32 1, i32 0} +// CHECK-AMDGCN-CL12-NOT: !opencl.spir.version // CHECK-AMDGCN-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]} // CHECK-AMDGCN-CL12: [[OCL]] = !{i32 1, i32 2} +// CHECK-AMDGCN-CL20-NOT: !opencl.spir.version // 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} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits