aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJay Foad <jay.foad@gmail.com>2011-01-16 15:30:52 +0000
committerJay Foad <jay.foad@gmail.com>2011-01-16 15:30:52 +0000
commit1ed26acc58a13f125bc9e1d5e5aa22fd479654ff (patch)
tree0f1bc09ea94435780419763db1c49d5dd21a5f29 /lib
parent29c8419f91ff87ebaee7d275aa709a3bbfc13614 (diff)
downloadexternal_llvm-1ed26acc58a13f125bc9e1d5e5aa22fd479654ff.zip
external_llvm-1ed26acc58a13f125bc9e1d5e5aa22fd479654ff.tar.gz
external_llvm-1ed26acc58a13f125bc9e1d5e5aa22fd479654ff.tar.bz2
Simplify the construction and destruction of Uses. Simplify
User::dropHungOffUses(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123580 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/Instructions.cpp15
-rw-r--r--lib/VMCore/Use.cpp24
2 files changed, 15 insertions, 24 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index 909dab9..db38a15 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -96,8 +96,7 @@ PHINode::PHINode(const PHINode &PN)
}
PHINode::~PHINode() {
- if (OperandList)
- dropHungoffUses(OperandList);
+ dropHungoffUses();
}
// removeIncomingValue - Remove an incoming value. This is useful if a
@@ -158,7 +157,7 @@ void PHINode::resizeOperands(unsigned NumOps) {
Use *NewOps = allocHungoffUses(NumOps);
std::copy(OldOps, OldOps + e, NewOps);
OperandList = NewOps;
- if (OldOps) Use::zap(OldOps, OldOps + e, true);
+ Use::zap(OldOps, OldOps + e, true);
}
/// hasConstantValue - If the specified PHI node always merges together the same
@@ -2982,7 +2981,7 @@ SwitchInst::SwitchInst(const SwitchInst &SI)
}
SwitchInst::~SwitchInst() {
- dropHungoffUses(OperandList);
+ dropHungoffUses();
}
@@ -3053,7 +3052,7 @@ void SwitchInst::resizeOperands(unsigned NumOps) {
NewOps[i] = OldOps[i];
}
OperandList = NewOps;
- if (OldOps) Use::zap(OldOps, OldOps + e, true);
+ Use::zap(OldOps, OldOps + e, true);
}
@@ -3068,7 +3067,7 @@ void SwitchInst::setSuccessorV(unsigned idx, BasicBlock *B) {
}
//===----------------------------------------------------------------------===//
-// SwitchInst Implementation
+// IndirectBrInst Implementation
//===----------------------------------------------------------------------===//
void IndirectBrInst::init(Value *Address, unsigned NumDests) {
@@ -3108,7 +3107,7 @@ void IndirectBrInst::resizeOperands(unsigned NumOps) {
for (unsigned i = 0; i != e; ++i)
NewOps[i] = OldOps[i];
OperandList = NewOps;
- if (OldOps) Use::zap(OldOps, OldOps + e, true);
+ Use::zap(OldOps, OldOps + e, true);
}
IndirectBrInst::IndirectBrInst(Value *Address, unsigned NumCases,
@@ -3136,7 +3135,7 @@ IndirectBrInst::IndirectBrInst(const IndirectBrInst &IBI)
}
IndirectBrInst::~IndirectBrInst() {
- dropHungoffUses(OperandList);
+ dropHungoffUses();
}
/// addDestination - Add a destination.
diff --git a/lib/VMCore/Use.cpp b/lib/VMCore/Use.cpp
index 32cf954..4e959a5 100644
--- a/lib/VMCore/Use.cpp
+++ b/lib/VMCore/Use.cpp
@@ -85,7 +85,8 @@ const Use *Use::getImpliedUser() const {
// Use initTags Implementation
//===----------------------------------------------------------------------===//
-Use *Use::initTags(Use * const Start, Use *Stop, ptrdiff_t Done) {
+Use *Use::initTags(Use * const Start, Use *Stop) {
+ ptrdiff_t Done = 0;
while (Done < 20) {
if (Start == Stop--)
return Start;
@@ -97,20 +98,18 @@ Use *Use::initTags(Use * const Start, Use *Stop, ptrdiff_t Done) {
oneDigitTag, oneDigitTag, oneDigitTag,
oneDigitTag, stopTag
};
- Stop->Prev.setFromOpaqueValue(reinterpret_cast<Use**>(tags[Done++]));
- Stop->Val = 0;
+ new(Stop) Use(tags[Done++]);
}
ptrdiff_t Count = Done;
while (Start != Stop) {
--Stop;
- Stop->Val = 0;
if (!Count) {
- Stop->Prev.setFromOpaqueValue(reinterpret_cast<Use**>(stopTag));
+ new(Stop) Use(stopTag);
++Done;
Count = Done;
} else {
- Stop->Prev.setFromOpaqueValue(reinterpret_cast<Use**>(Count & 1));
+ new(Stop) Use(PrevPtrTag(Count & 1));
Count >>= 1;
++Done;
}
@@ -124,17 +123,10 @@ Use *Use::initTags(Use * const Start, Use *Stop, ptrdiff_t Done) {
//===----------------------------------------------------------------------===//
void Use::zap(Use *Start, const Use *Stop, bool del) {
- if (del) {
- while (Start != Stop) {
- (--Stop)->~Use();
- }
+ while (Start != Stop)
+ (--Stop)->~Use();
+ if (del)
::operator delete(Start);
- return;
- }
-
- while (Start != Stop) {
- (Start++)->set(0);
- }
}
//===----------------------------------------------------------------------===//