forked from OSchip/llvm-project
[TargetInstrInfo] Fix the implementation of commuteInstruction to match the
comment of the API. Relaxes the behavior of TargetInstrInfo::commuteInstruction when TargetInstrInfo::findCommutedOpIndices returns false. Previously TargetInstrInfo triggered a fatal error in such situation whereas based on the comment in the API it should just return nullptr. Indeed the only precondition that should be ensured is that the instruction must be commutable. llvm-svn: 208371
This commit is contained in:
parent
54a824b758
commit
2eb151e29f
|
@ -127,10 +127,8 @@ MachineInstr *TargetInstrInfo::commuteInstruction(MachineInstr *MI,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
unsigned Idx1, Idx2;
|
unsigned Idx1, Idx2;
|
||||||
if (!findCommutedOpIndices(MI, Idx1, Idx2)) {
|
if (!findCommutedOpIndices(MI, Idx1, Idx2)) {
|
||||||
std::string msg;
|
assert(MI->isCommutable() && "Precondition violation: MI must be commutable.");
|
||||||
raw_string_ostream Msg(msg);
|
return nullptr;
|
||||||
Msg << "Don't know how to commute: " << *MI;
|
|
||||||
report_fatal_error(Msg.str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(MI->getOperand(Idx1).isReg() && MI->getOperand(Idx2).isReg() &&
|
assert(MI->getOperand(Idx1).isReg() && MI->getOperand(Idx2).isReg() &&
|
||||||
|
|
Loading…
Reference in New Issue