about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorJacob Bramley <jacob.bramley@arm.com>2022-12-13 17:04:02 +0000
committerJacob Bramley <jacob.bramley@arm.com>2022-12-13 17:04:02 +0000
commit73d374f3e7d5fe9635a23937cdc2f7e1d1c29224 (patch)
tree7b4c0037e3c7aa9e187a917e0dbaa2979d2e40ee /compiler/rustc_codegen_llvm/src
parentf4d51b8ca954d9353e5a250646c219d2e597b8cb (diff)
downloadrust-73d374f3e7d5fe9635a23937cdc2f7e1d1c29224.tar.gz
rust-73d374f3e7d5fe9635a23937cdc2f7e1d1c29224.zip
bug! if branch-protection makes it to non-AArch64 codegen.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/context.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs
index a22a67ad7d3..f6fcdc90cb6 100644
--- a/compiler/rustc_codegen_llvm/src/context.rs
+++ b/compiler/rustc_codegen_llvm/src/context.rs
@@ -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."
+            );
         }
     }