summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/BasicBlock.h19
-rw-r--r--include/llvm/Value.h2
-rw-r--r--include/llvm/ValueHolder.h12
-rw-r--r--include/llvm/iOther.h5
-rw-r--r--lib/VMCore/ValueHolderImpl.h24
5 files changed, 44 insertions, 18 deletions
diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h
index 6873ef2deb..5230e87d8d 100644
--- a/include/llvm/BasicBlock.h
+++ b/include/llvm/BasicBlock.h
@@ -148,7 +148,16 @@ public:
typedef bidirectional_iterator_tag iterator_category;
typedef _Ptr pointer;
- inline PredIterator(_Ptr BB) : ThisBB(BB), It(BB->use_begin()) {}
+ inline void advancePastConstPool() {
+ // Loop to ignore constant pool references
+ while (It != ThisBB->use_end() &&
+ ((*It)->getValueType() != Value::InstructionVal))
+ ++It;
+ }
+
+ inline PredIterator(_Ptr BB) : ThisBB(BB), It(BB->use_begin()) {
+ advancePastConstPool();
+ }
inline PredIterator(_Ptr BB, bool) : ThisBB(BB), It(BB->use_end()) {}
inline bool operator==(const _Self& x) const { return It == x.It; }
@@ -161,13 +170,7 @@ public:
inline pointer *operator->() const { return &(operator*()); }
inline _Self& operator++() { // Preincrement
- do { // Loop to ignore constant pool references
- ++It;
- } while (It != ThisBB->use_end() &&
- ((*It)->getValueType() != Value::ConstantVal));
-
- // DOES THIS WORK???
- //((*It)->getValueType() != Value::BasicBlockVal));
+ ++It; advancePastConstPool();
return *this;
}
diff --git a/include/llvm/Value.h b/include/llvm/Value.h
index d751eb1c6a..b10ea95b18 100644
--- a/include/llvm/Value.h
+++ b/include/llvm/Value.h
@@ -65,7 +65,7 @@ public:
typedef list<User*>::iterator use_iterator;
typedef list<User*>::const_iterator use_const_iterator;
- inline bool use_size() const { return Uses.size(); }
+ inline unsigned use_size() const { return Uses.size(); }
inline bool use_empty() const { return Uses.empty(); }
inline use_iterator use_begin() { return Uses.begin(); }
inline use_const_iterator use_begin() const { return Uses.begin(); }
diff --git a/include/llvm/ValueHolder.h b/include/llvm/ValueHolder.h
index 318419f139..8e18fc7ffd 100644
--- a/include/llvm/ValueHolder.h
+++ b/include/llvm/ValueHolder.h
@@ -65,10 +65,9 @@ public:
inline const_iterator end() const { return ValueList.end(); }
void delete_all() { // Delete all removes and deletes all elements
- // TODO: REMOVE FROM END OF VECTOR!!!
- while (begin() != end()) {
- iterator I = begin();
- delete remove(I); // Delete all instructions...
+ while (!empty()) {
+ iterator it = end();
+ delete remove(--it); // Delete all instructions...
}
}
@@ -76,8 +75,9 @@ public:
// specified by the iterator, and leaves the iterator pointing to the element
// that used to follow the element deleted.
//
- ValueSubclass *remove(iterator &DI); // Defined in ValueHolderImpl.h
- void remove(ValueSubclass *D); // Defined in ValueHolderImpl.h
+ ValueSubclass *remove(iterator &DI); // Defined in ValueHolderImpl.h
+ ValueSubclass *remove(const iterator &DI); // Defined in ValueHolderImpl.h
+ void remove(ValueSubclass *D); // Defined in ValueHolderImpl.h
inline void push_front(ValueSubclass *Inst); // Defined in ValueHolderImpl.h
inline void push_back(ValueSubclass *Inst); // Defined in ValueHolderImpl.h
diff --git a/include/llvm/iOther.h b/include/llvm/iOther.h
index 4c06b4fdd8..b66e4d4217 100644
--- a/include/llvm/iOther.h
+++ b/include/llvm/iOther.h
@@ -50,7 +50,12 @@ public:
virtual bool setOperand(unsigned i, Value *Val);
virtual string getOpcode() const { return "phi"; }
+ // addIncoming - Add an incoming value to the end of the PHI list
void addIncoming(Value *D);
+
+ // removeIncomingValue - Remove an incoming value. This is useful if a
+ // predecessor basic block is deleted. The value removed is returned.
+ Value *removeIncomingValue(unsigned idx);
};
diff --git a/lib/VMCore/ValueHolderImpl.h b/lib/VMCore/ValueHolderImpl.h
index ecafd470f1..9ca5d94926 100644
--- a/lib/VMCore/ValueHolderImpl.h
+++ b/lib/VMCore/ValueHolderImpl.h
@@ -38,9 +38,9 @@ void ValueHolder<ValueSubclass,ItemParentType>::remove(ValueSubclass *D) {
remove(I);
}
-// ValueHolder::remove(iterator &) this removes the element at the location specified
-// by the iterator, and leaves the iterator pointing to the element that used to follow
-// the element deleted.
+// ValueHolder::remove(iterator &) this removes the element at the location
+// specified by the iterator, and leaves the iterator pointing to the element
+// that used to follow the element deleted.
//
template<class ValueSubclass, class ItemParentType>
ValueSubclass *ValueHolder<ValueSubclass,ItemParentType>::remove(iterator &DI) {
@@ -60,6 +60,24 @@ ValueSubclass *ValueHolder<ValueSubclass,ItemParentType>::remove(iterator &DI) {
}
template<class ValueSubclass, class ItemParentType>
+ValueSubclass *ValueHolder<ValueSubclass,ItemParentType>
+::remove(const iterator &DI) {
+ assert(DI != ValueList.end() &&
+ "Trying to remove the end of the def list!!!");
+
+ ValueSubclass *i = *DI;
+ ValueList.erase(DI);
+
+ i->setParent(0); // I don't own you anymore... byebye...
+
+ // You don't get to be in the symbol table anymore... byebye
+ if (i->hasName() && Parent)
+ Parent->getSymbolTable()->remove(i);
+
+ return i;
+}
+
+template<class ValueSubclass, class ItemParentType>
void ValueHolder<ValueSubclass,ItemParentType>::push_front(ValueSubclass *Inst) {
assert(Inst->getParent() == 0 && "Value already has parent!");
Inst->setParent(ItemParent);