summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorEaswaran Raman <eraman@google.com>2015-12-03 20:57:37 +0000
committerEaswaran Raman <eraman@google.com>2015-12-03 20:57:37 +0000
commitecb05e512499fa84bde009110a692037f24e80d8 (patch)
tree9b67bf3dccf4208ea7a10923d1bc990a53ac01c8 /llvm/lib/IR
parentc3ec9508ea1d522cb488459f965e02dddd240d5e (diff)
downloadbcm5719-llvm-ecb05e512499fa84bde009110a692037f24e80d8.tar.gz
bcm5719-llvm-ecb05e512499fa84bde009110a692037f24e80d8.zip
Interface to attach maximum function count from PGO to module as module flags.
This provides interface to get and set maximum function counts to Module. This would allow things like determination of function hotness. The actual setting of this max function count will have to be done in the frontend. Differential Revision: http://reviews.llvm.org/D15003 llvm-svn: 254647
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/Module.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 2b9adad44ba..2acd9db210d 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -491,3 +491,15 @@ PICLevel::Level Module::getPICLevel() const {
void Module::setPICLevel(PICLevel::Level PL) {
addModuleFlag(ModFlagBehavior::Error, "PIC Level", PL);
}
+
+void Module::setMaximumFunctionCount(uint64_t Count) {
+ addModuleFlag(ModFlagBehavior::Error, "MaxFunctionCount", Count);
+}
+
+Optional<uint64_t> Module::getMaximumFunctionCount() {
+ auto *Val =
+ cast_or_null<ConstantAsMetadata>(getModuleFlag("MaxFunctionCount"));
+ if (!Val)
+ return None;
+ return cast<ConstantInt>(Val->getValue())->getZExtValue();
+}
OpenPOWER on IntegriCloud