summaryrefslogtreecommitdiff
path: root/lib/CodeGen/TargetInstrInfo.cpp
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2014-05-08 23:12:27 +0000
committerQuentin Colombet <qcolombet@apple.com>2014-05-08 23:12:27 +0000
commit8d53407abba2fb328edea4aa3079827f348ec41f (patch)
treee8d6329f564396c950f34494d0861c32f22d058c /lib/CodeGen/TargetInstrInfo.cpp
parent8ec421c2557f437e14cb0246fefee9cda16a06ef (diff)
downloadllvm-8d53407abba2fb328edea4aa3079827f348ec41f.tar.gz
llvm-8d53407abba2fb328edea4aa3079827f348ec41f.tar.bz2
llvm-8d53407abba2fb328edea4aa3079827f348ec41f.tar.xz
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208371 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TargetInstrInfo.cpp')
-rw-r--r--lib/CodeGen/TargetInstrInfo.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/CodeGen/TargetInstrInfo.cpp b/lib/CodeGen/TargetInstrInfo.cpp
index c4c9c83120..c3f84c64d7 100644
--- a/lib/CodeGen/TargetInstrInfo.cpp
+++ b/lib/CodeGen/TargetInstrInfo.cpp
@@ -127,10 +127,8 @@ MachineInstr *TargetInstrInfo::commuteInstruction(MachineInstr *MI,
return nullptr;
unsigned Idx1, Idx2;
if (!findCommutedOpIndices(MI, Idx1, Idx2)) {
- std::string msg;
- raw_string_ostream Msg(msg);
- Msg << "Don't know how to commute: " << *MI;
- report_fatal_error(Msg.str());
+ assert(MI->isCommutable() && "Precondition violation: MI must be commutable.");
+ return nullptr;
}
assert(MI->getOperand(Idx1).isReg() && MI->getOperand(Idx2).isReg() &&