Add "PIE Level" metadata to module flags.

http://reviews.llvm.org/D19671

llvm-svn: 267911
This commit is contained in:
Sriraman Tallam 2016-04-28 18:15:44 +00:00
parent 88164939cd
commit 8d0bae3878
3 changed files with 29 additions and 0 deletions

View File

@ -732,6 +732,17 @@ public:
void setPICLevel(PICLevel::Level PL);
/// @}
/// @}
/// @name Utility functions for querying and setting PIE level
/// @{
/// \brief Returns the PIE level (small or large model)
PIELevel::Level getPIELevel() const;
/// \brief Set the PIE level (small or large model)
void setPIELevel(PIELevel::Level PL);
/// @}
/// @name Utility functions for querying and setting PGO summary
/// @{

View File

@ -32,6 +32,10 @@ namespace llvm {
enum Level { Default=0, Small=1, Large=2 };
}
namespace PIELevel {
enum Level { Default=0, Small=1, Large=2 };
}
// TLS models.
namespace TLSModel {
enum Model {

View File

@ -497,6 +497,20 @@ void Module::setPICLevel(PICLevel::Level PL) {
addModuleFlag(ModFlagBehavior::Error, "PIC Level", PL);
}
PIELevel::Level Module::getPIELevel() const {
auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("PIE Level"));
if (!Val)
return PIELevel::Default;
return static_cast<PIELevel::Level>(
cast<ConstantInt>(Val->getValue())->getZExtValue());
}
void Module::setPIELevel(PIELevel::Level PL) {
addModuleFlag(ModFlagBehavior::Error, "PIE Level", PL);
}
void Module::setMaximumFunctionCount(uint64_t Count) {
addModuleFlag(ModFlagBehavior::Error, "MaxFunctionCount", Count);
}