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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254647 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Easwaran Raman
2015-12-03 20:57:37 +00:00
parent 3a8af93eb7
commit 52c4f7de09
2 changed files with 23 additions and 0 deletions
+12
View File
@@ -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();
}