Author: Daniel Kiss Date: 2024-07-11T08:37:47+02:00 New Revision: b65aba292e0d485de286ec36134375e74b1fb95c
URL: https://github.com/llvm/llvm-project/commit/b65aba292e0d485de286ec36134375e74b1fb95c DIFF: https://github.com/llvm/llvm-project/commit/b65aba292e0d485de286ec36134375e74b1fb95c.diff LOG: Revert "[NFC][Clang] Move functions of BranchProtectionInfo out of line" (#98437) Reverts llvm/llvm-project#98329 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 6afa354353e3c..cf7628553647c 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -32,7 +32,9 @@ #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" @@ -45,8 +47,6 @@ namespace llvm { struct fltSemantics; -class Function; -class AttrBuilder; } namespace clang { @@ -1455,9 +1455,24 @@ class TargetInfo : public TransferrableTargetInfo, GuardedControlStack = LangOpts.GuardedControlStack; } - void setFnAttributes(llvm::Function &F) const; + void setFnAttributes(llvm::Function &F) { + llvm::AttrBuilder FuncAttrs(F.getContext()); + setFnAttributes(FuncAttrs); + F.addFnAttrs(FuncAttrs); + } - void setFnAttributes(llvm::AttrBuilder &FuncAttrs) 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"); + } }; /// Determine if the Architecture in this TargetInfo supports branch diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp index cc4b79b4334af..29f5cd14e46e1 100644 --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/lib/Basic/TargetInfo.cpp @@ -18,7 +18,6 @@ #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> @@ -1006,24 +1005,3 @@ 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