aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Use.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/Use.cpp')
-rw-r--r--llvm/lib/IR/Use.cpp29
1 files changed, 11 insertions, 18 deletions
diff --git a/llvm/lib/IR/Use.cpp b/llvm/lib/IR/Use.cpp
index dc0716b85372..99049c0232aa 100644
--- a/llvm/lib/IR/Use.cpp
+++ b/llvm/lib/IR/Use.cpp
@@ -17,24 +17,17 @@ void Use::swap(Use &RHS) {
if (Val == RHS.Val)
return;
- if (Val)
- removeFromList();
-
- Value *OldVal = Val;
- if (RHS.Val) {
- RHS.removeFromList();
- Val = RHS.Val;
- Val->addUse(*this);
- } else {
- Val = nullptr;
- }
-
- if (OldVal) {
- RHS.Val = OldVal;
- RHS.Val->addUse(RHS);
- } else {
- RHS.Val = nullptr;
- }
+ std::swap(Val, RHS.Val);
+ std::swap(Next, RHS.Next);
+ std::swap(Prev, RHS.Prev);
+
+ *Prev = this;
+ if (Next)
+ Next->Prev = &Next;
+
+ *RHS.Prev = &RHS;
+ if (RHS.Next)
+ RHS.Next->Prev = &RHS.Next;
}
unsigned Use::getOperandNo() const {