summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Constants.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-01-19 02:13:50 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-01-19 02:13:50 +0000
commit6a93692a34a501ed8e4c735175780ee98f3cf48f (patch)
tree83214ee900ba9dd83b7819be9e50f0b37eb1eff0 /llvm/lib/IR/Constants.cpp
parent157a97a6a01424551748ace05bd9c0931e98aefe (diff)
downloadbcm5719-llvm-6a93692a34a501ed8e4c735175780ee98f3cf48f.tar.gz
bcm5719-llvm-6a93692a34a501ed8e4c735175780ee98f3cf48f.zip
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. llvm-svn: 199568
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r--llvm/lib/IR/Constants.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 1f6f5ac4270..ecd2cfd9fd1 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/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.
//
OpenPOWER on IntegriCloud