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 #134430

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
50f6238
Fix const conditions for RPITITs
compiler-errors Dec 5, 2024
68ce659
Promote powerpc64le-unknown-linux-musl to tier 2 with host tools
Gelbpunkt Nov 18, 2024
3e3ee4c
Fix markdown link
Gelbpunkt Dec 3, 2024
8bb0fd5
Update src/doc/rustc/src/platform-support/powerpc64le-unknown-linux-m…
Gelbpunkt Dec 3, 2024
286de9f
Move dist-powerpc64le-linux to job-linux-4c-largedisk
Gelbpunkt Dec 9, 2024
2fd4438
clean up `emit_access_facts`
lqd Dec 11, 2024
9d8f58a
clean up `emit_drop_facts`
lqd Dec 11, 2024
afbe101
clean up `translate_outlives_facts`
lqd Dec 11, 2024
5486857
use let else more consistently in fact generation
lqd Dec 11, 2024
1740a5f
simplify `emit_access_facts` and fact generation
lqd Dec 11, 2024
2024c5d
simplify `emit_outlives_facts`
lqd Dec 11, 2024
7ad1f5b
refactor `type_check` module slightly
lqd Dec 11, 2024
8562497
improve consistency within fact gen
lqd Dec 11, 2024
ab6ad1a
Add a range argument to vec.extract_if
the8472 Nov 20, 2024
03f1b73
remove bounds from vec and linkedlist ExtractIf
the8472 Nov 20, 2024
fe52150
update uses of extract_if in the compiler
the8472 Nov 20, 2024
44790c4
remove obsolete comment and pub(super) visibility
the8472 Nov 20, 2024
fe412af
coverage: Use `is_eligible_for_coverage` to filter unused functions
Zalathar Dec 14, 2024
154fae1
coverage: Build the global file table on the fly
Zalathar Dec 13, 2024
252276a
coverage: Pull expression conversion out of `map_data.rs`
Zalathar Dec 12, 2024
527f812
coverage: Pull region conversion out of `map_data.rs`
Zalathar Dec 12, 2024
d34c365
coverage: Pull function source hash out of `map_data.rs`
Zalathar Dec 14, 2024
541d4e8
coverage: Track used functions in a set instead of a map
Zalathar Dec 14, 2024
a7f61ca
Regression test for RPIT inheriting lifetime
rmehri01 Dec 17, 2024
9c7593e
Pass FnAbi to find_mir_or_eval_fn
tiif Nov 16, 2024
13e8313
bootstrap: use specific-purpose ui test path
jieyouxu Dec 17, 2024
c482b31
Fix typo in uint_macros.rs
hkBst Dec 17, 2024
b9e001f
Rollup merge of #133103 - tiif:fnabi, r=RalfJung
jieyouxu Dec 17, 2024
ec4e1ca
Rollup merge of #133265 - the8472:extract-if-ranges, r=cuviper
jieyouxu Dec 17, 2024
05c8c5d
Rollup merge of #133801 - Gelbpunkt:powerpc64le-unknown-linux-musl-ti…
jieyouxu Dec 17, 2024
b0b6b62
Rollup merge of #133926 - compiler-errors:const-conditions, r=lcnr
jieyouxu Dec 17, 2024
8736e17
Rollup merge of #134323 - Zalathar:dismantle-map-data, r=jieyouxu
jieyouxu Dec 17, 2024
a2a432b
Rollup merge of #134378 - lqd:polonius-next-episode-2, r=jackh726
jieyouxu Dec 17, 2024
0fd8709
Rollup merge of #134408 - rmehri01:rpit-inherits-lifetime, r=compiler…
jieyouxu Dec 17, 2024
3a1e80b
Rollup merge of #134423 - jieyouxu:bootstrap-test-valid, r=onur-ozkan
jieyouxu Dec 17, 2024
b247178
Rollup merge of #134426 - hkBst:patch-3, r=lqd
jieyouxu Dec 17, 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
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/src/nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ pub(crate) fn compute_regions<'a, 'tcx>(
borrow_set,
move_data,
&universal_region_relations,
&constraints,
);

let mut regioncx = RegionInferenceContext::new(
Expand Down
85 changes: 85 additions & 0 deletions compiler/rustc_borrowck/src/polonius/legacy/accesses.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
use rustc_middle::mir::visit::{MutatingUseContext, PlaceContext, Visitor};
use rustc_middle::mir::{Body, Local, Location, Place};
use rustc_middle::ty::TyCtxt;
use rustc_mir_dataflow::move_paths::{LookupResult, MoveData};
use tracing::debug;

use crate::def_use::{self, DefUse};
use crate::facts::AllFacts;
use crate::location::{LocationIndex, LocationTable};
use crate::universal_regions::UniversalRegions;

/// Emit polonius facts for variable defs, uses, drops, and path accesses.
pub(crate) fn emit_access_facts<'tcx>(
tcx: TyCtxt<'tcx>,
facts: &mut AllFacts,
body: &Body<'tcx>,
location_table: &LocationTable,
move_data: &MoveData<'tcx>,
universal_regions: &UniversalRegions<'tcx>,
) {
let mut extractor = AccessFactsExtractor { facts, move_data, location_table };
extractor.visit_body(body);

for (local, local_decl) in body.local_decls.iter_enumerated() {
debug!("add use_of_var_derefs_origin facts - local={:?}, type={:?}", local, local_decl.ty);
tcx.for_each_free_region(&local_decl.ty, |region| {
let region_vid = universal_regions.to_region_vid(region);
facts.use_of_var_derefs_origin.push((local, region_vid.into()));
});
}
}

/// MIR visitor extracting point-wise facts about accesses.
struct AccessFactsExtractor<'a, 'tcx> {
facts: &'a mut AllFacts,
move_data: &'a MoveData<'tcx>,
location_table: &'a LocationTable,
}

impl<'tcx> AccessFactsExtractor<'_, 'tcx> {
fn location_to_index(&self, location: Location) -> LocationIndex {
self.location_table.mid_index(location)
}
}

impl<'a, 'tcx> Visitor<'tcx> for AccessFactsExtractor<'a, 'tcx> {
fn visit_local(&mut self, local: Local, context: PlaceContext, location: Location) {
match def_use::categorize(context) {
Some(DefUse::Def) => {
debug!("AccessFactsExtractor - emit def");
self.facts.var_defined_at.push((local, self.location_to_index(location)));
}
Some(DefUse::Use) => {
debug!("AccessFactsExtractor - emit use");
self.facts.var_used_at.push((local, self.location_to_index(location)));
}
Some(DefUse::Drop) => {
debug!("AccessFactsExtractor - emit drop");
self.facts.var_dropped_at.push((local, self.location_to_index(location)));
}
_ => (),
}
}

fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) {
self.super_place(place, context, location);

match context {
PlaceContext::NonMutatingUse(_)
| PlaceContext::MutatingUse(MutatingUseContext::Borrow) => {
let path = match self.move_data.rev_lookup.find(place.as_ref()) {
LookupResult::Exact(path) | LookupResult::Parent(Some(path)) => path,
_ => {
// There's no path access to emit.
return;
}
};
debug!("AccessFactsExtractor - emit path access ({path:?}, {location:?})");
self.facts.path_accessed_at_base.push((path, self.location_to_index(location)));
}

_ => {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ use crate::{
/// Emit `loan_invalidated_at` facts.
pub(super) fn emit_loan_invalidations<'tcx>(
tcx: TyCtxt<'tcx>,
all_facts: &mut AllFacts,
location_table: &LocationTable,
facts: &mut AllFacts,
body: &Body<'tcx>,
location_table: &LocationTable,
borrow_set: &BorrowSet<'tcx>,
) {
let dominators = body.basic_blocks.dominators();
let mut visitor =
LoanInvalidationsGenerator { all_facts, borrow_set, tcx, location_table, body, dominators };
LoanInvalidationsGenerator { facts, borrow_set, tcx, location_table, body, dominators };
visitor.visit_body(body);
}

struct LoanInvalidationsGenerator<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
all_facts: &'a mut AllFacts,
location_table: &'a LocationTable,
facts: &'a mut AllFacts,
body: &'a Body<'tcx>,
location_table: &'a LocationTable,
dominators: &'a Dominators<BasicBlock>,
borrow_set: &'a BorrowSet<'tcx>,
}
Expand Down Expand Up @@ -151,7 +151,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LoanInvalidationsGenerator<'a, 'tcx> {
let resume = self.location_table.start_index(resume.start_location());
for (i, data) in borrow_set.iter_enumerated() {
if borrow_of_local_data(data.borrowed_place) {
self.all_facts.loan_invalidated_at.push((resume, i));
self.facts.loan_invalidated_at.push((resume, i));
}
}

Expand All @@ -165,7 +165,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LoanInvalidationsGenerator<'a, 'tcx> {
let start = self.location_table.start_index(location);
for (i, data) in borrow_set.iter_enumerated() {
if borrow_of_local_data(data.borrowed_place) {
self.all_facts.loan_invalidated_at.push((start, i));
self.facts.loan_invalidated_at.push((start, i));
}
}
}
Expand Down Expand Up @@ -409,7 +409,7 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
/// Generates a new `loan_invalidated_at(L, B)` fact.
fn emit_loan_invalidated_at(&mut self, b: BorrowIndex, l: Location) {
let lidx = self.location_table.start_index(l);
self.all_facts.loan_invalidated_at.push((lidx, b));
self.facts.loan_invalidated_at.push((lidx, b));
}

fn check_activations(&mut self, location: Location) {
Expand Down
24 changes: 12 additions & 12 deletions compiler/rustc_borrowck/src/polonius/legacy/loan_kills.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ use crate::places_conflict;
/// Emit `loan_killed_at` and `cfg_edge` facts at the same time.
pub(super) fn emit_loan_kills<'tcx>(
tcx: TyCtxt<'tcx>,
all_facts: &mut AllFacts,
location_table: &LocationTable,
facts: &mut AllFacts,
body: &Body<'tcx>,
location_table: &LocationTable,
borrow_set: &BorrowSet<'tcx>,
) {
let mut visitor = LoanKillsGenerator { borrow_set, tcx, location_table, all_facts, body };
let mut visitor = LoanKillsGenerator { borrow_set, tcx, location_table, facts, body };
for (bb, data) in body.basic_blocks.iter_enumerated() {
visitor.visit_basic_block_data(bb, data);
}
}

struct LoanKillsGenerator<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
all_facts: &'a mut AllFacts,
facts: &'a mut AllFacts,
location_table: &'a LocationTable,
borrow_set: &'a BorrowSet<'tcx>,
body: &'a Body<'tcx>,
Expand All @@ -36,12 +36,12 @@ struct LoanKillsGenerator<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for LoanKillsGenerator<'a, 'tcx> {
fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
// Also record CFG facts here.
self.all_facts.cfg_edge.push((
self.facts.cfg_edge.push((
self.location_table.start_index(location),
self.location_table.mid_index(location),
));

self.all_facts.cfg_edge.push((
self.facts.cfg_edge.push((
self.location_table.mid_index(location),
self.location_table.start_index(location.successor_within_block()),
));
Expand All @@ -63,15 +63,15 @@ impl<'a, 'tcx> Visitor<'tcx> for LoanKillsGenerator<'a, 'tcx> {

fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
// Also record CFG facts here.
self.all_facts.cfg_edge.push((
self.facts.cfg_edge.push((
self.location_table.start_index(location),
self.location_table.mid_index(location),
));

let successor_blocks = terminator.successors();
self.all_facts.cfg_edge.reserve(successor_blocks.size_hint().0);
self.facts.cfg_edge.reserve(successor_blocks.size_hint().0);
for successor_block in successor_blocks {
self.all_facts.cfg_edge.push((
self.facts.cfg_edge.push((
self.location_table.mid_index(location),
self.location_table.start_index(successor_block.start_location()),
));
Expand Down Expand Up @@ -128,7 +128,7 @@ impl<'tcx> LoanKillsGenerator<'_, 'tcx> {

if places_conflict {
let location_index = self.location_table.mid_index(location);
self.all_facts.loan_killed_at.push((borrow_index, location_index));
self.facts.loan_killed_at.push((borrow_index, location_index));
}
}
}
Expand All @@ -140,9 +140,9 @@ impl<'tcx> LoanKillsGenerator<'_, 'tcx> {
fn record_killed_borrows_for_local(&mut self, local: Local, location: Location) {
if let Some(borrow_indices) = self.borrow_set.local_map.get(&local) {
let location_index = self.location_table.mid_index(location);
self.all_facts.loan_killed_at.reserve(borrow_indices.len());
self.facts.loan_killed_at.reserve(borrow_indices.len());
for &borrow_index in borrow_indices {
self.all_facts.loan_killed_at.push((borrow_index, location_index));
self.facts.loan_killed_at.push((borrow_index, location_index));
}
}
}
Expand Down
Loading
Loading