aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.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/Transforms/Utils/Local.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/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 624907a..ddef654 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1423,6 +1423,12 @@ static Align tryEnforceAlignment(Value *V, Align PrefAlign,
if (!GO->canIncreaseAlignment())
return CurrentAlign;
+ if (GO->isThreadLocal()) {
+ unsigned MaxTLSAlign = GO->getParent()->getMaxTLSAlignment() / CHAR_BIT;
+ if (MaxTLSAlign && PrefAlign > Align(MaxTLSAlign))
+ PrefAlign = Align(MaxTLSAlign);
+ }
+
GO->setAlignment(PrefAlign);
return PrefAlign;
}