Instruction::isIdenticalToWhenDefined(): Check getNumOperands() in advance of std...
authorNAKAMURA Takumi <geek4civic@gmail.com>
Mon, 2 Jun 2014 01:35:34 +0000 (01:35 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Mon, 2 Jun 2014 01:35:34 +0000 (01:35 +0000)
MSVC Debug build is confused with (possibly invalid) op_begin(), if op_begin() == op_end().

llvm-svn: 210000

llvm/lib/IR/Instruction.cpp

index 28cc4cb..6becc1e 100644 (file)
@@ -331,6 +331,10 @@ bool Instruction::isIdenticalToWhenDefined(const Instruction *I) const {
       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()))