Now that the subclasses which care about hung off uses let ~User clean it up,
there's no need for a separate method. Just inline it to ~User and delete it.
Reviewed by Duncan Exon Smith.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239491
91177308-0d34-0410-b5e6-
96231b3b80d8
const Twine &NameStr, BasicBlock *InsertAtEnd) {
return new PHINode(Ty, NumReservedValues, NameStr, InsertAtEnd);
}
- ~PHINode() override;
/// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
static LandingPadInst *Create(Type *RetTy, Value *PersonalityFn,
unsigned NumReservedClauses,
const Twine &NameStr, BasicBlock *InsertAtEnd);
- ~LandingPadInst() override;
/// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
return new SwitchInst(Value, Default, NumCases, InsertAtEnd);
}
- ~SwitchInst() override;
-
/// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
BasicBlock *InsertAtEnd) {
return new IndirectBrInst(Address, NumDests, InsertAtEnd);
}
- ~IndirectBrInst() override;
/// Provide fast operand accessors.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
/// \param IsPhi identifies callers which are phi nodes and which need
/// N BasicBlock* allocated along with N
Use *allocHungoffUses(unsigned N, bool IsPhi = false);
- void dropHungoffUses() {
- Use::zap(OperandList, OperandList + NumOperands, true);
- OperandList = nullptr;
- // Reset NumOperands so User::operator delete() does the right thing.
- NumOperands = 0;
- }
public:
- ~User() override { Use::zap(OperandList, OperandList + NumOperands); }
+ ~User() override {
+ // drop the hung off uses.
+ Use::zap(OperandList, OperandList + NumOperands, HasHungOffUses);
+ if (HasHungOffUses) {
+ OperandList = nullptr;
+ // Reset NumOperands so User::operator delete() does the right thing.
+ NumOperands = 0;
+ }
+ }
/// \brief Free memory allocated for User and Use objects.
void operator delete(void *Usr);
/// \brief Placement delete - required by std, but never called.
SubclassOptionalData = PN.SubclassOptionalData;
}
-PHINode::~PHINode() {
- dropHungoffUses();
-}
-
// removeIncomingValue - Remove an incoming value. This is useful if a
// predecessor basic block is deleted.
Value *PHINode::removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty) {
setCleanup(LP.isCleanup());
}
-LandingPadInst::~LandingPadInst() {
- dropHungoffUses();
-}
-
LandingPadInst *LandingPadInst::Create(Type *RetTy, Value *PersonalityFn,
unsigned NumReservedClauses,
const Twine &NameStr,
SubclassOptionalData = SI.SubclassOptionalData;
}
-SwitchInst::~SwitchInst() {
- dropHungoffUses();
-}
-
/// addCase - Add an entry to the switch instruction...
///
SubclassOptionalData = IBI.SubclassOptionalData;
}
-IndirectBrInst::~IndirectBrInst() {
- dropHungoffUses();
-}
-
/// addDestination - Add a destination.
///
void IndirectBrInst::addDestination(BasicBlock *DestBB) {