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
#ifndef LLVM_IR_MODULE_H
#define LLVM_IR_MODULE_H
+#include "llvm/ADT/Optional.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/IR/Comdat.h"
#include "llvm/IR/DataLayout.h"
/// \brief Set the PIC level (small or large model)
void setPICLevel(PICLevel::Level PL);
/// @}
+
+ /// @name Utility functions for querying and setting PGO counts
+ /// @{
+
+ /// \brief Set maximum function count in PGO mode
+ void setMaximumFunctionCount(uint64_t);
+
+ /// \brief Returns maximum function count in PGO mode
+ Optional<uint64_t> getMaximumFunctionCount();
+ /// @}
};
/// An raw_ostream inserter for modules.
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();
+}