summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Instructions.cpp2
-rw-r--r--llvm/lib/VMCore/Use.cpp29
2 files changed, 30 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index cea496d1ca7..ff565606138 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -1563,7 +1563,7 @@ const Value *BinaryOperator::getNotArgument(const Value *BinOp) {
bool BinaryOperator::swapOperands() {
if (!isCommutative())
return true; // Can't commute operands
- std::swap(Op<0>(), Op<1>());
+ Op<0>().swap(Op<1>());
return false;
}
diff --git a/llvm/lib/VMCore/Use.cpp b/llvm/lib/VMCore/Use.cpp
index a510d1a41ce..0672209bffa 100644
--- a/llvm/lib/VMCore/Use.cpp
+++ b/llvm/lib/VMCore/Use.cpp
@@ -16,6 +16,35 @@
namespace llvm {
//===----------------------------------------------------------------------===//
+// Use swap Implementation
+//===----------------------------------------------------------------------===//
+
+void Use::swap(Use &RHS) {
+ Value *V1(Val);
+ Value *V2(RHS.Val);
+ if (V1 != V2) {
+ if (V1) {
+ removeFromList();
+ }
+
+ if (V2) {
+ RHS.removeFromList();
+ Val = V2;
+ V2->addUse(*this);
+ } else {
+ Val = 0;
+ }
+
+ if (V1) {
+ RHS.Val = V1;
+ V1->addUse(RHS);
+ } else {
+ RHS.Val = 0;
+ }
+ }
+}
+
+//===----------------------------------------------------------------------===//
// Use getImpliedUser Implementation
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud