diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2014-01-19 02:13:50 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2014-01-19 02:13:50 +0000 |
commit | 60e425e99ba7ef05b7a52c7068a67c6baa25da38 (patch) | |
tree | a9ebb901ce4706d01180fb0021cc10ec1a561b88 /lib | |
parent | e952af7ae522e4e372fe486e1124d7ff0821ab33 (diff) | |
download | llvm-60e425e99ba7ef05b7a52c7068a67c6baa25da38.tar.gz llvm-60e425e99ba7ef05b7a52c7068a67c6baa25da38.tar.bz2 llvm-60e425e99ba7ef05b7a52c7068a67c6baa25da38.tar.xz |
Add a const lookup routine to get a BlockAddress constant if there is
one, but not create one. This is useful in the verifier when we want to
query the constant if it exists but not create one. To be used in an
upcoming commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199568 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/IR/Constants.cpp | 11 | ||||
-rw-r--r-- | lib/IR/LLVMContextImpl.h | 4 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/IR/Constants.cpp b/lib/IR/Constants.cpp index 1f6f5ac427..ecd2cfd9fd 100644 --- a/lib/IR/Constants.cpp +++ b/lib/IR/Constants.cpp @@ -1375,6 +1375,17 @@ BlockAddress::BlockAddress(Function *F, BasicBlock *BB) BB->AdjustBlockAddressRefCount(1); } +BlockAddress *BlockAddress::lookup(const BasicBlock *BB) { + if (!BB->hasAddressTaken()) + return 0; + + const Function *F = BB->getParent(); + assert(F != 0 && "Block must have a parent"); + BlockAddress *BA = + F->getContext().pImpl->BlockAddresses.lookup(std::make_pair(F, BB)); + assert(BA && "Refcount and block address map disagree!"); + return BA; +} // destroyConstant - Remove the constant from the constant table. // diff --git a/lib/IR/LLVMContextImpl.h b/lib/IR/LLVMContextImpl.h index 39e5d778ed..0433827246 100644 --- a/lib/IR/LLVMContextImpl.h +++ b/lib/IR/LLVMContextImpl.h @@ -281,8 +281,8 @@ public: StringMap<ConstantDataSequential*> CDSConstants; - - DenseMap<std::pair<Function*, BasicBlock*> , BlockAddress*> BlockAddresses; + DenseMap<std::pair<const Function *, const BasicBlock *>, BlockAddress *> + BlockAddresses; ConstantUniqueMap<ExprMapKeyType, const ExprMapKeyType&, Type, ConstantExpr> ExprConstants; |