diff options
author | Gabor Greif <ggreif@gmail.com> | 2008-05-13 22:51:52 +0000 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2008-05-13 22:51:52 +0000 |
commit | 94fb68ba217975d2d99ae86d15993402158ac655 (patch) | |
tree | 552de423a4b79ff2cf57b7c68f5e2db81fb562d2 /lib | |
parent | e3fc3858a2e9d6483a68a6696d07f29ccc799cce (diff) | |
download | external_llvm-94fb68ba217975d2d99ae86d15993402158ac655.zip external_llvm-94fb68ba217975d2d99ae86d15993402158ac655.tar.gz external_llvm-94fb68ba217975d2d99ae86d15993402158ac655.tar.bz2 |
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')
-rw-r--r-- | lib/VMCore/Instructions.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/Use.cpp | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index cea496d..ff56560 100644 --- a/lib/VMCore/Instructions.cpp +++ b/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/lib/VMCore/Use.cpp b/lib/VMCore/Use.cpp index a510d1a..0672209 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 //===----------------------------------------------------------------------===// |