[llvm] r267911 - Add "PIE Level" metadata to module flags.
Sriraman Tallam via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 28 11:15:44 PDT 2016
Author: tmsriram
Date: Thu Apr 28 13:15:44 2016
New Revision: 267911
URL: http://llvm.org/viewvc/llvm-project?rev=267911&view=rev
Log:
Add "PIE Level" metadata to module flags.
http://reviews.llvm.org/D19671
Modified:
llvm/trunk/include/llvm/IR/Module.h
llvm/trunk/include/llvm/Support/CodeGen.h
llvm/trunk/lib/IR/Module.cpp
Modified: llvm/trunk/include/llvm/IR/Module.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Module.h?rev=267911&r1=267910&r2=267911&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Module.h (original)
+++ llvm/trunk/include/llvm/IR/Module.h Thu Apr 28 13:15:44 2016
@@ -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
/// @{
Modified: llvm/trunk/include/llvm/Support/CodeGen.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CodeGen.h?rev=267911&r1=267910&r2=267911&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/CodeGen.h (original)
+++ llvm/trunk/include/llvm/Support/CodeGen.h Thu Apr 28 13:15:44 2016
@@ -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 {
Modified: llvm/trunk/lib/IR/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Module.cpp?rev=267911&r1=267910&r2=267911&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Module.cpp (original)
+++ llvm/trunk/lib/IR/Module.cpp Thu Apr 28 13:15:44 2016
@@ -497,6 +497,20 @@ void Module::setPICLevel(PICLevel::Level
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);
}
More information about the llvm-commits
mailing list