diff options
author | Nikita Popov <npopov@redhat.com> | 2025-05-02 13:03:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-02 13:03:43 +0200 |
commit | 7f5c34bc5e54e0fb149275d9ee6805e9e6a7a3ea (patch) | |
tree | 9d55b8f6526a354259e2ed4bb3bdfd7a08a7a2f9 /llvm/lib/IR/Constants.cpp | |
parent | cf2f13a867fb86b5c7ce33df8a569477dce71f4f (diff) | |
download | llvm-7f5c34bc5e54e0fb149275d9ee6805e9e6a7a3ea.zip llvm-7f5c34bc5e54e0fb149275d9ee6805e9e6a7a3ea.tar.gz llvm-7f5c34bc5e54e0fb149275d9ee6805e9e6a7a3ea.tar.bz2 |
[IR] Replace blockaddress refcount with single flag (#138239)
BasicBlock currently has a blockaddress refcount. However,
blockaddresses are uniqued, which means that there can only be a single
blockaddress for a given BasicBlock. Prior to #137958 there were some
edge case exceptions to this, but now it always holds. As such, replace
the refcount with a single flag.
As we're now just tracking two bits, I've dropped the BasicBlockBits
structure, as I found it more annoying than useful (esp with the weird
AIX workarounds). Instead handle the subclass data the same way we do in
Operators.
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 49107a4..d7c847e 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -1911,7 +1911,7 @@ BlockAddress *BlockAddress::get(Function *F, BasicBlock *BB) { BlockAddress::BlockAddress(Type *Ty, BasicBlock *BB) : Constant(Ty, Value::BlockAddressVal, AllocMarker) { setOperand(0, BB); - BB->AdjustBlockAddressRefCount(1); + BB->setHasAddressTaken(true); } BlockAddress *BlockAddress::lookup(const BasicBlock *BB) { @@ -1926,7 +1926,7 @@ BlockAddress *BlockAddress::lookup(const BasicBlock *BB) { /// Remove the constant from the constant table. void BlockAddress::destroyConstantImpl() { getType()->getContext().pImpl->BlockAddresses.erase(getBasicBlock()); - getBasicBlock()->AdjustBlockAddressRefCount(-1); + getBasicBlock()->setHasAddressTaken(false); } Value *BlockAddress::handleOperandChangeImpl(Value *From, Value *To) { @@ -1939,14 +1939,14 @@ Value *BlockAddress::handleOperandChangeImpl(Value *From, Value *To) { if (NewBA) return NewBA; - getBasicBlock()->AdjustBlockAddressRefCount(-1); + getBasicBlock()->setHasAddressTaken(false); // Remove the old entry, this can't cause the map to rehash (just a // tombstone will get added). getContext().pImpl->BlockAddresses.erase(getBasicBlock()); NewBA = this; setOperand(0, NewBB); - getBasicBlock()->AdjustBlockAddressRefCount(1); + getBasicBlock()->setHasAddressTaken(true); // If we just want to keep the existing value, then return null. // Callers know that this means we shouldn't delete this value. |