You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose extending rustc's -C instrument-coverage to allow support for LLVM's single-byte counters. No defaults would be changed, but -C instrument-coverage=counter would become the "canonical" variant of the current default.
Specifically, I propose -C instrument-coverage=presence-only as an opt-in mechanism for switching to single-byte counters. This option would be guarded behind -Z unstable-options.
(The name presence-only is picked as a happy medium -- "counters" is confusing in a context where the coverage is binary, and "presence" alone would also be confusing because all coverage is presence.)
Background and motivation
Per llvm/llvm-project#75425, single-byte counters are available in LLVM 19.1.0 and later. The equivalent clang frontend specific option for this is currently tucked behind an -mllvm passthrough, e.g. -mllvm -enable-single-byte-coverage.
The main advantage to single-byte counters is performance: LLVM's own (older) benchmarks show a 3-5% runtime improvement on x86(-64) platforms, and a much more dramatic 40-60% runtime improvement on ARM(-64) platforms. Single-byte counters also significant improve code size, since the instrumentation only needs to inject 8-bit counters rather an 64-bit ones.
The main disadvantage to single-byte counters is a decrease in fidelity: single-byte counters no longer track actual block hit counts, and instead only offer a binary "covered or not." This makes them unsuitable for use cases where the "heat" of covered regions is important, but perfectly suitable for use cases where line/block coverage is the primary concern.
Mentors or Reviewers
None yet. This is my first non-trivial compiler-side contribution to Rust, so I would appreciate a reviewer who is familiar with this part of the compiler.
Proposal
I propose extending
rustc's-C instrument-coverageto allow support for LLVM's single-byte counters. No defaults would be changed, but-C instrument-coverage=counterwould become the "canonical" variant of the current default.Specifically, I propose
-C instrument-coverage=presence-onlyas an opt-in mechanism for switching to single-byte counters. This option would be guarded behind-Z unstable-options.(The name
presence-onlyis picked as a happy medium -- "counters" is confusing in a context where the coverage is binary, and "presence" alone would also be confusing because all coverage is presence.)Background and motivation
Per llvm/llvm-project#75425, single-byte counters are available in LLVM 19.1.0 and later. The equivalent clang frontend specific option for this is currently tucked behind an
-mllvmpassthrough, e.g.-mllvm -enable-single-byte-coverage.The main advantage to single-byte counters is performance: LLVM's own (older) benchmarks show a 3-5% runtime improvement on x86(-64) platforms, and a much more dramatic 40-60% runtime improvement on ARM(-64) platforms. Single-byte counters also significant improve code size, since the instrumentation only needs to inject 8-bit counters rather an 64-bit ones.
The main disadvantage to single-byte counters is a decrease in fidelity: single-byte counters no longer track actual block hit counts, and instead only offer a binary "covered or not." This makes them unsuitable for use cases where the "heat" of covered regions is important, but perfectly suitable for use cases where line/block coverage is the primary concern.
Mentors or Reviewers
None yet. This is my first non-trivial compiler-side contribution to Rust, so I would appreciate a reviewer who is familiar with this part of the compiler.
Process
The main points of the Major Change Process are as follows:
@rustbot secondor kickoff a team FCP with@rfcbot fcp $RESOLUTION.You can read more about Major Change Proposals on forge.
Caution
Concerns (2 active)
stabilization-pressureresolved in this commentManaged by
@rustbot—see help for details.