bug! if branch-protection makes it to non-AArch64 codegen.

This commit is contained in:
Jacob Bramley 2022-12-13 17:04:02 +00:00
parent f4d51b8ca9
commit 73d374f3e7

View File

@ -274,9 +274,8 @@ pub unsafe fn create_module<'ll>(
}
}
// 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 {
if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
if sess.target.arch == "aarch64" {
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Error,
@ -302,6 +301,11 @@ pub unsafe fn create_module<'ll>(
"sign-return-address-with-bkey\0".as_ptr().cast(),
u32::from(pac_opts.key == PAuthKey::B),
);
} else {
bug!(
"branch-protection used on non-AArch64 target; \
this should be checked in rustc_session."
);
}
}