summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit5ef7404dc732caba5b5376820f41943abb8f2fdf (patch)
treeade1653c2ba91ebd8f5eeb806b6470557c69a4b3 /llvm/lib/VMCore/Use.cpp
parent29fafcccd382b6a86c1e866bc6f1d4ed3c2bc9b7 (diff)
downloadbcm5719-llvm-5ef7404dc732caba5b5376820f41943abb8f2fdf.tar.gz
bcm5719-llvm-5ef7404dc732caba5b5376820f41943abb8f2fdf.zip
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. llvm-svn: 51078
Diffstat (limited to 'llvm/lib/VMCore/Use.cpp')
-rw-r--r--llvm/lib/VMCore/Use.cpp29
1 files changed, 29 insertions, 0 deletions
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