Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[NFC][Clang] Move functions of BranchProtectionInfo out of line" #98437

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

DanielKristofKiss
Copy link
Member

Reverts #98329

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jul 11, 2024
@DanielKristofKiss DanielKristofKiss merged commit b65aba2 into main Jul 11, 2024
5 of 8 checks passed
@DanielKristofKiss DanielKristofKiss deleted the revert-98329-move_BPI branch July 11, 2024 06:37
@llvmbot
Copy link
Member

llvmbot commented Jul 11, 2024

@llvm/pr-subscribers-clang

Author: Daniel Kiss (DanielKristofKiss)

Changes

Reverts llvm/llvm-project#98329


Full diff: https://github.com/llvm/llvm-project/pull/98437.diff

2 Files Affected:

  • (modified) clang/include/clang/Basic/TargetInfo.h (+19-4)
  • (modified) clang/lib/Basic/TargetInfo.cpp (-22)
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");
-}

aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this pull request Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants