1
Fork 0

Check AArch64 branch-protection earlier in the pipeline.

As suggested in #93516.
This commit is contained in:
Jacob Bramley 2022-11-21 16:05:51 +00:00
parent 203c8765ea
commit 49f3c0b736
8 changed files with 19 additions and 18 deletions

View file

@ -3,7 +3,6 @@ use crate::back::write::to_llvm_code_model;
use crate::callee::get_fn;
use crate::coverageinfo;
use crate::debuginfo;
use crate::errors::BranchProtectionRequiresAArch64;
use crate::llvm;
use crate::llvm_util;
use crate::type_::Type;
@ -275,10 +274,9 @@ pub unsafe fn create_module<'ll>(
}
}
if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
if sess.target.arch != "aarch64" {
sess.emit_err(BranchProtectionRequiresAArch64);
} else {
// AArch64-only options (checked in rustc_session).
if sess.target.arch == "aarch64" {
if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Error,

View file

@ -51,10 +51,6 @@ pub(crate) struct SymbolAlreadyDefined<'a> {
pub symbol_name: &'a str,
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_branch_protection_requires_aarch64)]
pub(crate) struct BranchProtectionRequiresAArch64;
#[derive(Diagnostic)]
#[diag(codegen_llvm_invalid_minimum_alignment)]
pub(crate) struct InvalidMinimumAlignment {