diff options
| author | Pete Cooper <peter_cooper@apple.com> | 2015-06-10 22:38:34 +0000 |
|---|---|---|
| committer | Pete Cooper <peter_cooper@apple.com> | 2015-06-10 22:38:34 +0000 |
| commit | c6c0439d2aa914672712435fef12b5055ebb5caf (patch) | |
| tree | 8338132e989f5deb3cda39735171af46eebf5102 /llvm/lib/IR | |
| parent | 87b925b0645e33fc353d8c54ab21b26792262dc8 (diff) | |
| download | bcm5719-llvm-c6c0439d2aa914672712435fef12b5055ebb5caf.tar.gz bcm5719-llvm-c6c0439d2aa914672712435fef12b5055ebb5caf.zip | |
Make User track whether a class has 'hung off uses' and delete them in its destructor.
Currently all of the logic for deleting hung off uses, which PHI/switch/etc use,
is in their classes.
This adds a bit to Value which tracks whether that user had hung off uses,
then User can be responsible for clearing them instead of the sub classes.
Note, the bit used here was taken from NumOperands which was 30-bits.
Given the reduction to 29 bits, and the average User being just over 100 bytes,
a single User with 29-bits of num operands would need 50GB of RAM for itself
so its reasonable to assume that 29-bits is enough for now.
This is a step towards hiding all the hung off uses logic in the User.
Reviewed by Duncan Exon Smith.
llvm-svn: 239490
Diffstat (limited to 'llvm/lib/IR')
| -rw-r--r-- | llvm/lib/IR/User.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/IR/User.cpp b/llvm/lib/IR/User.cpp index 4dae071185f..e5450946006 100644 --- a/llvm/lib/IR/User.cpp +++ b/llvm/lib/IR/User.cpp @@ -40,7 +40,7 @@ void User::replaceUsesOfWith(Value *From, Value *To) { // User allocHungoffUses Implementation //===----------------------------------------------------------------------===// -Use *User::allocHungoffUses(unsigned N, bool IsPhi) const { +Use *User::allocHungoffUses(unsigned N, bool IsPhi) { // Allocate the array of Uses, followed by a pointer (with bottom bit set) to // the User. size_t size = N * sizeof(Use) + sizeof(Use::UserRef); @@ -49,7 +49,11 @@ Use *User::allocHungoffUses(unsigned N, bool IsPhi) const { Use *Begin = static_cast<Use*>(::operator new(size)); Use *End = Begin + N; (void) new(End) Use::UserRef(const_cast<User*>(this), 1); - return Use::initTags(Begin, End); + Use *Uses = Use::initTags(Begin, End); + OperandList = Uses; + // Tag this operand list as being a hung off. + HasHungOffUses = true; + return Uses; } //===----------------------------------------------------------------------===// @@ -62,6 +66,7 @@ void *User::operator new(size_t s, unsigned Us) { Use *End = Start + Us; User *Obj = reinterpret_cast<User*>(End); Obj->OperandList = Start; + Obj->HasHungOffUses = false; Obj->NumOperands = Us; Use::initTags(Start, End); return Obj; |

