[clang] Revert "[NFC][Clang] Move functions of BranchProtectionInfo out of line" (PR #98437)
Daniel Kiss via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 10 23:37:38 PDT 2024
https://github.com/DanielKristofKiss created https://github.com/llvm/llvm-project/pull/98437
Reverts llvm/llvm-project#98329
>From 9a74d0613287e7ae86c305b0250e188e3c3de6c3 Mon Sep 17 00:00:00 2001
From: Daniel Kiss <daniel.kristof.kiss at gmail.com>
Date: Thu, 11 Jul 2024 08:37:25 +0200
Subject: [PATCH] Revert "[NFC][Clang] Move functions of BranchProtectionInfo
out of line (#98329)"
This reverts commit 4710e0f498cb661ca17c99cb174616102fcad923.
---
clang/include/clang/Basic/TargetInfo.h | 23 +++++++++++++++++++----
clang/lib/Basic/TargetInfo.cpp | 22 ----------------------
2 files changed, 19 insertions(+), 26 deletions(-)
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");
-}
More information about the cfe-commits
mailing list