summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/IR/Module.h11
-rw-r--r--llvm/include/llvm/Support/CodeGen.h4
-rw-r--r--llvm/lib/IR/Module.cpp14
3 files changed, 29 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index 0a6a127bb0d..25585b0cb6a 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -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
/// @{
diff --git a/llvm/include/llvm/Support/CodeGen.h b/llvm/include/llvm/Support/CodeGen.h
index 0ff3d56363c..6e31ef4cb10 100644
--- a/llvm/include/llvm/Support/CodeGen.h
+++ b/llvm/include/llvm/Support/CodeGen.h
@@ -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 {
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 10110367841..b15cac40274 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -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);
}
OpenPOWER on IntegriCloud