Index: include/llvm/IR/Module.h =================================================================== --- include/llvm/IR/Module.h +++ include/llvm/IR/Module.h @@ -639,7 +639,7 @@ void setPICLevel(PICLevel::Level PL); /// @} - /// @name Utility functions for querying and setting PGO counts + /// @name Utility functions for querying and setting PGO summary /// @{ /// \brief Set maximum function count in PGO mode @@ -647,6 +647,12 @@ /// \brief Returns maximum function count in PGO mode Optional getMaximumFunctionCount(); + + /// \brief Attach profile summary metadata to this module. + void setProfileSummary(Metadata *M); + + /// \brief Returns profile summary metadata + Metadata *getProfileSummary(); /// @} }; Index: lib/IR/Module.cpp =================================================================== --- lib/IR/Module.cpp +++ lib/IR/Module.cpp @@ -485,3 +485,11 @@ return None; return cast(Val->getValue())->getZExtValue(); } + +void Module::setProfileSummary(Metadata *M) { + addModuleFlag(ModFlagBehavior::Error, "ProfileSummary", M); +} + +Metadata *Module::getProfileSummary() { + return getModuleFlag("ProfileSummary"); +}