Skip to content
Merged
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
16 changes: 16 additions & 0 deletions compiler/rustc_index/src/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ impl<R: Idx, C: Step + Idx> SparseIntervalMatrix<R, C> {
self.rows.iter_enumerated()
}

pub fn clear_row(&mut self, row: R) {
if let Some(row) = self.rows.get_mut(row) {
row.clear();
}
}

fn ensure_row(&mut self, row: R) -> &mut IntervalSet<C> {
self.rows.ensure_contains_elem(row, || IntervalSet::new(self.column_size))
}
Expand All @@ -397,6 +403,16 @@ impl<R: Idx, C: Step + Idx> SparseIntervalMatrix<R, C> {
write_row.union(read_row)
}

pub fn disjoint_rows(&self, a: R, b: R) -> bool
where
C: Step,
{
let (Some(a), Some(b)) = (self.rows.get(a), self.rows.get(b)) else {
return true;
};
a.disjoint(b)
}

pub fn insert_all_into_row(&mut self, row: R) {
self.ensure_row(row).insert_all();
}
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ pub enum RuntimePhase {
/// disallowed:
/// * [`TerminatorKind::Yield`]
/// * [`TerminatorKind::CoroutineDrop`]
/// * [`Rvalue::Aggregate`] for any `AggregateKind` except `Array`
/// * [`Rvalue::CopyForDeref`]
/// * [`PlaceElem::OpaqueCast`]
/// * [`LocalInfo::DerefTemp`](super::LocalInfo::DerefTemp)
Expand Down Expand Up @@ -1449,9 +1448,6 @@ pub enum Rvalue<'tcx> {
/// This is needed because dataflow analysis needs to distinguish
/// `dest = Foo { x: ..., y: ... }` from `dest.x = ...; dest.y = ...;` in the case that `Foo`
/// has a destructor.
///
/// Disallowed after deaggregation for all aggregate kinds except `Array` and `Coroutine`. After
/// coroutine lowering, `Coroutine` aggregate kinds are disallowed too.
Aggregate(Box<AggregateKind<'tcx>>, IndexVec<FieldIdx, Operand<'tcx>>),

/// A CopyForDeref is equivalent to a read from a place at the
Expand Down
13 changes: 13 additions & 0 deletions compiler/rustc_middle/src/ty/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,19 @@ impl<'tcx> AdtDef<'tcx> {
self.0.0.repr
}

/// Whether MIR may project into the fields of this ADT.
///
/// MCP#838 bans field projections into SIMD types, including scalable
/// vectors.
///
/// Codegen requires `DynMetadata` to be manipulated as a whole, with its
/// insides being treated as opaque..
pub fn can_project_fields(self, tcx: TyCtxt<'tcx>) -> bool {
!self.repr().simd()
&& !self.repr().scalable()
&& !tcx.is_lang_item(self.did(), LangItem::DynMetadata)
}

pub fn field_representing_type_info(
self,
tcx: TyCtxt<'tcx>,
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_mir_transform/src/dest_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ pub(super) struct DestinationPropagation;

impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation {
fn policy(&self, ctx: &crate::PassCtx<'_>) -> PassPolicy {
PassPolicy::optional(ctx.mir_opt_level() >= 2)
PassPolicy::optional(
ctx.mir_opt_level() >= 2 && !ctx.opts.unstable_opts.mir_move_elimination,
)
}

#[tracing::instrument(level = "trace", skip(self, tcx, body))]
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ declare_passes! {
mod lower_slice_len : LowerSliceLenCalls;
mod match_branches : MatchBranchSimplification;
mod mentioned_items : MentionedItems;
mod move_elimination : MoveElimination;
mod multiple_return_terminators : MultipleReturnTerminators;
mod post_drop_elaboration : CheckLiveDrops;
mod prettify : ReorderBasicBlocks, ReorderLocals;
Expand Down Expand Up @@ -770,6 +771,7 @@ pub(crate) fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'
&dead_store_elimination::DeadStoreElimination::Final,
&dest_prop::DestinationPropagation,
&tail_copy_to_move::TailCopyToMove,
&move_elimination::MoveElimination,
&simplify::SimplifyLocals::Final,
&multiple_return_terminators::MultipleReturnTerminators,
// Some cleanup necessary at least for LLVM and potentially other codegen backends.
Expand Down
Loading
Loading