[llvm] r208371 - [TargetInstrInfo] Fix the implementation of commuteInstruction to match the

Quentin Colombet qcolombet at apple.com
Thu May 8 16:12:27 PDT 2014

Author: qcolombet
Date: Thu May  8 18:12:27 2014
New Revision: 208371

URL: http://llvm.org/viewvc/llvm-project?rev=208371&view=rev
[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.


Modified: llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp?rev=208371&r1=208370&r2=208371&view=diff
--- llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp Thu May  8 18:12:27 2014
@@ -127,10 +127,8 @@ MachineInstr *TargetInstrInfo::commuteIn
     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() &&

More information about the llvm-commits mailing list