mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +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:
@@ -56,6 +56,33 @@ Use *User::allocHungoffUses(unsigned N, bool IsPhi) {
|
||||
return Uses;
|
||||
}
|
||||
|
||||
void User::growHungoffUses(unsigned NewNumUses, bool IsPhi) {
|
||||
assert(HasHungOffUses && "realloc must have hung off uses");
|
||||
|
||||
unsigned OldNumUses = getNumOperands();
|
||||
|
||||
// We don't support shrinking the number of uses. We wouldn't have enough
|
||||
// space to copy the old uses in to the new space.
|
||||
assert(NewNumUses > OldNumUses && "realloc must grow num uses");
|
||||
|
||||
Use *OldOps = OperandList;
|
||||
allocHungoffUses(NewNumUses, IsPhi);
|
||||
Use *NewOps = OperandList;
|
||||
|
||||
// Now copy from the old operands list to the new one.
|
||||
std::copy(OldOps, OldOps + OldNumUses, NewOps);
|
||||
|
||||
// If this is a Phi, then we need to copy the BB pointers too.
|
||||
if (IsPhi) {
|
||||
auto *OldPtr =
|
||||
reinterpret_cast<char *>(OldOps + OldNumUses) + sizeof(Use::UserRef);
|
||||
auto *NewPtr =
|
||||
reinterpret_cast<char *>(NewOps + NewNumUses) + sizeof(Use::UserRef);
|
||||
std::copy(OldPtr, OldPtr + (OldNumUses * sizeof(BasicBlock *)), NewPtr);
|
||||
}
|
||||
Use::zap(OldOps, OldOps + OldNumUses, true);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// User operator new Implementations
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Reference in New Issue
Block a user