8000 Rollup of 6 pull requests by Dylan-DPC-zz · Pull Request #71467 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 6 pull requests #71467

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

Merged
merged 27 commits into from
Apr 23, 2020
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4eaf535
Treat RETURN_PLACE as a normal Local
jonas-schievink Apr 15, 2020
a417f96
Remove null places
jonas-schievink Apr 15, 2020
34ed891
Fix pop_stack_frame logic
jonas-schievink Apr 15, 2020
0fda0fd
Dump return_place upon returning
jonas-schievink Apr 15, 2020
c5bfbb6
Update const prop
jonas-schievink Apr 16, 2020
a5c1851
Fix codegen and mir-opt tests
jonas-schievink Apr 16, 2020
f0ab469
Remove unnecessary block
jonas-schievink Apr 16, 2020
1ce6e6a
Bless 32-bit test output
jonas-schievink Apr 16, 2020
9e6f38a
Use copy_op_transmute
jonas-schievink Apr 17, 2020
415fd0c
const prop: don't special case return place
jonas-schievink Apr 19, 2020
57c2712
Improve E0308 error message wording again
DeeDeeG Apr 21, 2020
e97c227
Remove outdated reference to interpreter snapshotting
ecstatic-morse Apr 22, 2020
b3c26de
Inline some function docs re-exported in `std::ptr`
ecstatic-morse Apr 23, 2020
a135ced
Fix ui test blessing when a test has an empty stderr file after havin…
oli-obk Mar 16, 2020
6a3fb26
Rename `Item` to `ConstCx`.
oli-obk Mar 23, 2020
f0f7a59
Use ConstCx in more places
oli-obk Apr 2, 2020
0bc743e
Use ConstCx in the promoted collector
oli-obk Apr 2, 2020
cffd4b6
Improve E0567 explanation
GuillaumeGomez Apr 23, 2020
22a5379
Use `ConstCx` for `validate_candidates`
oli-obk Apr 2, 2020
119c636
Catch and fix explicit promotions that fail to actually promote
oli-obk Apr 6, 2020
4cdc31b
Document our sanity assertion around explicit promotion
oli-obk Apr 16, 2020
61fbc6a
Rollup merge of #71005 - jonas-schievink:no-place-like-return, r=oli-obk
Dylan-DPC Apr 23, 2020
629a613
Rollup merge of #71198 - oli-obk:const_check_cleanup, r=RalfJung
Dylan-DPC Apr 23, 2020
4ae7037
Rollup merge of #71396 - DeeDeeG:improve-e0308-again, r=estebank
Dylan-DPC Apr 23, 2020
414355b
Rollup merge of #71452 - ecstatic-morse:no-more-snapshot, r=RalfJung
Dylan-DPC Apr 23, 2020
98cadb2
Rollup merge of #71454 - ecstatic-morse:inline-core-ptr-docs, r=RalfJung
Dylan-DPC Apr 23, 2020
47e2687
Rollup merge of #71461 - GuillaumeGomez:improve-e0567, r=Dylan-DPC
Dylan-DPC Apr 23, 2020
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
Prev Previous commit
Next Next commit
Use ConstCx in the promoted collector
  • Loading branch information
oli-obk committed Apr 23, 2020
commit 0bc743ed12e7ca72eca59ef2a6eadcfabf385b4a
30 changes: 14 additions & 16 deletions src/librustc_mir/transform/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ impl<'tcx> MirPass<'tcx> for PromoteTemps<'tcx> {
let def_id = src.def_id();

let mut rpo = traversal::reverse_postorder(body);
let (temps, all_candidates) = collect_temps_and_candidates(tcx, body, &mut rpo);
let ccx = ConstCx::new(tcx, def_id, body);
let (temps, all_candidates) = collect_temps_and_candidates(&ccx, &mut rpo);

let promotable_candidates = validate_candidates(tcx, body, def_id, &temps, &all_candidates);

Expand Down Expand Up @@ -139,8 +140,7 @@ fn args_required_const(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Vec<usize>> {
}

struct Collector<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
body: &'a Body<'tcx>,
ccx: &'a ConstCx<'a, 'tcx>,
temps: IndexVec<Local, TempState>,
candidates: Vec<Candidate>,
span: Span,
Expand All @@ -150,7 +150,7 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
fn visit_local(&mut self, &index: &Local, context: PlaceContext, location: Location) {
debug!("visit_local: index={:?} context={:?} location={:?}", index, context, location);
// We're only interested in temporaries and the return place
match self.body.local_kind(index) {
match self.ccx.body.local_kind(index) {
LocalKind::Temp | LocalKind::ReturnPointer => {}
LocalKind::Arg | LocalKind::Var => return,
}
Expand Down Expand Up @@ -203,7 +203,7 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
Rvalue::Ref(..) => {
self.candidates.push(Candidate::Ref(location));
}
Rvalue::Repeat(..) if self.tcx.features().const_in_array_repeat_expressions => {
Rvalue::Repeat(..) if self.ccx.tcx.features().const_in_array_repeat_expressions => {
// FIXME(#49147) only promote the element when it isn't `Copy`
// (so that code that can copy it at runtime is unaffected).
self.candidates.push(Candidate::Repeat(location));
Expand All @@ -216,10 +216,10 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
self.super_terminator_kind(kind, location);

if let TerminatorKind::Call { ref func, .. } = *kind {
if let ty::FnDef(def_id, _) = func.ty(self.body, self.tcx).kind {
let fn_sig = self.tcx.fn_sig(def_id);
if let ty::FnDef(def_id, _) = func.ty(self.ccx.body, self.ccx.tcx).kind {
let fn_sig = self.ccx.tcx.fn_sig(def_id);
if let Abi::RustIntrinsic | Abi::PlatformIntrinsic = fn_sig.abi() {
let name = self.tcx.item_name(def_id);
let name = self.ccx.tcx.item_name(def_id);
// FIXME(eddyb) use `#[rustc_args_required_const(2)]` for shuffles.
if name.as_str().starts_with("simd_shuffle") {
self.candidates.push(Candidate::Argument { bb: location.block, index: 2 });
Expand All @@ -228,7 +228,7 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
}
}

if let Some(constant_args) = args_required_const(self.tcx, def_id) {
if let Some(constant_args) = args_required_const(self.ccx.tcx, def_id) {
for index in constant_args {
self.candidates.push(Candidate::Argument { bb: location.block, index });
}
Expand All @@ -243,16 +243,14 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
}

pub fn collect_temps_and_candidates(
tcx: TyCtxt<'tcx>,
body: &Body<'tcx>,
ccx: &ConstCx<'mir, 'tcx>,
rpo: &mut ReversePostorder<'_, 'tcx>,
) -> (IndexVec<Local, TempState>, Vec<Candidate>) {
let mut collector = Collector {
tcx,
body,
temps: IndexVec::from_elem(TempState::Undefined, &body.local_decls),
temps: IndexVec::from_elem(TempState::Undefined, &ccx.body.local_decls),
candidates: vec![],
span: body.span,
span: ccx.body.span,
ccx,
};
for (bb, data) in rpo {
collector.visit_basic_block_data(bb, data);
Expand Down Expand Up @@ -1151,7 +1149,7 @@ crate fn should_suggest_const_in_array_repeat_expressions_attribute<'tcx>(
operand: &Operand<'tcx>,
) -> bool {
let mut rpo = traversal::reverse_postorder(&ccx.body);
let (temps, _) = collect_temps_and_candidates(ccx.tcx, &ccx.body, &mut rpo);
let (temps, _) = collect_temps_and_candidates(&ccx, &mut rpo);
let validator = Validator { ccx, temps: &temps, explicit: false };

let should_promote = validator.validate_operand(operand).is_ok();
Expand Down
0