diff --git a/include/llvm/Analysis/DSNode.h b/include/llvm/Analysis/DSNode.h index 7726d72f378..64748d85b6f 100644 --- a/include/llvm/Analysis/DSNode.h +++ b/include/llvm/Analysis/DSNode.h @@ -271,4 +271,19 @@ inline void DSNodeHandle::mergeWith(const DSNodeHandle &Node) { *this = Node; } +inline void DSNodeHandle::swap(DSNodeHandle &NH) { + std::swap(Offset, NH.Offset); + if (N != NH.N) { + if (N) { + N->removeReferrer(this); + N->addReferrer(&NH); + } + if (NH.N) { + N->removeReferrer(&NH); + N->addReferrer(this); + } + std::swap(N, NH.N); + } +} + #endif diff --git a/include/llvm/Analysis/DataStructure/DSNode.h b/include/llvm/Analysis/DataStructure/DSNode.h index 7726d72f378..64748d85b6f 100644 --- a/include/llvm/Analysis/DataStructure/DSNode.h +++ b/include/llvm/Analysis/DataStructure/DSNode.h @@ -271,4 +271,19 @@ inline void DSNodeHandle::mergeWith(const DSNodeHandle &Node) { *this = Node; } +inline void DSNodeHandle::swap(DSNodeHandle &NH) { + std::swap(Offset, NH.Offset); + if (N != NH.N) { + if (N) { + N->removeReferrer(this); + N->addReferrer(&NH); + } + if (NH.N) { + N->removeReferrer(&NH); + N->addReferrer(this); + } + std::swap(N, NH.N); + } +} + #endif