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
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_ssa/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
let llfn = cx.get_fn(instance);

let mut mir = tcx.instance_mir(instance.def);
// Note that the ABI logic has deduced facts about the functions' parameters based on the MIR we
// got here (`deduce_param_attrs`). That means we can *not* apply arbitrary further MIR
// transforms as that may invalidate those deduced facts!

let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty());
debug!("fn_abi: {:?}", fn_abi);
Expand Down Expand Up @@ -317,6 +320,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
}
}

/// Replace `clone` calls that come from `use` statements with direct copies if possible.
// FIXME: Move this function to mir::transform when post-mono MIR passes land.
fn optimize_use_clone<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
cx: &'a Bx::CodegenCx,
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_middle/src/middle/deduced_param_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_macros::{Decodable, Encodable, HashStable};
use crate::ty::{Ty, TyCtxt, TypingEnv};

/// Flags that dictate how a parameter is mutated. If the flags are empty, the param is
/// read-only. If non-empty, it is read-only with conditions.
/// read-only. If non-empty, it is read-only if *all* flags' conditions are met.
#[derive(Clone, Copy, PartialEq, Debug, Decodable, Encodable, HashStable)]
pub struct DeducedReadOnlyParam(u8);

Expand Down Expand Up @@ -53,6 +53,7 @@ impl DeducedParamAttrs {
ty: Ty<'tcx>,
) -> bool {
let read_only = self.read_only;
// We have to check *all* set bits; only if all checks pass is this truly read-only.
if read_only.contains(DeducedReadOnlyParam::MUTATED) {
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ pub enum RuntimePhase {
/// And the following variants are allowed:
/// * [`StatementKind::Retag`]
/// * [`StatementKind::SetDiscriminant`]
/// * [`PlaceElem::ConstantIndex`] / [`PlaceElem::Subslice`] after [`PlaceElem::Subslice`]
///
/// Furthermore, `Copy` operands are allowed for non-`Copy` types.
Initial = 0,
Expand Down Expand Up @@ -1246,6 +1247,9 @@ pub enum ProjectionElem<V, T> {
///
/// If `from_end` is true `slice[from..slice.len() - to]`.
/// Otherwise `array[from..to]`.
///
/// This projection cannot have `ConstantIndex` or additional `Subslice` projections after it
/// before runtime MIR.
Subslice {
from: u64,
to: u64,
Expand Down
Loading
Loading