Tentative fix for global-buffer-overflow caused by r188426. Found by AddressSanitizer

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188448 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alexey Samsonov 2013-08-15 07:11:34 +00:00
parent 07ad0c4c99
commit 84e51517e2

View File

@ -115,7 +115,10 @@ const TargetRegisterClass *AMDGPUDAGToDAGISel::getOperandRegClass(SDNode *N,
switch (N->getMachineOpcode()) {
default: {
const MCInstrDesc &Desc = TM.getInstrInfo()->get(N->getMachineOpcode());
int RegClass = Desc.OpInfo[Desc.getNumDefs() + OpNo].RegClass;
unsigned OpIdx = Desc.getNumDefs() + OpNo;
if (OpIdx >= Desc.getNumOperands())
return NULL;
int RegClass = Desc.OpInfo[OpIdx].RegClass;
if (RegClass == -1) {
return NULL;
}