Paul Vario
2014-Jun-13 21:58 UTC
[LLVMdev] A question about the BasicBlock::hasAddressTaken() implementation.
Hi Fellows, BasicBlock::hasAddressTaken has the following implementation: bool hasAddressTaken() const { return getSubclassDataFromValue() != 0; } and then, in llvm/IR/Value.h, we have unsigned short getSubclassDataFromValue() const { return SubclassData; } But it's not clear to me at all, how is (SubclassData != 0) equivalent to the basic block has its address taken? What's the logic behind all these? Thanks so much. Best Regards, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140613/1b2cf521/attachment.html>
Tim Northover
2014-Jun-14 06:15 UTC
[LLVMdev] A question about the BasicBlock::hasAddressTaken() implementation.
Hi Paul, On 13 June 2014 22:58, Paul Vario <paul.paul.mit at gmail.com> wrote:> unsigned short getSubclassDataFromValue() const { return > SubclassData; } > > But it's not clear to me at all, how is (SubclassData != 0) equivalent > to the basic block has its address taken? What's the logic behind all these?That field in Value is there as a convenience for anything that inherits from it to use to store a few bits of information. For example, Atomic instructions store what ordering they've been given there; I think arithmetic instructions use it for the wrapping behaviour flags. BasicBlock appears to use it as a reference count: whenever a BasicBlockAddress is created, that value gets incremented by a call to AdjustBlockAddressRefCount. So assuming all BasicBlockAddresses that have been created are actually still in use, it should be accurate. Just don't let them leak, I suppose! Cheers. Tim.