llvm.org GIT mirror llvm / 69bd957
TableGen: avoid dereferencing nullptr variable ARM64 ended up reaching odder parts of TableGen alias generation than current backends and caused a segfault. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205089 91177308-0d34-0410-b5e6-96231b3b80d8 Tim Northover 6 years ago
1 changed file(s) with 10 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
435435 ResultOperand &ResOp) {
436436 Init *Arg = Result->getArg(AliasOpNo);
437437 DefInit *ADI = dyn_cast(Arg);
438 Record *ResultRecord = ADI ? ADI->getDef() : 0;
438439
439440 if (ADI && ADI->getDef() == InstOpRec) {
440441 // If the operand is a record, it must have a name, and the record type
442443 if (Result->getArgName(AliasOpNo).empty())
443444 PrintFatalError(Loc, "result argument #" + utostr(AliasOpNo) +
444445 " must have a name!");
445 ResOp = ResultOperand(Result->getArgName(AliasOpNo), ADI->getDef());
446 ResOp = ResultOperand(Result->getArgName(AliasOpNo), ResultRecord);
446447 return true;
447448 }
448449
449450 // For register operands, the source register class can be a subclass
450451 // of the instruction register class, not just an exact match.
452 if (InstOpRec->isSubClassOf("RegisterOperand"))
453 InstOpRec = InstOpRec->getValueAsDef("RegClass");
454
455 if (ADI && ADI->getDef()->isSubClassOf("RegisterOperand"))
456 ADI = ADI->getDef()->getValueAsDef("RegClass")->getDefInit();
457
451458 if (ADI && ADI->getDef()->isSubClassOf("RegisterClass")) {
452459 if (!InstOpRec->isSubClassOf("RegisterClass"))
453460 return false;
454461 if (!T.getRegisterClass(InstOpRec)
455462 .hasSubClass(&T.getRegisterClass(ADI->getDef())))
456463 return false;
457 ResOp = ResultOperand(Result->getArgName(AliasOpNo), ADI->getDef());
464 ResOp = ResultOperand(Result->getArgName(AliasOpNo), ResultRecord);
458465 return true;
459466 }
460467
467474 InstOpRec = cast(DI->getArg(0))->getDef();
468475 }
469476
470 if (InstOpRec->isSubClassOf("RegisterOperand"))
471 InstOpRec = InstOpRec->getValueAsDef("RegClass");
472
473477 if (!InstOpRec->isSubClassOf("RegisterClass"))
474478 return false;
475479
483487 PrintFatalError(Loc, "result fixed register argument must "
484488 "not have a name!");
485489
486 ResOp = ResultOperand(ADI->getDef());
490 ResOp = ResultOperand(ResultRecord);
487491 return true;
488492 }
489493