aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Module.cpp
diff options
context:
space:
mode:
authorWolfgang Pieb <wolfgang_pieb@playstation.sony.com>2023-02-06 13:50:37 -0800
committerWolfgang Pieb <wolfgang_pieb@playstation.sony.com>2023-02-08 10:34:56 -0800
commit5d07e0448e38d4be0cc7b1079d72b5e3644e941c (patch)
treef98ec36c2a5f4df3a9ee87516335f8a72f206769 /llvm/lib/IR/Module.cpp
parent66b8d2bb71298cf3f406593464c6d729b7817f51 (diff)
downloadllvm-5d07e0448e38d4be0cc7b1079d72b5e3644e941c.zip
llvm-5d07e0448e38d4be0cc7b1079d72b5e3644e941c.tar.gz
llvm-5d07e0448e38d4be0cc7b1079d72b5e3644e941c.tar.bz2
[TLS]: Clamp the alignment of TLS global variables if required by the target
Adding a module flag 'MaxTLSAlign' describing the maximum alignment a global TLS variable can have. Optimizers are prevented from increasing the alignment of such variables beyond this threshold. Reviewed By: probinson Differential Revision: https://reviews.llvm.org/D140123
Diffstat (limited to 'llvm/lib/IR/Module.cpp')
-rw-r--r--llvm/lib/IR/Module.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 49fadc9..3df1e7b 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -746,6 +746,13 @@ unsigned Module::getOverrideStackAlignment() const {
return 0;
}
+unsigned Module::getMaxTLSAlignment() const {
+ Metadata *MD = getModuleFlag("MaxTLSAlign");
+ if (auto *CI = mdconst::dyn_extract_or_null<ConstantInt>(MD))
+ return CI->getZExtValue();
+ return 0;
+}
+
void Module::setOverrideStackAlignment(unsigned Align) {
addModuleFlag(ModFlagBehavior::Error, "override-stack-alignment", Align);
}