From 033138ea452f5f493fb5095e5963419905ad12e1 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Fri, 21 May 2021 15:53:21 -0700 Subject: [IR] make stack-protector-guard-* flags into module attrs D88631 added initial support for: - -mstack-protector-guard= - -mstack-protector-guard-reg= - -mstack-protector-guard-offset= flags, and D100919 extended these to AArch64. Unfortunately, these flags aren't retained for LTO. Make them module attributes rather than TargetOptions. Link: https://github.com/ClangBuiltLinux/linux/issues/1378 Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D102742 --- clang/lib/CodeGen/CodeGenModule.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8d1b2ea5d522..744ccf0fe59f 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -777,6 +777,15 @@ void CodeGenModule::Release() { if (!getCodeGenOpts().RecordCommandLine.empty()) EmitCommandLineMetadata(); + if (!getCodeGenOpts().StackProtectorGuard.empty()) + getModule().setStackProtectorGuard(getCodeGenOpts().StackProtectorGuard); + if (!getCodeGenOpts().StackProtectorGuardReg.empty()) + getModule().setStackProtectorGuardReg( + getCodeGenOpts().StackProtectorGuardReg); + if (getCodeGenOpts().StackProtectorGuardOffset != INT_MAX) + getModule().setStackProtectorGuardOffset( + getCodeGenOpts().StackProtectorGuardOffset); + getTargetCodeGenInfo().emitTargetMetadata(*this, MangledDeclNames); EmitBackendOptionsMetadata(getCodeGenOpts()); -- cgit v1.2.3