summaryrefslogtreecommitdiff
path: root/lib/VMCore/Use.cpp
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2008-05-13 22:51:52 +0000
committerGabor Greif <ggreif@gmail.com>2008-05-13 22:51:52 +0000
commit94fb68ba217975d2d99ae86d15993402158ac655 (patch)
tree552de423a4b79ff2cf57b7c68f5e2db81fb562d2 /lib/VMCore/Use.cpp
parente3fc3858a2e9d6483a68a6696d07f29ccc799cce (diff)
downloadllvm-94fb68ba217975d2d99ae86d15993402158ac655.tar.gz
llvm-94fb68ba217975d2d99ae86d15993402158ac655.tar.bz2
llvm-94fb68ba217975d2d99ae86d15993402158ac655.tar.xz
Merge of r51073-51074 from use-diet branch.
Do not rely on std::swap<Use>, provide a (faster) member function instead. This change is primarily necessitated by MSVC++'s incompatibility with declaring std::swap<Use> to be a friend of Use. Also contains some minor tweaks to Use inline functions, to undo pointless changes that sneaked in with the last merge. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51078 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Use.cpp')
-rw-r--r--lib/VMCore/Use.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/VMCore/Use.cpp b/lib/VMCore/Use.cpp
index a510d1a41c..0672209bff 100644
--- a/lib/VMCore/Use.cpp
+++ b/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
//===----------------------------------------------------------------------===//