Author: Daniel Kiss Date: 2024-07-11T07:07:25+02:00 New Revision: 4710e0f498cb661ca17c99cb174616102fcad923
URL: https://github.com/llvm/llvm-project/commit/4710e0f498cb661ca17c99cb174616102fcad923 DIFF: https://github.com/llvm/llvm-project/commit/4710e0f498cb661ca17c99cb174616102fcad923.diff LOG: [NFC][Clang] Move functions of BranchProtectionInfo out of line (#98329) Also let's add const to the setFnAttributes. Added: Modified: clang/include/clang/Basic/TargetInfo.h clang/lib/Basic/TargetInfo.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index cf7628553647c..6afa354353e3c 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -32,9 +32,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" #include "llvm/Frontend/OpenMP/OMPGridValues.h" -#include "llvm/IR/Attributes.h" #include "llvm/IR/DerivedTypes.h" -#include "llvm/IR/Function.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Error.h" #include "llvm/Support/VersionTuple.h" @@ -47,6 +45,8 @@ namespace llvm { struct fltSemantics; +class Function; +class AttrBuilder; } namespace clang { @@ -1455,24 +1455,9 @@ class TargetInfo : public TransferrableTargetInfo, GuardedControlStack = LangOpts.GuardedControlStack; } - void setFnAttributes(llvm::Function &F) { - llvm::AttrBuilder FuncAttrs(F.getContext()); - setFnAttributes(FuncAttrs); - F.addFnAttrs(FuncAttrs); - } + void setFnAttributes(llvm::Function &F) const; - void setFnAttributes(llvm::AttrBuilder &FuncAttrs) { - if (SignReturnAddr != LangOptions::SignReturnAddressScopeKind::None) { - FuncAttrs.addAttribute("sign-return-address", getSignReturnAddrStr()); - FuncAttrs.addAttribute("sign-return-address-key", getSignKeyStr()); - } - if (BranchTargetEnforcement) - FuncAttrs.addAttribute("branch-target-enforcement"); - if (BranchProtectionPAuthLR) - FuncAttrs.addAttribute("branch-protection-pauth-lr"); - if (GuardedControlStack) - FuncAttrs.addAttribute("guarded-control-stack"); - } + void setFnAttributes(llvm::AttrBuilder &FuncAttrs) const; }; /// Determine if the Architecture in this TargetInfo supports branch diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp index 29f5cd14e46e1..cc4b79b4334af 100644 --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/lib/Basic/TargetInfo.cpp @@ -18,6 +18,7 @@ #include "clang/Basic/LangOptions.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/IR/Function.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/TargetParser/TargetParser.h" #include <cstdlib> @@ -1005,3 +1006,24 @@ void TargetInfo::copyAuxTarget(const TargetInfo *Aux) { auto *Src = static_cast<const TransferrableTargetInfo*>(Aux); *Target = *Src; } + +void TargetInfo::BranchProtectionInfo::setFnAttributes( + llvm::Function &F) const { + llvm::AttrBuilder FuncAttrs(F.getContext()); + setFnAttributes(FuncAttrs); + F.addFnAttrs(FuncAttrs); +} + +void TargetInfo::BranchProtectionInfo::setFnAttributes( + llvm::AttrBuilder &FuncAttrs) const { + if (SignReturnAddr != LangOptions::SignReturnAddressScopeKind::None) { + FuncAttrs.addAttribute("sign-return-address", getSignReturnAddrStr()); + FuncAttrs.addAttribute("sign-return-address-key", getSignKeyStr()); + } + if (BranchTargetEnforcement) + FuncAttrs.addAttribute("branch-target-enforcement"); + if (BranchProtectionPAuthLR) + FuncAttrs.addAttribute("branch-protection-pauth-lr"); + if (GuardedControlStack) + FuncAttrs.addAttribute("guarded-control-stack"); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits