diff options
author | Fangrui Song <i@maskray.me> | 2022-07-26 09:48:35 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-07-26 09:48:36 -0700 |
commit | de1b5c91453fb9fc65b931a9afa53c8d407f8460 (patch) | |
tree | c23707dabe1ef6db1460e34d89954817806feef4 /clang/lib | |
parent | 9891bb2302f60d1b130de6fc4a13055504fb525d (diff) | |
download | llvm-de1b5c91453fb9fc65b931a9afa53c8d407f8460.zip llvm-de1b5c91453fb9fc65b931a9afa53c8d407f8460.tar.gz llvm-de1b5c91453fb9fc65b931a9afa53c8d407f8460.tar.bz2 |
[AArch64] Simplify BTI/PAC-RET module flags
These module flags use the Min merge behavior with a default value of
zero, so we don't need to emit them if zero.
Reviewed By: danielkiss
Differential Revision: https://reviews.llvm.org/D130145
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 29713a5..918425b 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -795,18 +795,17 @@ void CodeGenModule::Release() { Arch == llvm::Triple::arm || Arch == llvm::Triple::armeb || Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_32 || Arch == llvm::Triple::aarch64_be) { - getModule().addModuleFlag(llvm::Module::Min, "branch-target-enforcement", - LangOpts.BranchTargetEnforcement); - - getModule().addModuleFlag(llvm::Module::Min, "sign-return-address", - LangOpts.hasSignReturnAddress()); - - getModule().addModuleFlag(llvm::Module::Min, "sign-return-address-all", - LangOpts.isSignReturnAddressScopeAll()); - - getModule().addModuleFlag(llvm::Module::Min, - "sign-return-address-with-bkey", - !LangOpts.isSignReturnAddressWithAKey()); + if (LangOpts.BranchTargetEnforcement) + getModule().addModuleFlag(llvm::Module::Min, "branch-target-enforcement", + 1); + if (LangOpts.hasSignReturnAddress()) + getModule().addModuleFlag(llvm::Module::Min, "sign-return-address", 1); + if (LangOpts.isSignReturnAddressScopeAll()) + getModule().addModuleFlag(llvm::Module::Min, "sign-return-address-all", + 1); + if (!LangOpts.isSignReturnAddressWithAKey()) + getModule().addModuleFlag(llvm::Module::Min, + "sign-return-address-with-bkey", 1); } if (!CodeGenOpts.MemoryProfileOutput.empty()) { |