about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-29 20:11:09 +0000
committerbors <bors@rust-lang.org>2024-05-29 20:11:09 +0000
commitdebd22da66cfa97c74040ebf68e420672ac8560e (patch)
treeabb2e5ad3c4d30c15b364d3114729a89fea28675 /compiler/rustc_codegen_llvm
parente9b7aa08f7cd890dcebd36c198193707d5cd3770 (diff)
parent6ef3dd0d383438770aed1faf37d3f15792aaa7aa (diff)
downloadrust-debd22da66cfa97c74040ebf68e420672ac8560e.tar.gz
rust-debd22da66cfa97c74040ebf68e420672ac8560e.zip
Auto merge of #125732 - matthiaskrgr:rollup-bozbtk3, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #124655 (Add `-Zfixed-x18`)
 - #125693 (Format all source files in `tests/coverage/`)
 - #125700 (coverage: Avoid overflow when the MC/DC condition limit is exceeded)
 - #125705 (Reintroduce name resolution check for trying to access locals from an inline const)
 - #125708 (tier 3 target policy: clarify the point about producing assembly)
 - #125715 (remove unneeded extern crate in rmake test)
 - #125719 (Extract coverage-specific code out of `compiletest::runtest`)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm')
-rw-r--r--compiler/rustc_codegen_llvm/messages.ftl2
-rw-r--r--compiler/rustc_codegen_llvm/src/errors.rs6
-rw-r--r--compiler/rustc_codegen_llvm/src/llvm_util.rs11
3 files changed, 18 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/messages.ftl b/compiler/rustc_codegen_llvm/messages.ftl
index d14fe0299e6..1c126e79762 100644
--- a/compiler/rustc_codegen_llvm/messages.ftl
+++ b/compiler/rustc_codegen_llvm/messages.ftl
@@ -18,6 +18,8 @@ codegen_llvm_error_creating_import_library =
 codegen_llvm_error_writing_def_file =
     Error writing .DEF file: {$error}
 
+codegen_llvm_fixed_x18_invalid_arch = the `-Zfixed-x18` flag is not supported on the `{$arch}` architecture
+
 codegen_llvm_from_llvm_diag = {$message}
 
 codegen_llvm_from_llvm_optimization_diag = {$filename}:{$line}:{$column} {$pass_name} ({$kind}): {$message}
diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs
index e15eda7c66c..9d83dc81163 100644
--- a/compiler/rustc_codegen_llvm/src/errors.rs
+++ b/compiler/rustc_codegen_llvm/src/errors.rs
@@ -254,3 +254,9 @@ pub struct MismatchedDataLayout<'a> {
 pub(crate) struct InvalidTargetFeaturePrefix<'a> {
     pub feature: &'a str,
 }
+
+#[derive(Diagnostic)]
+#[diag(codegen_llvm_fixed_x18_invalid_arch)]
+pub(crate) struct FixedX18InvalidArch<'a> {
+    pub arch: &'a str,
+}
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
index 5552b381025..53b9b530e9b 100644
--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
@@ -1,6 +1,6 @@
 use crate::back::write::create_informational_target_machine;
 use crate::errors::{
-    InvalidTargetFeaturePrefix, PossibleFeature, TargetFeatureDisableOrEnable,
+    FixedX18InvalidArch, InvalidTargetFeaturePrefix, PossibleFeature, TargetFeatureDisableOrEnable,
     UnknownCTargetFeature, UnknownCTargetFeaturePrefix, UnstableCTargetFeature,
 };
 use crate::llvm;
@@ -615,6 +615,15 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
         .flatten();
     features.extend(feats);
 
+    // -Zfixed-x18
+    if sess.opts.unstable_opts.fixed_x18 {
+        if sess.target.arch != "aarch64" {
+            sess.dcx().emit_fatal(FixedX18InvalidArch { arch: &sess.target.arch });
+        } else {
+            features.push("+reserve-x18".into());
+        }
+    }
+
     if diagnostics && let Some(f) = check_tied_features(sess, &featsmap) {
         sess.dcx().emit_err(TargetFeatureDisableOrEnable {
             features: f,