[llvm] r239491 - Delete User::dropHungOffUses and move it in to ~User which is the only caller. NFC.
Pete Cooper
peter_cooper at apple.com
Wed Jun 10 15:38:38 PDT 2015
Author: pete
Date: Wed Jun 10 17:38:38 2015
New Revision: 239491
URL: http://llvm.org/viewvc/llvm-project?rev=239491&view=rev
Log:
Delete User::dropHungOffUses and move it in to ~User which is the only caller. NFC.
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.
Modified:
llvm/trunk/include/llvm/IR/Instructions.h
llvm/trunk/include/llvm/IR/User.h
llvm/trunk/lib/IR/Instructions.cpp
Modified: llvm/trunk/include/llvm/IR/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instructions.h?rev=239491&r1=239490&r2=239491&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Instructions.h (original)
+++ llvm/trunk/include/llvm/IR/Instructions.h Wed Jun 10 17:38:38 2015
@@ -2265,7 +2265,6 @@ public:
const Twine &NameStr, BasicBlock *InsertAtEnd) {
return new PHINode(Ty, NumReservedValues, NameStr, InsertAtEnd);
}
- ~PHINode() override;
/// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -2458,7 +2457,6 @@ public:
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);
@@ -2857,8 +2855,6 @@ public:
return new SwitchInst(Value, Default, NumCases, InsertAtEnd);
}
- ~SwitchInst() override;
-
/// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -3043,7 +3039,6 @@ public:
BasicBlock *InsertAtEnd) {
return new IndirectBrInst(Address, NumDests, InsertAtEnd);
}
- ~IndirectBrInst() override;
/// Provide fast operand accessors.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
Modified: llvm/trunk/include/llvm/IR/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/User.h?rev=239491&r1=239490&r2=239491&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/User.h (original)
+++ llvm/trunk/include/llvm/IR/User.h Wed Jun 10 17:38:38 2015
@@ -58,14 +58,16 @@ protected:
/// \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.
Modified: llvm/trunk/lib/IR/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instructions.cpp?rev=239491&r1=239490&r2=239491&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instructions.cpp (original)
+++ llvm/trunk/lib/IR/Instructions.cpp Wed Jun 10 17:38:38 2015
@@ -93,10 +93,6 @@ PHINode::PHINode(const PHINode &PN)
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) {
@@ -190,10 +186,6 @@ LandingPadInst::LandingPadInst(const Lan
setCleanup(LP.isCleanup());
}
-LandingPadInst::~LandingPadInst() {
- dropHungoffUses();
-}
-
LandingPadInst *LandingPadInst::Create(Type *RetTy, Value *PersonalityFn,
unsigned NumReservedClauses,
const Twine &NameStr,
@@ -3325,10 +3317,6 @@ SwitchInst::SwitchInst(const SwitchInst
SubclassOptionalData = SI.SubclassOptionalData;
}
-SwitchInst::~SwitchInst() {
- dropHungoffUses();
-}
-
/// addCase - Add an entry to the switch instruction...
///
@@ -3450,10 +3438,6 @@ IndirectBrInst::IndirectBrInst(const Ind
SubclassOptionalData = IBI.SubclassOptionalData;
}
-IndirectBrInst::~IndirectBrInst() {
- dropHungoffUses();
-}
-
/// addDestination - Add a destination.
///
void IndirectBrInst::addDestination(BasicBlock *DestBB) {
More information about the llvm-commits
mailing list