Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #120190

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7e64f29
Update Readme
atouchet Jan 15, 2024
aa72e54
Un-hide `iter::repeat_n`
scottmcm Jan 17, 2024
06a9dbe
Fix a soundness bug in `with_tables`.
oli-obk Jan 19, 2024
61361c1
Fix `Stable` trait and its impls to work with the new `with_tables`
oli-obk Jan 19, 2024
9aace67
Ensure internal function is safe
celinval Jan 18, 2024
6cd6539
Use the new `with_tables` everywhere
oli-obk Jan 19, 2024
5796b3c
fix: Drop guard was deallocating with the incorrect size
the8472 Jan 19, 2024
270f151
rustc_mir_dataflow: Add exports for external tools
jubnzv Jan 20, 2024
f6b3bcc
Capture the rationale for -Zallow-features= in bootstrap.py
dtolnay Jan 20, 2024
8d2a617
Add Assume custom MIR.
cjgillot Jan 20, 2024
6ab44fb
Add test for jump-threading assume.
cjgillot Jan 20, 2024
a0a7173
Do not thread through Assert terminator.
cjgillot Jan 20, 2024
7842043
Add a warning comment
jubnzv Jan 20, 2024
cc8e56b
Warn users about limited review for tier 2 and 3 code
Mark-Simulacrum Jan 20, 2024
6f1944d
Document some alternatives to `Vec::split_off`
Zalathar Jan 21, 2024
695df12
Rollup merge of #120005 - atouchet:rd3, r=Mark-Simulacrum
matthiaskrgr Jan 21, 2024
9652b15
Rollup merge of #120045 - scottmcm:unhide-repeat-n, r=Mark-Simulacrum
matthiaskrgr Jan 21, 2024
3f10dc7
Rollup merge of #120128 - oli-obk:smir_internal_lift, r=celinval
matthiaskrgr Jan 21, 2024
4b02c24
Rollup merge of #120145 - the8472:fix-inplace-dest-drop, r=cuviper
matthiaskrgr Jan 21, 2024
d3172f2
Rollup merge of #120158 - jubnzv:120130-mirdf-exports, r=nnethercote
matthiaskrgr Jan 21, 2024
866296b
Rollup merge of #120167 - dtolnay:bootstrap, r=clubby789
matthiaskrgr Jan 21, 2024
eac55e7
Rollup merge of #120171 - cjgillot:jump-threading-assume-assert, r=tm…
matthiaskrgr Jan 21, 2024
bbbadb1
Rollup merge of #120174 - Mark-Simulacrum:link-libs-policy, r=dtolnay
matthiaskrgr Jan 21, 2024
1d678a5
Rollup merge of #120180 - Zalathar:vec-split-off-alternatives, r=dtolnay
matthiaskrgr Jan 21, 2024
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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ If you wish to _contribute_ to the compiler, you should read
<summary>Table of Contents</summary>

- [Quick Start](#quick-start)
- [Installing from Source](#installing-from-source)
- [Getting Help](#getting-help)
- [Contributing](#contributing)
- [License](#license)
Expand All @@ -29,9 +30,10 @@ Read ["Installation"] from [The Book].
["Installation"]: https://doc.rust-lang.org/book/ch01-01-installation.html
[The Book]: https://doc.rust-lang.org/book/index.html

## Installing from source
## Installing from Source

If you really want to install from source (though this is not recommended), see [INSTALL.md](INSTALL.md).
If you really want to install from source (though this is not recommended), see
[INSTALL.md](INSTALL.md).

## Getting Help

Expand Down
13 changes: 13 additions & 0 deletions compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,19 @@ impl DroplessArena {
}
}

/// Used by `Lift` to check whether this slice is allocated
/// in this arena.
#[inline]
pub fn contains_slice<T>(&self, slice: &[T]) -> bool {
for chunk in self.chunks.borrow_mut().iter_mut() {
let ptr = slice.as_ptr().cast::<u8>().cast_mut();
if chunk.start() <= ptr && chunk.end() >= ptr {
return true;
}
}
false
}

/// Allocates a string slice that is copied into the `DroplessArena`, returning a
/// reference to it. Will panic if passed an empty string.
///
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<'tcx> ConstValue<'tcx> {
/// Constants

#[derive(Clone, Copy, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable, Debug)]
#[derive(TypeFoldable, TypeVisitable)]
#[derive(TypeFoldable, TypeVisitable, Lift)]
pub enum Const<'tcx> {
/// This constant came from the type system.
///
Expand Down Expand Up @@ -456,7 +456,7 @@ impl<'tcx> Const<'tcx> {

/// An unevaluated (potentially generic) constant used in MIR.
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, TyEncodable, TyDecodable)]
#[derive(Hash, HashStable, TypeFoldable, TypeVisitable)]
#[derive(Hash, HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct UnevaluatedConst<'tcx> {
pub def: DefId,
pub args: GenericArgsRef<'tcx>,
Expand Down
23 changes: 22 additions & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,7 @@ nop_lift! {const_; Const<'a> => Const<'tcx>}
nop_lift! {const_allocation; ConstAllocation<'a> => ConstAllocation<'tcx>}
nop_lift! {predicate; Predicate<'a> => Predicate<'tcx>}
nop_lift! {predicate; Clause<'a> => Clause<'tcx>}
nop_lift! {layout; Layout<'a> => Layout<'tcx>}

nop_list_lift! {type_lists; Ty<'a> => Ty<'tcx>}
nop_list_lift! {poly_existential_predicates; PolyExistentialPredicate<'a> => PolyExistentialPredicate<'tcx>}
Expand All @@ -1424,8 +1425,28 @@ nop_list_lift! {bound_variable_kinds; ty::BoundVariableKind => ty::BoundVariable
// This is the impl for `&'a GenericArgs<'a>`.
nop_list_lift! {args; GenericArg<'a> => GenericArg<'tcx>}

macro_rules! nop_slice_lift {
($ty:ty => $lifted:ty) => {
impl<'a, 'tcx> Lift<'tcx> for &'a [$ty] {
type Lifted = &'tcx [$lifted];
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
if self.is_empty() {
return Some(&[]);
}
tcx.interners
.arena
.dropless
.contains_slice(self)
.then(|| unsafe { mem::transmute(self) })
}
}
};
}

nop_slice_lift! {ty::ValTree<'a> => ty::ValTree<'tcx>}

TrivialLiftImpls! {
ImplPolarity,
ImplPolarity, Promoted
}

macro_rules! sty_debug_print {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
@call(mir_storage_dead, args) => {
Ok(StatementKind::StorageDead(self.parse_local(args[0])?))
},
@call(mir_assume, args) => {
let op = self.parse_operand(args[0])?;
Ok(StatementKind::Intrinsic(Box::new(NonDivergingIntrinsic::Assume(op))))
},
@call(mir_deinit, args) => {
Ok(StatementKind::Deinit(Box::new(self.parse_place(args[0])?)))
},
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_mir_dataflow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ extern crate rustc_middle;

use rustc_middle::ty;

// Please change the public `use` directives cautiously, as they might be used by external tools.
// See issue #120130.
pub use self::drop_flag_effects::{
drop_flag_effects_for_function_entry, drop_flag_effects_for_location,
move_path_children_matching, on_all_children_bits, on_lookup_result_bits,
};
pub use self::framework::{
fmt, lattice, visit_results, Analysis, AnalysisDomain, Direction, GenKill, GenKillAnalysis,
JoinSemiLattice, MaybeReachable, Results, ResultsCursor, ResultsVisitable, ResultsVisitor,
fmt, graphviz, lattice, visit_results, Analysis, AnalysisDomain, Backward, Direction, Engine,
Forward, GenKill, GenKillAnalysis, JoinSemiLattice, MaybeReachable, Results, ResultsCursor,
ResultsVisitable, ResultsVisitor, SwitchIntEdgeEffects,
};
use self::framework::{Backward, SwitchIntEdgeEffects};
use self::move_paths::MoveData;

pub mod debuginfo;
Expand Down
17 changes: 2 additions & 15 deletions compiler/rustc_mir_transform/src/jump_threading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,6 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
cost: &CostChecker<'_, 'tcx>,
depth: usize,
) {
let register_opportunity = |c: Condition| {
debug!(?bb, ?c.target, "register");
self.opportunities.push(ThreadingOpportunity { chain: vec![bb], target: c.target })
};

let term = self.body.basic_blocks[bb].terminator();
let place_to_flood = match term.kind {
// We come from a target, so those are not possible.
Expand All @@ -544,16 +539,8 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
// Flood the overwritten place, and progress through.
TerminatorKind::Drop { place: destination, .. }
| TerminatorKind::Call { destination, .. } => Some(destination),
// Treat as an `assume(cond == expected)`.
TerminatorKind::Assert { ref cond, expected, .. } => {
if let Some(place) = cond.place()
&& let Some(conditions) = state.try_get(place.as_ref(), self.map)
{
let expected = if expected { ScalarInt::TRUE } else { ScalarInt::FALSE };
conditions.iter_matches(expected).for_each(register_opportunity);
}
None
}
// Ignore, as this can be a no-op at codegen time.
TerminatorKind::Assert { .. } => None,
};

// We can recurse through this terminator.
Expand Down
Loading
Loading