llvm.org GIT mirror llvm / 4444fc4
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 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_39@277079 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 4 years ago
4 changed file(s) with 39 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
782782 emitRuntimeMDIntValue(OutStreamer, RuntimeMD::KeyMDVersion,
783783 RuntimeMD::MDVersion << 8 | RuntimeMD::MDRevision, 2);
784784 if (auto MD = M.getNamedMetadata("opencl.ocl.version")) {
785 emitRuntimeMDIntValue(OutStreamer, RuntimeMD::KeyLanguage,
786 RuntimeMD::OpenCL_C, 1);
787 auto Node = MD->getOperand(0);
788 unsigned short Major = mdconst::extract(Node->getOperand(0))
789 ->getZExtValue();
790 unsigned short Minor = mdconst::extract(Node->getOperand(1))
791 ->getZExtValue();
792 emitRuntimeMDIntValue(OutStreamer, RuntimeMD::KeyLanguageVersion,
793 Major * 100 + Minor * 10, 2);
785 if (MD->getNumOperands()) {
786 auto Node = MD->getOperand(0);
787 if (Node->getNumOperands() > 1) {
788 emitRuntimeMDIntValue(OutStreamer, RuntimeMD::KeyLanguage,
789 RuntimeMD::OpenCL_C, 1);
790 uint16_t Major = mdconst::extract(Node->getOperand(0))
791 ->getZExtValue();
792 uint16_t Minor = mdconst::extract(Node->getOperand(1))
793 ->getZExtValue();
794 emitRuntimeMDIntValue(OutStreamer, RuntimeMD::KeyLanguageVersion,
795 Major * 100 + Minor * 10, 2);
796 }
797 }
794798 }
795799 }
796800
0 ; RUN: llc -mtriple=amdgcn--amdhsa < %s | FileCheck %s
1 ; check llc does not crash for invalid opencl version metadata
2
3 ; CHECK: .section .AMDGPU.runtime_metadata
4 ; CHECK-NEXT: .byte 1
5 ; CHECK-NEXT: .short 256
6
7 !opencl.ocl.version = !{}
0 ; RUN: llc -mtriple=amdgcn--amdhsa < %s | FileCheck %s
1 ; check llc does not crash for invalid opencl version metadata
2
3 ; CHECK: .section .AMDGPU.runtime_metadata
4 ; CHECK-NEXT: .byte 1
5 ; CHECK-NEXT: .short 256
6
7 !opencl.ocl.version = !{!0}
8 !0 = !{}
0 ; RUN: llc -mtriple=amdgcn--amdhsa < %s | FileCheck %s
1 ; check llc does not crash for invalid opencl version metadata
2
3 ; CHECK: .section .AMDGPU.runtime_metadata
4 ; CHECK-NEXT: .byte 1
5 ; CHECK-NEXT: .short 256
6
7 !opencl.ocl.version = !{!0}
8 !0 = !{i32 1}