mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Add User::growHungoffUses and use it to grow the hung off uses. NFC.
PhiNode, SwitchInst, LandingPad and IndirectBr all had virtually identical logic for growing the hung off uses. Move it to User so that they can all call a single shared implementation. Their destructors were all empty after this change and were deleted. They all have virtual clone_impl methods which can be used as vtable anchors. Reviewed by Duncan Exon Smith. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239492 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -128,16 +128,8 @@ void PHINode::growOperands() {
|
||||
unsigned NumOps = e + e / 2;
|
||||
if (NumOps < 2) NumOps = 2; // 2 op PHI nodes are VERY common.
|
||||
|
||||
Use *OldOps = op_begin();
|
||||
BasicBlock **OldBlocks = block_begin();
|
||||
|
||||
ReservedSpace = NumOps;
|
||||
OperandList = allocHungoffUses(ReservedSpace);
|
||||
|
||||
std::copy(OldOps, OldOps + e, op_begin());
|
||||
std::copy(OldBlocks, OldBlocks + e, block_begin());
|
||||
|
||||
Use::zap(OldOps, OldOps + e, true);
|
||||
growHungoffUses(ReservedSpace, /* IsPhi */ true);
|
||||
}
|
||||
|
||||
/// hasConstantValue - If the specified PHI node always merges together the same
|
||||
@@ -218,14 +210,7 @@ void LandingPadInst::growOperands(unsigned Size) {
|
||||
unsigned e = getNumOperands();
|
||||
if (ReservedSpace >= e + Size) return;
|
||||
ReservedSpace = (e + Size / 2) * 2;
|
||||
|
||||
Use *NewOps = allocHungoffUses(ReservedSpace);
|
||||
Use *OldOps = OperandList;
|
||||
for (unsigned i = 0; i != e; ++i)
|
||||
NewOps[i] = OldOps[i];
|
||||
|
||||
OperandList = NewOps;
|
||||
Use::zap(OldOps, OldOps + e, true);
|
||||
growHungoffUses(ReservedSpace);
|
||||
}
|
||||
|
||||
void LandingPadInst::addClause(Constant *Val) {
|
||||
@@ -3363,13 +3348,7 @@ void SwitchInst::growOperands() {
|
||||
unsigned NumOps = e*3;
|
||||
|
||||
ReservedSpace = NumOps;
|
||||
Use *NewOps = allocHungoffUses(NumOps);
|
||||
Use *OldOps = OperandList;
|
||||
for (unsigned i = 0; i != e; ++i) {
|
||||
NewOps[i] = OldOps[i];
|
||||
}
|
||||
OperandList = NewOps;
|
||||
Use::zap(OldOps, OldOps + e, true);
|
||||
growHungoffUses(ReservedSpace);
|
||||
}
|
||||
|
||||
|
||||
@@ -3406,12 +3385,7 @@ void IndirectBrInst::growOperands() {
|
||||
unsigned NumOps = e*2;
|
||||
|
||||
ReservedSpace = NumOps;
|
||||
Use *NewOps = allocHungoffUses(NumOps);
|
||||
Use *OldOps = OperandList;
|
||||
for (unsigned i = 0; i != e; ++i)
|
||||
NewOps[i] = OldOps[i];
|
||||
OperandList = NewOps;
|
||||
Use::zap(OldOps, OldOps + e, true);
|
||||
growHungoffUses(ReservedSpace);
|
||||
}
|
||||
|
||||
IndirectBrInst::IndirectBrInst(Value *Address, unsigned NumCases,
|
||||
|
Reference in New Issue
Block a user