Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f6ee72b
doc: update PGO guide with Sample-based PGO information
Apr 28, 2026
84f2d63
doc: move option description from Unstable book to the proper place
Apr 28, 2026
9c33952
fix: make stabilization preparation for the flags
Apr 28, 2026
6978fab
doc: a attempt to add PGO-related UI tests
May 10, 2026
f19a92f
doc: add more information about the flags
zamazan4ik May 31, 2026
4cc83fd
doc: apply 80 width limit to the PGO guide
May 31, 2026
167a496
doc: add more information about debuginfo-for-profiling
May 31, 2026
0570f86
fix: remove debuginfo-for-profiling from stabilization
Jun 1, 2026
01a5987
doc: add a small note about unstable flag
zamazan4ik Jun 2, 2026
9b4b2c6
Fix std-features example in bootstrap.example.toml
alyssais Aug 11, 2026
4fc505d
add dir operations
Qelxiros Aug 4, 2026
76c314f
Make ShardedHashMap::with_capacity split capacity between shards
Zoxc Aug 14, 2026
d871d69
Add regression test for dyn impl missing type
lybang-lab Aug 15, 2026
8b85851
avoid pointless spans in target modifier errors
RalfJung Aug 16, 2026
3da0457
add crashtests
cyrgani Aug 16, 2026
bd9ab86
Improve `powerpc-types.rs` test
beetrees Aug 16, 2026
185ac52
Fix inconsistency in backward handling of `Yield`
nnethercote Aug 4, 2026
828faaa
Improve edge computation in `Backward::apply_effects_in_block`
nnethercote Aug 4, 2026
ea4322d
De-`mut` an `apply_switch_int_edge_effect` argument
nnethercote Aug 4, 2026
bc072b6
Rollup merge of #160533 - Qelxiros:dirfd-dirs, r=Mark-Simulacrum
jhpratt Aug 17, 2026
04d3aa1
Rollup merge of #161127 - Zoxc:shard-cap, r=nnethercote
jhpratt Aug 17, 2026
6dd399a
Rollup merge of #161183 - RalfJung:target-modifier-spans, r=estebank
jhpratt Aug 17, 2026
93fdeb5
Rollup merge of #161203 - nnethercote:Analysis-cleanups, r=cjgillot
jhpratt Aug 17, 2026
4e990da
Rollup merge of #155942 - zamazan4ik:stabilize-profile-sample-use-and…
jhpratt Aug 17, 2026
7b626ab
Rollup merge of #160939 - alyssais:std-features, r=Mark-Simulacrum
jhpratt Aug 17, 2026
2968464
Rollup merge of #161139 - KevinA-cpu:regression-test-152668, r=nnethe…
jhpratt Aug 17, 2026
0095b6e
Rollup merge of #161150 - cyrgani:tests-4, r=folkertdev
jhpratt Aug 17, 2026
ca1576b
Rollup merge of #161191 - beetrees:powerpc-inline-asm-test-improve, r…
jhpratt Aug 17, 2026
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
2 changes: 1 addition & 1 deletion bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@
#
# Since libstd also builds libcore and liballoc as dependencies and all their features are mirrored
# as libstd features, this option can also be used to configure features such as optimize_for_size.
#rust.std-features = ["panic_unwind"]
#rust.std-features = ["panic-unwind"]

# Trigger a `DebugBreak` after an internal compiler error during bootstrap on Windows
#rust.break-on-ice = true
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
to_add.push(uwtable_attr(cx.llcx, sess.opts.unstable_opts.use_sync_unwind));
}

if sess.opts.unstable_opts.profile_sample_use.is_some() {
if sess.opts.cg.profile_sample_use.is_some() {
to_add.push(llvm::CreateAttrString(cx.llcx, "use-sample-profile"));
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl<'a> GccLinker<'a> {
config::OptLevel::Aggressive => "O3",
};

if let Some(path) = &self.sess.opts.unstable_opts.profile_sample_use {
if let Some(path) = &self.sess.opts.cg.profile_sample_use {
self.link_arg(&format!("-plugin-opt=sample-profile={}", path.display()));
};
let prefix = if self.codegen_backend == "gcc" {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl ModuleConfig {
SwitchWithOptPath::Disabled
),
pgo_use: if_regular!(sess.opts.cg.profile_use.clone(), None),
pgo_sample_use: if_regular!(sess.opts.unstable_opts.profile_sample_use.clone(), None),
pgo_sample_use: if_regular!(sess.opts.cg.profile_sample_use.clone(), None),
debug_info_for_profiling: sess.opts.unstable_opts.debuginfo_for_profiling,
instrument_coverage: if_regular!(sess.instrument_coverage(), false),

Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_data_structures/src/sharded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ pub type ShardedHashMap<K, V> = Sharded<hash_table::HashTable<(K, V)>>;

impl<K: Eq, V> ShardedHashMap<K, V> {
pub fn with_capacity(cap: usize) -> Self {
Self::new(|| HashTable::with_capacity(cap))
let per_shard_cap = cap.div_ceil(shards());
Self::new(|| HashTable::with_capacity(per_shard_cap))
}
pub fn len(&self) -> usize {
self.lock_shards().map(|shard| shard.len()).sum()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
checksum_hash_algo,
));
}
if let Some(ref profile_sample) = sess.opts.unstable_opts.profile_sample_use {
if let Some(ref profile_sample) = sess.opts.cg.profile_sample_use {
files.extend(hash_iter_files(
iter::once(normalize_path(profile_sample.as_path().to_path_buf())),
checksum_hash_algo,
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 @@ -656,6 +656,7 @@ fn test_codegen_options_tracking_hash() {
tracked!(passes, vec![String::from("1"), String::from("2")]);
tracked!(prefer_dynamic, true);
tracked!(profile_generate, SwitchWithOptPath::Enabled(None));
tracked!(profile_sample_use, Some(PathBuf::from("abc")));
tracked!(profile_use, Some(PathBuf::from("abc")));
tracked!(relocation_model, Some(RelocModel::Pic));
tracked!(relro_level, Some(RelroLevel::Full));
Expand Down Expand Up @@ -871,7 +872,6 @@ fn test_unstable_options_tracking_hash() {
tracked!(plt, Some(true));
tracked!(polonius, Polonius::Legacy);
tracked!(precise_enum_drop_elaboration, false);
tracked!(profile_sample_use, Some(PathBuf::from("abc")));
tracked!(profiler_runtime, "abc".to_string());
tracked!(reg_struct_return, true);
tracked!(regparm, Some(3));
Expand Down
12 changes: 3 additions & 9 deletions compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,10 @@ impl CStore {

fn report_target_modifiers_extended(
tcx: TyCtxt<'_>,
krate: &Crate,
mods: &TargetModifiers,
dep_mods: &TargetModifiers,
data: &CrateMetadata,
) {
let span = krate.spans.inner_span.shrink_to_lo();
let allowed_flag_mismatches = &tcx.sess.opts.cg.unsafe_allow_abi_mismatch;
let local_crate = tcx.crate_name(LOCAL_CRATE);
let tmod_extender = |tmod: &TargetModifier| (tmod.extend(), tmod.clone());
Expand All @@ -367,7 +365,6 @@ impl CStore {
match (flag_local_value, flag_extern_value) {
(Some(local_value), Some(extern_value)) => {
tcx.dcx().emit_err(diagnostics::IncompatibleTargetModifiers {
span,
extern_crate,
local_crate,
flag_name,
Expand All @@ -378,7 +375,6 @@ impl CStore {
}
(None, Some(extern_value)) => {
tcx.dcx().emit_err(diagnostics::IncompatibleTargetModifiersLMissed {
span,
extern_crate,
local_crate,
flag_name,
Expand All @@ -389,7 +385,6 @@ impl CStore {
}
(Some(local_value), None) => {
tcx.dcx().emit_err(diagnostics::IncompatibleTargetModifiersRMissed {
span,
extern_crate,
local_crate,
flag_name,
Expand Down Expand Up @@ -453,16 +448,15 @@ impl CStore {
}

pub fn report_session_incompatibilities(&self, tcx: TyCtxt<'_>, krate: &Crate) {
self.report_incompatible_target_modifiers(tcx, krate);
self.report_incompatible_target_modifiers(tcx);
self.report_incompatible_partial_mitigations(tcx, krate);
self.report_incompatible_async_drop_feature(tcx, krate);
}

pub fn report_incompatible_target_modifiers(&self, tcx: TyCtxt<'_>, krate: &Crate) {
pub fn report_incompatible_target_modifiers(&self, tcx: TyCtxt<'_>) {
for flag_name in &tcx.sess.opts.cg.unsafe_allow_abi_mismatch {
if !OptionsTargetModifiers::is_target_modifier(flag_name) {
tcx.dcx().emit_err(diagnostics::UnknownTargetModifierUnsafeAllowed {
span: krate.spans.inner_span.shrink_to_lo(),
flag_name: flag_name.clone(),
});
}
Expand All @@ -474,7 +468,7 @@ impl CStore {
}
let dep_mods = data.target_modifiers();
if mods != dep_mods {
Self::report_target_modifiers_extended(tcx, krate, &mods, &dep_mods, data);
Self::report_target_modifiers_extended(tcx, &mods, &dep_mods, data);
}
}
}
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_metadata/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,6 @@ pub(crate) struct WasmCAbi {
"if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch={$flag_name}` to silence this error"
)]
pub(crate) struct IncompatibleTargetModifiers {
#[primary_span]
pub span: Span,
pub extern_crate: Symbol,
pub local_crate: Symbol,
pub flag_name: String,
Expand Down Expand Up @@ -581,8 +579,6 @@ pub(crate) struct IncompatibleTargetModifiers {
"if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch={$flag_name}` to silence this error"
)]
pub(crate) struct IncompatibleTargetModifiersLMissed {
#[primary_span]
pub span: Span,
pub extern_crate: Symbol,
pub local_crate: Symbol,
pub flag_name: String,
Expand Down Expand Up @@ -612,8 +608,6 @@ pub(crate) struct IncompatibleTargetModifiersLMissed {
"if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch={$flag_name}` to silence this error"
)]
pub(crate) struct IncompatibleTargetModifiersRMissed {
#[primary_span]
pub span: Span,
pub extern_crate: Symbol,
pub local_crate: Symbol,
pub flag_name: String,
Expand All @@ -627,8 +621,6 @@ pub(crate) struct IncompatibleTargetModifiersRMissed {
"unknown target modifier `{$flag_name}`, requested by `-Cunsafe-allow-abi-mismatch={$flag_name}`"
)]
pub(crate) struct UnknownTargetModifierUnsafeAllowed {
#[primary_span]
pub span: Span,
pub flag_name: String,
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::atomic::{AtomicU32, Ordering};
use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::profiling::QueryInvocationId;
use rustc_data_structures::sharded::{self, ShardedHashMap};
use rustc_data_structures::sharded::ShardedHashMap;
use rustc_data_structures::stable_hash::{StableHash, StableHasher};
use rustc_data_structures::sync::{AtomicU64, Lock, WorkerLocal};
use rustc_data_structures::unord::UnordMap;
Expand Down Expand Up @@ -1231,7 +1231,7 @@ impl CurrentDepGraph {
encoder: GraphEncoder::new(session, encoder, prev_index_space_len, previous),
anon_node_to_index: ShardedHashMap::with_capacity(
// FIXME: The count estimate is off as anon nodes are only a portion of the nodes.
new_node_count_estimate / sharded::shards(),
new_node_count_estimate,
),
anon_id_seed,
#[cfg(debug_assertions)]
Expand Down
46 changes: 9 additions & 37 deletions compiler/rustc_mir_dataflow/src/framework/direction.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rustc_middle::bug;
use rustc_middle::mir::{self, BasicBlock, CallReturnPlaces, Location, TerminatorEdges};
use rustc_middle::mir::{self, BasicBlock, Location, TerminatorEdges};

use super::visitor::ResultsVisitor;
use super::{Analysis, Effect, EffectIndex, SwitchTargetIndex};
Expand Down Expand Up @@ -79,45 +79,17 @@ impl Direction for Backward {

let exit_state = state;
for pred in body.basic_blocks.predecessors()[block].iter().copied() {
match body[pred].terminator().kind {
match body[pred].terminator().edges() {
// Apply terminator-specific edge effects.
mir::TerminatorKind::Call { destination, target: Some(dest), .. }
if dest == block =>
TerminatorEdges::AssignOnReturn { return_, place, .. }
if return_.contains(&block) =>
{
let mut tmp = exit_state.clone();
analysis.apply_call_return_effect(
&mut tmp,
pred,
CallReturnPlaces::Call(destination),
);
propagate(pred, &tmp);
}

mir::TerminatorKind::InlineAsm { ref targets, ref operands, .. }
if targets.contains(&block) =>
{
let mut tmp = exit_state.clone();
analysis.apply_call_return_effect(
&mut tmp,
pred,
CallReturnPlaces::InlineAsm(operands),
);
propagate(pred, &tmp);
}

mir::TerminatorKind::Yield { resume, drop, resume_arg, .. }
if resume == block || drop == Some(block) =>
{
let mut tmp = exit_state.clone();
analysis.apply_call_return_effect(
&mut tmp,
block,
CallReturnPlaces::Yield(resume_arg),
);
analysis.apply_call_return_effect(&mut tmp, pred, place);
propagate(pred, &tmp);
}

mir::TerminatorKind::SwitchInt { ref targets, ref discr } => {
TerminatorEdges::SwitchInt { targets, discr } => {
if let Some(_data) = analysis.get_switch_int_data(pred, targets, discr) {
bug!(
"SwitchInt edge effects are unsupported in backward dataflow analyses"
Expand Down Expand Up @@ -220,12 +192,12 @@ impl Direction for Forward {
}
}
TerminatorEdges::SwitchInt { targets, discr } => {
if let Some(mut data) = analysis.get_switch_int_data(block, targets, discr) {
if let Some(data) = analysis.get_switch_int_data(block, targets, discr) {
let mut tmp = analysis.bottom_value(body);
for (i, (_value, target)) in targets.iter().enumerate() {
tmp.clone_from(exit_state);
let target_idx = SwitchTargetIndex::Normal(i);
analysis.apply_switch_int_edge_effect(&mut tmp, &mut data, target_idx);
analysis.apply_switch_int_edge_effect(&mut tmp, &data, target_idx);
propagate(target, &tmp);
}

Expand All @@ -234,7 +206,7 @@ impl Direction for Forward {
// a clone of the dataflow state.
analysis.apply_switch_int_edge_effect(
exit_state,
&mut data,
&data,
SwitchTargetIndex::Otherwise,
);
propagate(targets.otherwise(), exit_state);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_dataflow/src/framework/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,13 @@ where
})?;
}

mir::TerminatorKind::Yield { resume, resume_arg, .. } => {
mir::TerminatorKind::Yield { resume_arg, .. } => {
self.write_row(w, "", "(on yield resume)", |this, w, fmt| {
let state_on_coroutine_drop = this.cursor.get().clone();
this.cursor.apply_custom_effect(|analysis, state| {
analysis.apply_call_return_effect(
state,
resume,
block,
CallReturnPlaces::Yield(resume_arg),
);
});
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_dataflow/src/framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ pub trait Analysis<'tcx> {
fn apply_switch_int_edge_effect(
&self,
_state: &mut Self::Domain,
_data: &mut Self::SwitchIntData,
_data: &Self::SwitchIntData,
_target_idx: SwitchTargetIndex,
) {
unreachable!();
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_dataflow/src/impls/initialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
fn apply_switch_int_edge_effect(
&self,
state: &mut Self::Domain,
data: &mut Self::SwitchIntData,
data: &Self::SwitchIntData,
target_idx: SwitchTargetIndex,
) {
let inactive_variants = match target_idx {
Expand Down Expand Up @@ -588,7 +588,7 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
fn apply_switch_int_edge_effect(
&self,
state: &mut Self::Domain,
data: &mut Self::SwitchIntData,
data: &Self::SwitchIntData,
target_idx: SwitchTargetIndex,
) {
let inactive_variants = match target_idx {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2763,11 +2763,11 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
early_dcx.early_fatal("options `-C profile-generate` and `-C profile-use` are exclusive");
}

if unstable_opts.profile_sample_use.is_some()
if cg.profile_sample_use.is_some()
&& (cg.profile_generate.enabled() || cg.profile_use.is_some())
{
early_dcx.early_fatal(
"option `-Z profile-sample-use` cannot be used with `-C profile-generate` or `-C profile-use`",
"option `-C profile-sample-use` cannot be used with `-C profile-generate` or `-C profile-use`",
);
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2302,6 +2302,8 @@ options! {
profile_generate: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
parse_switch_with_opt_path, [TRACKED],
"compile the program with profiling instrumentation"),
profile_sample_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
"use the given `.prof` file for sample-based profile-guided optimization"),
profile_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
"use the given `.profdata` file for profile-guided optimization"),
#[rustc_lint_opt_deny_field_access("use `Session::relocation_model` instead of this field")]
Expand Down Expand Up @@ -2426,7 +2428,7 @@ options! {
debuginfo_compression: DebugInfoCompression = (DebugInfoCompression::None, parse_debuginfo_compression, [TRACKED],
"compress debug info sections (none, zlib, zstd, default: none)"),
debuginfo_for_profiling: bool = (false, parse_bool, [TRACKED],
"emit discriminators and other data necessary for AutoFDO"),
"emit extra debug info to make sample profile more accurate"),
deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],
"deduplicate identical diagnostics (default: yes)"),
default_visibility: Option<SymbolVisibility> = (None, parse_opt_symbol_visibility, [TRACKED],
Expand Down Expand Up @@ -2770,8 +2772,6 @@ options! {
"how to run proc-macro code (default: same-thread)"),
profile_closures: bool = (false, parse_no_value, [UNTRACKED],
"profile size of closures"),
profile_sample_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
"use the given `.prof` file for sampled profile-guided optimization (also known as AutoFDO)"),
profiler_runtime: String = (String::from("profiler_builtins"), parse_string, [TRACKED],
"name of the profiler runtime crate to automatically inject (default: `profiler_builtins`)"),
query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
}

// Do the same for sample profile data.
if let Some(ref path) = sess.opts.unstable_opts.profile_sample_use {
if let Some(ref path) = sess.opts.cg.profile_sample_use {
if !path.exists() {
sess.dcx().emit_err(diagnostics::ProfileSampleUseFileDoesNotExist { path });
}
Expand Down
Loading
Loading