diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2020-11-23 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2020-11-23 00:00:00 +0000 |
| commit | fafe3cd68290b7440e1ea66fca8438363a431274 (patch) | |
| tree | 98bf427932508f9ea89691edc0b2e2e7e22c1b44 | |
| parent | 068320b39e3e4839d832b3aa71fa910ba170673b (diff) | |
| download | rust-fafe3cd68290b7440e1ea66fca8438363a431274.tar.gz rust-fafe3cd68290b7440e1ea66fca8438363a431274.zip | |
Allow using `-Z fewer-names=no` to retain value names
Change `-Z fewer-names` into an optional boolean flag and allow using it to either discard value names when true or retain them when false, regardless of other settings.
| -rw-r--r-- | compiler/rustc_interface/src/tests.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 15 | ||||
| -rw-r--r-- | src/test/codegen/fewer-names.rs | 20 |
4 files changed, 31 insertions, 8 deletions
diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 1fc2d281e79..01d5ed2f34a 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -547,7 +547,7 @@ fn test_debugging_options_tracking_hash() { tracked!(debug_macros, true); tracked!(dep_info_omit_d_target, true); tracked!(dual_proc_macros, true); - tracked!(fewer_names, true); + tracked!(fewer_names, Some(true)); tracked!(force_overflow_checks, Some(true)); tracked!(force_unstable_if_unmarked, true); tracked!(fuel, Some(("abc".to_string(), 99))); diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 1cd3d11e321..ba083140f51 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -900,7 +900,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "emits a future-incompatibility report for lints (RFC 2834)"), emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED], "emit a section containing stack size metadata (default: no)"), - fewer_names: bool = (false, parse_bool, [TRACKED], + fewer_names: Option<bool> = (None, parse_opt_bool, [TRACKED], "reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) \ (default: no)"), force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED], diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 419d1447764..5dddf0eb72e 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -734,12 +734,15 @@ impl Session { self.opts.cg.panic.unwrap_or(self.target.panic_strategy) } pub fn fewer_names(&self) -> bool { - let more_names = self.opts.output_types.contains_key(&OutputType::LlvmAssembly) - || self.opts.output_types.contains_key(&OutputType::Bitcode) - // AddressSanitizer and MemorySanitizer use alloca name when reporting an issue. - || self.opts.debugging_opts.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::MEMORY); - - self.opts.debugging_opts.fewer_names || !more_names + if let Some(fewer_names) = self.opts.debugging_opts.fewer_names { + fewer_names + } else { + let more_names = self.opts.output_types.contains_key(&OutputType::LlvmAssembly) + || self.opts.output_types.contains_key(&OutputType::Bitcode) + // AddressSanitizer and MemorySanitizer use alloca name when reporting an issue. + || self.opts.debugging_opts.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::MEMORY); + !more_names + } } pub fn unstable_options(&self) -> bool { diff --git a/src/test/codegen/fewer-names.rs b/src/test/codegen/fewer-names.rs new file mode 100644 index 00000000000..53a926d49ef --- /dev/null +++ b/src/test/codegen/fewer-names.rs @@ -0,0 +1,20 @@ +// no-system-llvm +// compile-flags: -Coverflow-checks=no -O +// revisions: YES NO +// [YES]compile-flags: -Zfewer-names=yes +// [NO] compile-flags: -Zfewer-names=no +#![crate_type = "lib"] + +#[no_mangle] +pub fn sum(x: u32, y: u32) -> u32 { +// YES-LABEL: define i32 @sum(i32 %0, i32 %1) +// YES-NEXT: %3 = add i32 %1, %0 +// YES-NEXT: ret i32 %3 + +// NO-LABEL: define i32 @sum(i32 %x, i32 %y) +// NO-NEXT: start: +// NO-NEXT: %z = add i32 %y, %x +// NO-NEXT: ret i32 %z + let z = x + y; + z +} |
