diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-30 22:33:29 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-30 22:33:29 +0000 |
commit | 3821176b2eb9fe5e66929f3df6f204fa6cb2e4d6 (patch) | |
tree | 3dc967f7b4c55152dddb6a5e1fdad3bd3a168a84 /include/llvm/BasicBlock.h | |
parent | 57f224a5a473462f85e94c457c7548af27c37f0b (diff) |
make hasAddressTaken() constant time by storing a refcount in BB's subclass data.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85625 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/BasicBlock.h')
-rw-r--r-- | include/llvm/BasicBlock.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index c6e6080209..10f2577869 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -23,6 +23,7 @@ namespace llvm { class TerminatorInst; class LLVMContext; +class BlockAddress; template<> struct ilist_traits<Instruction> : public SymbolTableListTraits<Instruction, BasicBlock> { @@ -66,7 +67,7 @@ private: /// @brief LLVM Basic Block Representation class BasicBlock : public Value, // Basic blocks are data objects also public ilist_node<BasicBlock> { - + friend class BlockAddress; public: typedef iplist<Instruction> InstListType; private: @@ -238,7 +239,15 @@ public: /// hasAddressTaken - returns true if there are any uses of this basic block /// other than direct branches, switches, etc. to it. - bool hasAddressTaken() const; + bool hasAddressTaken() const { return SubclassData != 0; } +private: + /// AdjustBlockAddressRefCount - BasicBlock stores the number of BlockAddress + /// objects using it. This is almost always 0, sometimes one, possibly but + /// almost never 2, and inconceivably 3 or more. + void AdjustBlockAddressRefCount(int Amt) { + SubclassData += Amt; + assert((int)(char)SubclassData >= 0 && "Refcount wrap-around"); + } }; } // End llvm namespace |