Author: hans Date: Thu Jul 28 18:18:47 2016 New Revision: 277079 URL: http://llvm.org/viewvc/llvm-project?rev=277079&view=rev Log: Merging r276119: ------------------------------------------------------------------------ r276119 | yaxunl | 2016-07-20 07:38:06 -0700 (Wed, 20 Jul 2016) | 3 lines
AMDGPU: Fix bug causing crash due to invalid opencl version metadata. Differential Revision: https://reviews.llvm.org/D22526 ------------------------------------------------------------------------ Added: llvm/branches/release_39/test/CodeGen/AMDGPU/invalid-opencl-version-metadata1.ll - copied unchanged from r276119, llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata1.ll llvm/branches/release_39/test/CodeGen/AMDGPU/invalid-opencl-version-metadata2.ll - copied unchanged from r276119, llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata2.ll llvm/branches/release_39/test/CodeGen/AMDGPU/invalid-opencl-version-metadata3.ll - copied unchanged from r276119, llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata3.ll Modified: llvm/branches/release_39/ (props changed) llvm/branches/release_39/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp Propchange: llvm/branches/release_39/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Jul 28 18:18:47 2016 @@ -1,3 +1,3 @@ /llvm/branches/Apple/Pertwee:110850,110961 /llvm/branches/type-system-rewrite:133420-134817 -/llvm/trunk:155241,275868-275870,275879,275898,275928,275935,275946,275978,275981,276015,276077,276109,276181,276209,276236-276237,276358,276364,276368,276389,276438,276479,276510,276740,276956 +/llvm/trunk:155241,275868-275870,275879,275898,275928,275935,275946,275978,275981,276015,276077,276109,276119,276181,276209,276236-276237,276358,276364,276368,276389,276438,276479,276510,276740,276956 Modified: llvm/branches/release_39/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp?rev=277079&r1=277078&r2=277079&view=diff ============================================================================== --- llvm/branches/release_39/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp (original) +++ llvm/branches/release_39/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp Thu Jul 28 18:18:47 2016 @@ -783,15 +783,19 @@ void AMDGPUAsmPrinter::emitStartOfRuntim emitRuntimeMDIntValue(OutStreamer, RuntimeMD::KeyMDVersion, RuntimeMD::MDVersion << 8 | RuntimeMD::MDRevision, 2); if (auto MD = M.getNamedMetadata("opencl.ocl.version")) { - emitRuntimeMDIntValue(OutStreamer, RuntimeMD::KeyLanguage, - RuntimeMD::OpenCL_C, 1); - auto Node = MD->getOperand(0); - unsigned short Major = mdconst::extract<ConstantInt>(Node->getOperand(0)) - ->getZExtValue(); - unsigned short Minor = mdconst::extract<ConstantInt>(Node->getOperand(1)) - ->getZExtValue(); - emitRuntimeMDIntValue(OutStreamer, RuntimeMD::KeyLanguageVersion, - Major * 100 + Minor * 10, 2); + if (MD->getNumOperands()) { + auto Node = MD->getOperand(0); + if (Node->getNumOperands() > 1) { + emitRuntimeMDIntValue(OutStreamer, RuntimeMD::KeyLanguage, + RuntimeMD::OpenCL_C, 1); + uint16_t Major = mdconst::extract<ConstantInt>(Node->getOperand(0)) + ->getZExtValue(); + uint16_t Minor = mdconst::extract<ConstantInt>(Node->getOperand(1)) + ->getZExtValue(); + emitRuntimeMDIntValue(OutStreamer, RuntimeMD::KeyLanguageVersion, + Major * 100 + Minor * 10, 2); + } + } } } _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits