[llvm] r210000 - Instruction::isIdenticalToWhenDefined(): Check getNumOperands() in advance of std::equal(op) to appease MSVC Debug build.

NAKAMURA Takumi geek4civic at gmail.com
Sun Jun 1 18:35:34 PDT 2014


Author: chapuni
Date: Sun Jun  1 20:35:34 2014
New Revision: 210000

URL: http://llvm.org/viewvc/llvm-project?rev=210000&view=rev
Log:
Instruction::isIdenticalToWhenDefined(): Check getNumOperands() in advance of std::equal(op) to appease MSVC Debug build.

MSVC Debug build is confused with (possibly invalid) op_begin(), if op_begin() == op_end().

Modified:
    llvm/trunk/lib/IR/Instruction.cpp

Modified: llvm/trunk/lib/IR/Instruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instruction.cpp?rev=210000&r1=209999&r2=210000&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instruction.cpp (original)
+++ llvm/trunk/lib/IR/Instruction.cpp Sun Jun  1 20:35:34 2014
@@ -331,6 +331,10 @@ bool Instruction::isIdenticalToWhenDefin
       getType() != I->getType())
     return false;
 
+  // If both instructions have no operands, they are identical.
+  if (getNumOperands() == 0 && I->getNumOperands() == 0)
+    return haveSameSpecialState(this, I);
+
   // We have two instructions of identical opcode and #operands.  Check to see
   // if all operands are the same.
   if (!std::equal(op_begin(), op_end(), I->op_begin()))





More information about the llvm-commits mailing list