Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub(crate) fn frame_pointer_type_attr<'ll>(
let opts = &sess.opts;
// "mcount" function relies on stack pointer.
// See <https://sourceware.org/binutils/docs/gprof/Implementation.html>.
if opts.unstable_opts.instrument_mcount {
if opts.cg.instrument_mcount {
fp.ratchet(FramePointer::Always);
}
fp.ratchet(opts.cg.force_frame_pointers);
Expand Down Expand Up @@ -180,7 +180,7 @@ fn instrument_function_attr<'ll>(
sess: &Session,
) -> SmallVec<[&'ll Attribute; 4]> {
let mut attrs = SmallVec::new();
if sess.opts.unstable_opts.instrument_mcount {
if sess.opts.cg.instrument_mcount {
// Similar to `clang -pg` behavior. Handled by the
// `post-inline-ee-instrument` LLVM pass.

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ fn test_codegen_options_tracking_hash() {
tracked!(force_frame_pointers, FramePointer::Always);
tracked!(force_unwind_tables, Some(true));
tracked!(instrument_coverage, InstrumentCoverage::Yes);
tracked!(instrument_mcount, true);
tracked!(jump_tables, false);
tracked!(link_dead_code, Some(true));
tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
Expand Down Expand Up @@ -813,7 +814,6 @@ fn test_unstable_options_tracking_hash() {
tracked!(inline_mir, Some(true));
tracked!(inline_mir_hint_threshold, Some(123));
tracked!(inline_mir_threshold, Some(123));
tracked!(instrument_mcount, true);
tracked!(instrument_xray, Some(InstrumentXRay::default()));
tracked!(link_directives, false);
tracked!(link_only, true);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,8 @@ options! {
"instrument the generated code to support LLVM source-based code coverage reports \
(note, the compiler build config must include `profiler = true`); \
implies `-C symbol-mangling-version=v0`"),
instrument_mcount: bool = (false, parse_bool, [TRACKED],
"insert function instrument code for mcount-based tracing (default: no)"),
jump_tables: bool = (true, parse_bool, [TRACKED],
"allow jump table and lookup table generation from switch case lowering (default: yes)"),
link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
Expand Down Expand Up @@ -2385,8 +2387,6 @@ options! {
"a default MIR inlining threshold (default: 50)"),
input_stats: bool = (false, parse_bool, [UNTRACKED],
"print some statistics about AST and HIR (default: no)"),
instrument_mcount: bool = (false, parse_bool, [TRACKED],
"insert function instrument code for mcount-based tracing (default: no)"),
instrument_xray: Option<InstrumentXRay> = (None, parse_instrument_xray, [TRACKED],
"insert function instrument code for XRay-based tracing (default: no)
Optional extra settings:
Expand Down
6 changes: 6 additions & 0 deletions src/doc/rustc/src/codegen-options/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ Note that while the `-C instrument-coverage` option is stable, the profile data
format produced by the resulting instrumentation may change, and may not work
with coverage tools other than those built and shipped with the compiler.

## instrument-mcount

This option inserts an mcount profiling call into each function prologue within
the crate being compiled. The instrumentation is compatible with gprof and
similiar tools.

## jump-tables

This option is used to allow or prevent the LLVM codegen backend from creating
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/x86_64-mcount.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ assembly-output: emit-asm
//@ compile-flags: -Zinstrument-mcount=y -Cllvm-args=-x86-asm-syntax=intel
//@ compile-flags: -Cinstrument-mcount=y -Cllvm-args=-x86-asm-syntax=intel

//@ revisions: x86_64-linux
//@[x86_64-linux] compile-flags: --target=x86_64-unknown-linux-gnu
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen-llvm/instrument-mcount.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
//@ compile-flags: -Z instrument-mcount -Copt-level=0
//@ compile-flags: -C instrument-mcount=yes -Copt-level=0

#![crate_type = "lib"]

Expand Down
Loading