diff --git a/include/llvm/ValueHolder.h b/include/llvm/ValueHolder.h index 26ecd267f2c..18f6e3f40b9 100644 --- a/include/llvm/ValueHolder.h +++ b/include/llvm/ValueHolder.h @@ -85,6 +85,7 @@ public: 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 + ValueSubclass *pop_back(); // Defined in ValueHolderImpl.h void push_front(ValueSubclass *Inst); // Defined in ValueHolderImpl.h void push_back(ValueSubclass *Inst); // Defined in ValueHolderImpl.h diff --git a/lib/VMCore/ValueHolderImpl.h b/lib/VMCore/ValueHolderImpl.h index 9d0e87413fa..f19d71f5026 100644 --- a/lib/VMCore/ValueHolderImpl.h +++ b/lib/VMCore/ValueHolderImpl.h @@ -59,6 +59,21 @@ ValueSubclass *ValueHolder::remove(iterator &DI) { return i; } +template +ValueSubclass *ValueHolder::pop_back() { + assert(!ValueList.empty() && "Can't pop_back an empty valuelist!"); + ValueSubclass *i = ValueList.back(); + ValueList.pop_back(); + 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 ValueSubclass *ValueHolder ::remove(const iterator &DI) {