From 3af624272aeb25f0e7be4e1752631a86ce7c6358 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sat, 4 May 2024 16:16:34 +0200 Subject: [PATCH 1/3] rustc_codegen_ssa: Remove unused ModuleConfig::inline_threshold --- compiler/rustc_codegen_ssa/src/back/write.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index dec87db0fc5cd..9115f130d499e 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -120,7 +120,6 @@ pub struct ModuleConfig { pub vectorize_loop: bool, pub vectorize_slp: bool, pub merge_functions: bool, - pub inline_threshold: Option, pub emit_lifetime_markers: bool, pub llvm_plugins: Vec, } @@ -280,7 +279,6 @@ impl ModuleConfig { } }, - inline_threshold: sess.opts.cg.inline_threshold, emit_lifetime_markers: sess.emit_lifetime_markers(), llvm_plugins: if_regular!(sess.opts.unstable_opts.llvm_plugins.clone(), vec![]), } From 651ff643ae68438213bded335ef47cc9c50d3039 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Fri, 14 Jun 2024 19:48:40 +0200 Subject: [PATCH 2/3] Fix typo in `-Cno-stack-check` deprecation warning The flag `--no-stack-check` does not exist: $ rustc --no-stack-check error: Unrecognized option: 'no-stack-check'. Did you mean `-C no-stack-check`? --- compiler/rustc_driver_impl/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 9acff4a0a26ce..f7828b033bb80 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -1133,7 +1133,7 @@ pub fn describe_flag_categories(early_dcx: &EarlyDiagCtxt, matches: &Matches) -> } if cg_flags.iter().any(|x| *x == "no-stack-check") { - early_dcx.early_warn("the --no-stack-check flag is deprecated and does nothing"); + early_dcx.early_warn("the `-Cno-stack-check` flag is deprecated and does nothing"); } if cg_flags.iter().any(|x| *x == "passes=list") { From f5f067bf9d8de86f3a546a33d8a2e08dfa64cde1 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sat, 4 May 2024 16:21:50 +0200 Subject: [PATCH 3/3] Deprecate no-op codegen option `-Cinline-threshold=...` This deprecates `-Cinline-threshold` since using it has no effect. This has been the case since the new LLVM pass manager started being used, more than 2 years ago. --- compiler/rustc_codegen_llvm/src/back/write.rs | 3 --- compiler/rustc_driver_impl/src/lib.rs | 4 ++++ compiler/rustc_session/src/options.rs | 3 ++- src/doc/rustc/src/codegen-options/index.md | 17 +++-------------- .../ui/codegen/issue-82833-slice-miscompile.rs | 2 +- .../deprecation/deprecated_inline_threshold.rs | 4 ++++ .../deprecated_inline_threshold.stderr | 2 ++ 7 files changed, 16 insertions(+), 19 deletions(-) create mode 100644 tests/ui/deprecation/deprecated_inline_threshold.rs create mode 100644 tests/ui/deprecation/deprecated_inline_threshold.stderr diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 02e3bb06dda3e..afacd0994b558 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -564,9 +564,6 @@ pub(crate) unsafe fn llvm_optimize( let llvm_plugins = config.llvm_plugins.join(","); - // FIXME: NewPM doesn't provide a facility to pass custom InlineParams. - // We would have to add upstream support for this first, before we can support - // config.inline_threshold and our more aggressive default thresholds. let result = llvm::LLVMRustOptimize( module.module_llvm.llmod(), &*module.module_llvm.tm, diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index f7828b033bb80..c51244a2c78fe 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -1136,6 +1136,10 @@ pub fn describe_flag_categories(early_dcx: &EarlyDiagCtxt, matches: &Matches) -> early_dcx.early_warn("the `-Cno-stack-check` flag is deprecated and does nothing"); } + if cg_flags.iter().any(|x| x.starts_with("inline-threshold")) { + early_dcx.early_warn("the `-Cinline-threshold` flag is deprecated and does nothing (consider using `-Cllvm-args=--inline-threshold=...`)"); + } + if cg_flags.iter().any(|x| *x == "passes=list") { let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend=")); diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index fd4a3a9e6cebd..2382412ee1a66 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1485,7 +1485,8 @@ options! { incremental: Option = (None, parse_opt_string, [UNTRACKED], "enable incremental compilation"), inline_threshold: Option = (None, parse_opt_number, [TRACKED], - "set the threshold for inlining a function"), + "this option is deprecated and does nothing \ + (consider using `-Cllvm-args=--inline-threshold=...`)"), #[rustc_lint_opt_deny_field_access("use `Session::instrument_coverage` instead of this field")] instrument_coverage: InstrumentCoverage = (InstrumentCoverage::No, parse_instrument_coverage, [TRACKED], "instrument the generated code to support LLVM source-based code coverage reports \ diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index babe2bc342bb0..cd10168bc1cf3 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -184,20 +184,9 @@ incremental files will be stored. ## inline-threshold -This option lets you set the default threshold for inlining a function. It -takes an unsigned integer as a value. Inlining is based on a cost model, where -a higher threshold will allow more inlining. - -The default depends on the [opt-level](#opt-level): - -| opt-level | Threshold | -|-----------|-----------| -| 0 | N/A, only inlines always-inline functions | -| 1 | N/A, only inlines always-inline functions and LLVM lifetime intrinsics | -| 2 | 225 | -| 3 | 275 | -| s | 75 | -| z | 25 | +This option is deprecated and does nothing. + +Consider using `-Cllvm-args=--inline-threshold=...`. ## instrument-coverage diff --git a/tests/ui/codegen/issue-82833-slice-miscompile.rs b/tests/ui/codegen/issue-82833-slice-miscompile.rs index 7723679dab19e..32eac923a6361 100644 --- a/tests/ui/codegen/issue-82833-slice-miscompile.rs +++ b/tests/ui/codegen/issue-82833-slice-miscompile.rs @@ -1,5 +1,5 @@ //@ run-pass -//@ compile-flags: -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Copt-level=0 -Cdebuginfo=2 +//@ compile-flags: -Ccodegen-units=1 -Cllvm-args=--inline-threshold=0 -Clink-dead-code -Copt-level=0 -Cdebuginfo=2 // Make sure LLVM does not miscompile this. diff --git a/tests/ui/deprecation/deprecated_inline_threshold.rs b/tests/ui/deprecation/deprecated_inline_threshold.rs new file mode 100644 index 0000000000000..56e033b8cf547 --- /dev/null +++ b/tests/ui/deprecation/deprecated_inline_threshold.rs @@ -0,0 +1,4 @@ +//@ check-pass +//@ compile-flags: -Cinline-threshold=666 + +fn main() {} diff --git a/tests/ui/deprecation/deprecated_inline_threshold.stderr b/tests/ui/deprecation/deprecated_inline_threshold.stderr new file mode 100644 index 0000000000000..c4f8ff092b29a --- /dev/null +++ b/tests/ui/deprecation/deprecated_inline_threshold.stderr @@ -0,0 +1,2 @@ +warning: the `-Cinline-threshold` flag is deprecated and does nothing (consider using `-Cllvm-args=--inline-threshold=...`) +