[llvm] r205089 - TableGen: avoid dereferencing nullptr variable
Tim Northover
tnorthover at apple.com
Sat Mar 29 02:03:22 PDT 2014
Author: tnorthover
Date: Sat Mar 29 04:03:22 2014
New Revision: 205089
URL: http://llvm.org/viewvc/llvm-project?rev=205089&view=rev
Log:
TableGen: avoid dereferencing nullptr variable
ARM64 ended up reaching odder parts of TableGen alias generation than
current backends and caused a segfault.
Modified:
llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.cpp?rev=205089&r1=205088&r2=205089&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenInstruction.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenInstruction.cpp Sat Mar 29 04:03:22 2014
@@ -436,6 +436,7 @@ bool CodeGenInstAlias::tryAliasOpMatch(D
ResultOperand &ResOp) {
Init *Arg = Result->getArg(AliasOpNo);
DefInit *ADI = dyn_cast<DefInit>(Arg);
+ Record *ResultRecord = ADI ? ADI->getDef() : 0;
if (ADI && ADI->getDef() == InstOpRec) {
// If the operand is a record, it must have a name, and the record type
@@ -443,19 +444,25 @@ bool CodeGenInstAlias::tryAliasOpMatch(D
if (Result->getArgName(AliasOpNo).empty())
PrintFatalError(Loc, "result argument #" + utostr(AliasOpNo) +
" must have a name!");
- ResOp = ResultOperand(Result->getArgName(AliasOpNo), ADI->getDef());
+ ResOp = ResultOperand(Result->getArgName(AliasOpNo), ResultRecord);
return true;
}
// For register operands, the source register class can be a subclass
// of the instruction register class, not just an exact match.
+ if (InstOpRec->isSubClassOf("RegisterOperand"))
+ InstOpRec = InstOpRec->getValueAsDef("RegClass");
+
+ if (ADI && ADI->getDef()->isSubClassOf("RegisterOperand"))
+ ADI = ADI->getDef()->getValueAsDef("RegClass")->getDefInit();
+
if (ADI && ADI->getDef()->isSubClassOf("RegisterClass")) {
if (!InstOpRec->isSubClassOf("RegisterClass"))
return false;
if (!T.getRegisterClass(InstOpRec)
.hasSubClass(&T.getRegisterClass(ADI->getDef())))
return false;
- ResOp = ResultOperand(Result->getArgName(AliasOpNo), ADI->getDef());
+ ResOp = ResultOperand(Result->getArgName(AliasOpNo), ResultRecord);
return true;
}
@@ -468,9 +475,6 @@ bool CodeGenInstAlias::tryAliasOpMatch(D
InstOpRec = cast<DefInit>(DI->getArg(0))->getDef();
}
- if (InstOpRec->isSubClassOf("RegisterOperand"))
- InstOpRec = InstOpRec->getValueAsDef("RegClass");
-
if (!InstOpRec->isSubClassOf("RegisterClass"))
return false;
@@ -484,7 +488,7 @@ bool CodeGenInstAlias::tryAliasOpMatch(D
PrintFatalError(Loc, "result fixed register argument must "
"not have a name!");
- ResOp = ResultOperand(ADI->getDef());
+ ResOp = ResultOperand(ResultRecord);
return true;
}
More information about the llvm-commits
mailing list