From 5d07e0448e38d4be0cc7b1079d72b5e3644e941c Mon Sep 17 00:00:00 2001 From: Wolfgang Pieb Date: Mon, 6 Feb 2023 13:50:37 -0800 Subject: [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 --- clang/lib/CodeGen/CodeGenModule.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 57c9e589be3b..0f93c3319435 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -947,6 +947,10 @@ void CodeGenModule::Release() { if (getCodeGenOpts().SkipRaxSetup) getModule().addModuleFlag(llvm::Module::Override, "SkipRaxSetup", 1); + if (getContext().getTargetInfo().getMaxTLSAlign()) + getModule().addModuleFlag(llvm::Module::Error, "MaxTLSAlign", + getContext().getTargetInfo().getMaxTLSAlign()); + getTargetCodeGenInfo().emitTargetMetadata(*this, MangledDeclNames); EmitBackendOptionsMetadata(getCodeGenOpts()); -- cgit v1.2.3