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
This commit is contained in:
Easwaran Raman
2015-12-03 20:57:37 +00:00
parent c3ec9508ea
commit ecb05e5124
2 changed files with 23 additions and 0 deletions

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();
}