summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/attributes.rs
diff options
context:
space:
mode:
authorJamie Cunliffe <Jamie.Cunliffe@arm.com>2021-12-01 15:56:59 +0000
committerJamie Cunliffe <Jamie.Cunliffe@arm.com>2021-12-01 15:56:59 +0000
commit984ca4689dbceea29bbfcf54c4743b45fccf7ad1 (patch)
tree50e979ae7eed117e44f6bce9a82003fe0270f51c /compiler/rustc_codegen_llvm/src/attributes.rs
parent837cc1687f7c0d35a4e90a2f6bee377b5a2ecfd5 (diff)
downloadrust-984ca4689dbceea29bbfcf54c4743b45fccf7ad1.tar.gz
rust-984ca4689dbceea29bbfcf54c4743b45fccf7ad1.zip
Review comments
- Changed the separator from '+' to ','.
- Moved the branch protection options from -C to -Z.
- Additional test for incorrect branch-protection option.
- Remove LLVM < 12 code.
- Style fixes.

Co-authored-by: James McGregor <james.mcgregor2@arm.com>
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/attributes.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/attributes.rs54
1 files changed, 1 insertions, 53 deletions
diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs
index 768e03b5ef3..8e6329a997f 100644
--- a/compiler/rustc_codegen_llvm/src/attributes.rs
+++ b/compiler/rustc_codegen_llvm/src/attributes.rs
@@ -9,7 +9,7 @@ use rustc_hir::def_id::DefId;
 use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use rustc_middle::ty::layout::HasTyCtxt;
 use rustc_middle::ty::{self, TyCtxt};
-use rustc_session::config::{BranchProtection, OptLevel, PAuthKey};
+use rustc_session::config::OptLevel;
 use rustc_session::Session;
 use rustc_target::spec::abi::Abi;
 use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType, StackProtector};
@@ -203,58 +203,6 @@ pub fn non_lazy_bind(sess: &Session, llfn: &'ll Value) {
     }
 }
 
-pub fn set_branch_protection(sess: &Session, llfn: &'ll Value) {
-    // Setting PAC/BTI function attributes is only necessary for LLVM 11 and earlier.
-    // For LLVM 12 and greater, module-level metadata attributes are set in
-    // `compiler/rustc_codegen_llvm/src/context.rs`.
-    if llvm_util::get_version() >= (12, 0, 0) {
-        return;
-    }
-
-    let BranchProtection { bti, pac_ret: pac } = sess.opts.cg.branch_protection;
-
-    if bti {
-        llvm::AddFunctionAttrString(
-            llfn,
-            llvm::AttributePlace::Function,
-            cstr!("branch-target-enforcement"),
-        );
-    }
-
-    if let Some(pac_opts) = pac {
-        if pac_opts.leaf {
-            llvm::AddFunctionAttrStringValue(
-                llfn,
-                llvm::AttributePlace::Function,
-                cstr!("sign-return-address"),
-                cstr!("non-leaf"),
-            );
-        } else {
-            llvm::AddFunctionAttrStringValue(
-                llfn,
-                llvm::AttributePlace::Function,
-                cstr!("sign-return-address"),
-                cstr!("all"),
-            );
-        }
-
-        match pac_opts.key {
-            PAuthKey::A => llvm::AddFunctionAttrStringValue(
-                llfn,
-                llvm::AttributePlace::Function,
-                cstr!("sign-return-address-key"),
-                cstr!("a_key"),
-            ),
-            PAuthKey::B => llvm::AddFunctionAttrStringValue(
-                llfn,
-                llvm::AttributePlace::Function,
-                cstr!("sign-return-address-key"),
-                cstr!("b_key"),
-            ),
-        }
-    }
-}
-
 pub(crate) fn default_optimisation_attrs(sess: &Session, llfn: &'ll Value) {
     match sess.opts.optimize {
         OptLevel::Size => {