[llvm] r276119 - AMDGPU: Fix bug causing crash due to invalid opencl version metadata.
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 28 08:57:47 PDT 2016
Yes, go ahead.
Cheers,
Hans
On Thu, Jul 28, 2016 at 7:52 AM, Tom Stellard <tom at stellard.net> wrote:
> On Wed, Jul 20, 2016 at 02:38:07PM -0000, Yaxun Liu via llvm-commits wrote:
>> Author: yaxunl
>> Date: Wed Jul 20 09:38:06 2016
>> New Revision: 276119
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=276119&view=rev
>> Log:
>> AMDGPU: Fix bug causing crash due to invalid opencl version metadata.
>>
>> Differential Revision: https://reviews.llvm.org/D22526
>>
>> Added:
>> llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata1.ll
>> llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata2.ll
>> llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata3.ll
>> Modified:
>> llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
>>
>
> Hi Hans,
>
> Is this OK to merge to the 3.9 branch? I am the code owner, and I approve.
>
> -Tom
>
>> Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp?rev=276119&r1=276118&r2=276119&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp (original)
>> +++ llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp Wed Jul 20 09:38:06 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);
>> + }
>> + }
>> }
>> }
>>
>>
>> Added: llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata1.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata1.ll?rev=276119&view=auto
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata1.ll (added)
>> +++ llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata1.ll Wed Jul 20 09:38:06 2016
>> @@ -0,0 +1,8 @@
>> +; RUN: llc -mtriple=amdgcn--amdhsa < %s | FileCheck %s
>> +; check llc does not crash for invalid opencl version metadata
>> +
>> +; CHECK: .section .AMDGPU.runtime_metadata
>> +; CHECK-NEXT: .byte 1
>> +; CHECK-NEXT: .short 256
>> +
>> +!opencl.ocl.version = !{}
>>
>> Added: llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata2.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata2.ll?rev=276119&view=auto
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata2.ll (added)
>> +++ llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata2.ll Wed Jul 20 09:38:06 2016
>> @@ -0,0 +1,9 @@
>> +; RUN: llc -mtriple=amdgcn--amdhsa < %s | FileCheck %s
>> +; check llc does not crash for invalid opencl version metadata
>> +
>> +; CHECK: .section .AMDGPU.runtime_metadata
>> +; CHECK-NEXT: .byte 1
>> +; CHECK-NEXT: .short 256
>> +
>> +!opencl.ocl.version = !{!0}
>> +!0 = !{}
>>
>> Added: llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata3.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata3.ll?rev=276119&view=auto
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata3.ll (added)
>> +++ llvm/trunk/test/CodeGen/AMDGPU/invalid-opencl-version-metadata3.ll Wed Jul 20 09:38:06 2016
>> @@ -0,0 +1,9 @@
>> +; RUN: llc -mtriple=amdgcn--amdhsa < %s | FileCheck %s
>> +; check llc does not crash for invalid opencl version metadata
>> +
>> +; CHECK: .section .AMDGPU.runtime_metadata
>> +; CHECK-NEXT: .byte 1
>> +; CHECK-NEXT: .short 256
>> +
>> +!opencl.ocl.version = !{!0}
>> +!0 = !{i32 1}
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list