This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rG15a1769631ff: Emit OpenCL metadata when targeting SPIR-V (authored by shangwuyao).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123049/new/ https://reviews.llvm.org/D123049 Files: clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGenCUDASPIRV/kernel-cc.cu Index: clang/test/CodeGenCUDASPIRV/kernel-cc.cu =================================================================== --- clang/test/CodeGenCUDASPIRV/kernel-cc.cu +++ clang/test/CodeGenCUDASPIRV/kernel-cc.cu @@ -7,3 +7,6 @@ // CHECK: define spir_kernel void @_Z6kernelv() __attribute__((global)) void kernel() { return; } + +// CHECK: !opencl.ocl.version = !{[[OCL:![0-9]+]]} +// CHECK: [[OCL]] = !{i32 2, i32 0} Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -3328,6 +3328,10 @@ // whereas respecting contract flag in backend. Opts.setDefaultFPContractMode(LangOptions::FPM_FastHonorPragmas); } else if (Opts.CUDA) { + if (T.isSPIRV()) { + // Emit OpenCL version metadata in LLVM IR when targeting SPIR-V. + Opts.OpenCLVersion = 200; + } // Allow fuse across statements disregarding pragmas. Opts.setDefaultFPContractMode(LangOptions::FPM_Fast); } Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -784,7 +784,7 @@ LangOpts.OpenMP); // Emit OpenCL specific module metadata: OpenCL/SPIR version. - if (LangOpts.OpenCL) { + if (LangOpts.OpenCL || (LangOpts.CUDAIsDevice && getTriple().isSPIRV())) { EmitOpenCLMetadata(); // Emit SPIR version. if (getTriple().isSPIR()) {
Index: clang/test/CodeGenCUDASPIRV/kernel-cc.cu =================================================================== --- clang/test/CodeGenCUDASPIRV/kernel-cc.cu +++ clang/test/CodeGenCUDASPIRV/kernel-cc.cu @@ -7,3 +7,6 @@ // CHECK: define spir_kernel void @_Z6kernelv() __attribute__((global)) void kernel() { return; } + +// CHECK: !opencl.ocl.version = !{[[OCL:![0-9]+]]} +// CHECK: [[OCL]] = !{i32 2, i32 0} Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -3328,6 +3328,10 @@ // whereas respecting contract flag in backend. Opts.setDefaultFPContractMode(LangOptions::FPM_FastHonorPragmas); } else if (Opts.CUDA) { + if (T.isSPIRV()) { + // Emit OpenCL version metadata in LLVM IR when targeting SPIR-V. + Opts.OpenCLVersion = 200; + } // Allow fuse across statements disregarding pragmas. Opts.setDefaultFPContractMode(LangOptions::FPM_Fast); } Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -784,7 +784,7 @@ LangOpts.OpenMP); // Emit OpenCL specific module metadata: OpenCL/SPIR version. - if (LangOpts.OpenCL) { + if (LangOpts.OpenCL || (LangOpts.CUDAIsDevice && getTriple().isSPIRV())) { EmitOpenCLMetadata(); // Emit SPIR version. if (getTriple().isSPIR()) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits