Commit 97864f4f authored by River Riddle's avatar River Riddle
Browse files

Fix some corner cases missed by D71955

* replaceAllUsesWith may be supplied with a null value.
* some compilers fail to implicitly convert single result operations to
OpaqueValue, so add an explicit OpOperand::set(Value) method.
parent bd402fc3
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public:
  /// the IR that uses 'this' to use the other value instead.  When this returns
  /// there are zero uses of 'this'.
  void replaceAllUsesWith(typename OperandType::ValueType newValue) {
    assert(this != OperandType::getUseList(newValue) &&
    assert(!newValue || this != OperandType::getUseList(newValue) &&
                            "cannot RAUW a value with itself");
    while (!use_empty())
      use_begin()->set(newValue);
@@ -126,7 +126,7 @@ public:
  void replaceAllUsesWith(ValueType oldValue, ValueType newValue) {
    assert(this == OperandType::getUseList(oldValue) &&
           "value not attached to this use list");
    assert(this != OperandType::getUseList(newValue) &&
    assert(!newValue || this != OperandType::getUseList(newValue) &&
                            "cannot RAUW a value with itself");
    for (OperandType &use : llvm::make_early_inc_range(getUses(oldValue)))
      use.set(newValue);
@@ -337,6 +337,9 @@ public:
  /// Return the current value being used by this operand.
  Value get() const;

  /// Set the operand to the given value.
  void set(Value value);

  /// Return which operand this is in the operand list of the User.
  unsigned getOperandNumber();
};
+5 −0
Original line number Diff line number Diff line
@@ -111,6 +111,11 @@ Value OpOperand::get() const {
  return IROperand<OpOperand, detail::OpaqueValue>::get();
}

/// Set the operand to the given value.
void OpOperand::set(Value value) {
  IROperand<OpOperand, detail::OpaqueValue>::set(value);
}

/// Return which operand this is in the operand list.
unsigned OpOperand::getOperandNumber() {
  return this - &getOwner()->getOpOperands()[0];