diff --git a/utils/TableGen/CodeGenInstruction.cpp b/utils/TableGen/CodeGenInstruction.cpp index 99d2f173a87..fd38672bfcf 100644 --- a/utils/TableGen/CodeGenInstruction.cpp +++ b/utils/TableGen/CodeGenInstruction.cpp @@ -233,11 +233,12 @@ static void ParseConstraint(const std::string &CStr, CGIOperandList &Ops) { if (wpos == std::string::npos) throw "Illegal format for tied-to constraint: '" + CStr + "'"; - std::pair SrcOp = - Ops.ParseOperandName(Name.substr(wpos), false); - if (SrcOp > DestOp) - throw "Illegal tied-to operand constraint '" + CStr + "'"; - + std::string SrcOpName = Name.substr(wpos); + std::pair SrcOp = Ops.ParseOperandName(SrcOpName, false); + if (SrcOp > DestOp) { + std::swap(SrcOp, DestOp); + std::swap(SrcOpName, DestOpName); + } unsigned FlatOpNo = Ops.getFlattenedOperandNumber(SrcOp);