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

Automated pull from upstream master #78

Merged
merged 58 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
58 commits
Select commit Hold shift click to select a range
51e22be
feat: render Object Safety informations non-object safe traits
poliorcetics Jul 1, 2023
40556b9
feat: Add 'object-safety' ID to init_id_map() in rustdoc
poliorcetics Jul 8, 2023
a119158
tests: object-safety section in traits
poliorcetics Jul 1, 2023
50ca5ef
When encountering unclosed delimiters during parsing, check for diff …
estebank Oct 13, 2023
1e5b2da
Rename Since -> StableSince in preparation for a DeprecatedSince
dtolnay Oct 26, 2023
5c7cf83
Fill in syntactically valid deprecation version in tests
dtolnay Oct 30, 2023
2fe7d17
Store version of `deprecated` attribute in structured form
dtolnay Oct 26, 2023
8afb40b
Delete unused InvalidDeprecationVersion diagnostic
dtolnay Oct 30, 2023
1e10fe9
Move deprecation_in_effect to inherent method on Deprecation
dtolnay Oct 30, 2023
af7472e
Add a stable MIR visitor
celinval Oct 30, 2023
48491c1
Also consider TAIT to be uncomputable if the MIR body is tainted
compiler-errors Oct 30, 2023
b106167
Add a DeprecatedSince::Err variant for versions that fail to parse
dtolnay Oct 30, 2023
c523672
Preserve deprecation attribute even if 'since' version is missing
dtolnay Oct 30, 2023
e8868af
Represent absence of 'since' attribute as a variant of DeprecatedSince
dtolnay Oct 30, 2023
add09e6
Some more coroutine renamings
compiler-errors Oct 30, 2023
dccf10e
Descriptive variant name deprecation versions outside the standard li…
dtolnay Oct 30, 2023
8b8906b
Add method for checking if deprecation is a rustc version
dtolnay Oct 30, 2023
ffb7ed9
Auto merge of #117419 - compiler-errors:gen, r=oli-obk
bors Oct 31, 2023
22b2712
Auto merge of #117377 - dtolnay:deprecatedsince, r=cjgillot
bors Oct 31, 2023
5b7cc9d
Do not ICE on constant evaluation failure in GVN.
cjgillot Oct 31, 2023
078144e
prepopulate opaque ty storage before using it :>
lcnr Oct 31, 2023
8ef67d0
coverage: Promote some debug-only checks to always run
Zalathar Oct 29, 2023
6d956a2
coverage: Replace impossible `coverage::Error` with assertions
Zalathar Oct 29, 2023
7c673db
don't use the moral equivalent of `assert!(false, "foo")`
oli-obk Sep 29, 2023
9a49ef3
Simplify all `require_simd` invocations by moving all of the shared i…
oli-obk Sep 29, 2023
f8372df
Merge simd size and type extraction into checking whether a type is s…
oli-obk Sep 29, 2023
ed27cb0
Reorder passes.
cjgillot Jul 22, 2023
c748ac1
Replace SwitchInt to unreachable by an assumption.
cjgillot Jul 22, 2023
0b13e63
Simplify assume of a constant.
cjgillot Jul 22, 2023
096196d
Refactor UninhabitedEnumBranching to mark targets unreachable.
cjgillot Jul 22, 2023
cb91890
Only emit `!=` assumptions if the otherwise target is reachable.
cjgillot Sep 24, 2023
ae2e211
FileCheck uninhabited_enum_branching.
cjgillot Oct 21, 2023
d0833c4
Rollup merge of #116267 - oli-obk:simd_cleanups, r=petrochenkov
matthiaskrgr Oct 31, 2023
7035c3d
Rollup merge of #116712 - estebank:issue-116252, r=petrochenkov
matthiaskrgr Oct 31, 2023
8daa317
Rollup merge of #117416 - compiler-errors:tait-in-bad-body, r=oli-obk
matthiaskrgr Oct 31, 2023
793776f
Rollup merge of #117421 - Zalathar:error, r=oli-obk,Swatinem
matthiaskrgr Oct 31, 2023
f623530
Rollup merge of #117438 - cjgillot:deterministic-error, r=oli-obk
matthiaskrgr Oct 31, 2023
045f158
Auto merge of #117444 - matthiaskrgr:rollup-43s0spc, r=matthiaskrgr
bors Oct 31, 2023
de83057
Use derivative for Clone
compiler-errors Oct 30, 2023
8eb932d
Use derivative for PartialOrd/ord
compiler-errors Oct 30, 2023
8b4fa0f
Use derivative for Hash
compiler-errors Oct 30, 2023
4512f21
Accept less invalid Rust in rustdoc
oli-obk Oct 31, 2023
d7d9f15
Auto merge of #117407 - compiler-errors:derive-clone, r=oli-obk
bors Oct 31, 2023
a8ece11
Add support for pre-unix-epoch file dates on Apple platforms (#108277)
Byron Oct 31, 2023
77174d3
Turn const_caller_location from a query to a hook
oli-obk Oct 30, 2023
50be229
Auto merge of #117450 - oli-obk:rustdoc_verify, r=estebank
bors Oct 31, 2023
51b275b
Rollup merge of #113241 - poliorcetics:85138-doc-object-safety, r=Gui…
matthiaskrgr Oct 31, 2023
83990ba
Rollup merge of #117388 - oli-obk:dequerification, r=RalfJung
matthiaskrgr Oct 31, 2023
290daf9
Rollup merge of #117417 - celinval:smir-visitor, r=oli-obk
matthiaskrgr Oct 31, 2023
86d69f9
Rollup merge of #117439 - lcnr:prepopulate-earlier, r=compiler-errors
matthiaskrgr Oct 31, 2023
d06200b
Rollup merge of #117451 - Byron:issue-108277-apple-fix, r=joshtriplett
matthiaskrgr Oct 31, 2023
7ea6977
Update cargo
weihanglo Oct 31, 2023
9d83ac2
Auto merge of #117462 - weihanglo:update-cargo, r=weihanglo
bors Oct 31, 2023
09ac6e4
Auto merge of #117459 - matthiaskrgr:rollup-t3osb3c, r=matthiaskrgr
bors Oct 31, 2023
98f5ebb
Auto merge of #113970 - cjgillot:assume-all-the-things, r=nikic
bors Nov 1, 2023
18168b8
remove excluded files from upstream
github-actions[bot] Nov 1, 2023
0df4dc9
pull new changes from upstream
github-actions[bot] Nov 1, 2023
d549a5c
add newly-added tests to conflict marker allowlist
tshepang Nov 1, 2023
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
97 changes: 40 additions & 57 deletions compiler/rustc_mir_transform/src/coverage/counters.rs
Original file line number Diff line number Diff line change
@@ -1,5 1,3 @@
use super::Error;

use super::graph;

use graph::{BasicCoverageBlock, BcbBranch, CoverageGraph, TraverseCoverageGraphWithLoops};
Expand Down Expand Up @@ -53,7 51,7 @@ pub(super) struct CoverageCounters {
/// edge between two BCBs.
bcb_edge_counters: FxHashMap<(BasicCoverageBlock, BasicCoverageBlock), BcbCounter>,
/// Tracks which BCBs have a counter associated with some incoming edge.
/// Only used by debug assertions, to verify that BCBs with incoming edge
/// Only used by assertions, to verify that BCBs with incoming edge
/// counters do not have their own physical counters (expressions are allowed).
bcb_has_incoming_edge_counters: BitSet<BasicCoverageBlock>,
/// Table of expression data, associating each expression ID with its
Expand Down Expand Up @@ -81,7 79,7 @@ impl CoverageCounters {
&mut self,
basic_coverage_blocks: &CoverageGraph,
bcb_has_coverage_spans: impl Fn(BasicCoverageBlock) -> bool,
) -> Result<(), Error> {
) {
MakeBcbCounters::new(self, basic_coverage_blocks).make_bcb_counters(bcb_has_coverage_spans)
}

Expand Down Expand Up @@ -111,26 109,23 @@ impl CoverageCounters {
self.expressions.len()
}

fn set_bcb_counter(
&mut self,
bcb: BasicCoverageBlock,
counter_kind: BcbCounter,
) -> Result<CovTerm, Error> {
debug_assert!(
fn set_bcb_counter(&mut self, bcb: BasicCoverageBlock, counter_kind: BcbCounter) -> CovTerm {
assert!(
// If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also
// have an expression (to be injected into an existing `BasicBlock` represented by this
// `BasicCoverageBlock`).
counter_kind.is_expression() || !self.bcb_has_incoming_edge_counters.contains(bcb),
"attempt to add a `Counter` to a BCB target with existing incoming edge counters"
);

let term = counter_kind.as_term();
if let Some(replaced) = self.bcb_counters[bcb].replace(counter_kind) {
Error::from_string(format!(
bug!(
"attempt to set a BasicCoverageBlock coverage counter more than once; \
{bcb:?} already had counter {replaced:?}",
))
);
} else {
Ok(term)
term
}
}

Expand All @@ -139,27 134,26 @@ impl CoverageCounters {
from_bcb: BasicCoverageBlock,
to_bcb: BasicCoverageBlock,
counter_kind: BcbCounter,
) -> Result<CovTerm, Error> {
if level_enabled!(tracing::Level::DEBUG) {
// If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also
// have an expression (to be injected into an existing `BasicBlock` represented by this
// `BasicCoverageBlock`).
if self.bcb_counter(to_bcb).is_some_and(|c| !c.is_expression()) {
return Error::from_string(format!(
"attempt to add an incoming edge counter from {from_bcb:?} when the target BCB already \
has a `Counter`"
));
}
) -> CovTerm {
// If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also
// have an expression (to be injected into an existing `BasicBlock` represented by this
// `BasicCoverageBlock`).
if let Some(node_counter) = self.bcb_counter(to_bcb) && !node_counter.is_expression() {
bug!(
"attempt to add an incoming edge counter from {from_bcb:?} \
when the target BCB already has {node_counter:?}"
);
}

self.bcb_has_incoming_edge_counters.insert(to_bcb);
let term = counter_kind.as_term();
if let Some(replaced) = self.bcb_edge_counters.insert((from_bcb, to_bcb), counter_kind) {
Error::from_string(format!(
bug!(
"attempt to set an edge counter more than once; from_bcb: \
{from_bcb:?} already had counter {replaced:?}",
))
);
} else {
Ok(term)
term
}
}

Expand Down Expand Up @@ -213,14 207,7 @@ impl<'a> MakeBcbCounters<'a> {
/// One way to predict which branch executes the least is by considering loops. A loop is exited
/// at a branch, so the branch that jumps to a `BasicCoverageBlock` outside the loop is almost
/// always executed less than the branch that does not exit the loop.
///
/// Returns any non-code-span expressions created to represent intermediate values (such as to
/// add two counters so the result can be subtracted from another counter), or an Error with
/// message for subsequent debugging.
fn make_bcb_counters(
&mut self,
bcb_has_coverage_spans: impl Fn(BasicCoverageBlock) -> bool,
) -> Result<(), Error> {
fn make_bcb_counters(&mut self, bcb_has_coverage_spans: impl Fn(BasicCoverageBlock) -> bool) {
debug!("make_bcb_counters(): adding a counter or expression to each BasicCoverageBlock");

// Walk the `CoverageGraph`. For each `BasicCoverageBlock` node with an associated
Expand All @@ -237,10 224,10 @@ impl<'a> MakeBcbCounters<'a> {
while let Some(bcb) = traversal.next() {
if bcb_has_coverage_spans(bcb) {
debug!("{:?} has at least one coverage span. Get or make its counter", bcb);
let branching_counter_operand = self.get_or_make_counter_operand(bcb)?;
let branching_counter_operand = self.get_or_make_counter_operand(bcb);

if self.bcb_needs_branch_counters(bcb) {
self.make_branch_counters(&traversal, bcb, branching_counter_operand)?;
self.make_branch_counters(&traversal, bcb, branching_counter_operand);
}
} else {
debug!(
Expand All @@ -251,22 238,19 @@ impl<'a> MakeBcbCounters<'a> {
}
}

if traversal.is_complete() {
Ok(())
} else {
Error::from_string(format!(
"`TraverseCoverageGraphWithLoops` missed some `BasicCoverageBlock`s: {:?}",
traversal.unvisited(),
))
}
assert!(
traversal.is_complete(),
"`TraverseCoverageGraphWithLoops` missed some `BasicCoverageBlock`s: {:?}",
traversal.unvisited(),
);
}

fn make_branch_counters(
&mut self,
traversal: &TraverseCoverageGraphWithLoops<'_>,
branching_bcb: BasicCoverageBlock,
branching_counter_operand: CovTerm,
) -> Result<(), Error> {
) {
let branches = self.bcb_branches(branching_bcb);
debug!(
"{:?} has some branch(es) without counters:\n {}",
Expand Down Expand Up @@ -299,10 283,10 @@ impl<'a> MakeBcbCounters<'a> {
counter",
branch, branching_bcb
);
self.get_or_make_counter_operand(branch.target_bcb)?
self.get_or_make_counter_operand(branch.target_bcb)
} else {
debug!(" {:?} has multiple incoming edges, so adding an edge counter", branch);
self.get_or_make_edge_counter_operand(branching_bcb, branch.target_bcb)?
self.get_or_make_edge_counter_operand(branching_bcb, branch.target_bcb)
};
if let Some(sumup_counter_operand) =
some_sumup_counter_operand.replace(branch_counter_operand)
Expand Down Expand Up @@ -337,19 321,18 @@ impl<'a> MakeBcbCounters<'a> {
debug!("{:?} gets an expression: {:?}", expression_branch, expression);
let bcb = expression_branch.target_bcb;
if expression_branch.is_only_path_to_target() {
self.coverage_counters.set_bcb_counter(bcb, expression)?;
self.coverage_counters.set_bcb_counter(bcb, expression);
} else {
self.coverage_counters.set_bcb_edge_counter(branching_bcb, bcb, expression)?;
self.coverage_counters.set_bcb_edge_counter(branching_bcb, bcb, expression);
}
Ok(())
}

#[instrument(level = "debug", skip(self))]
fn get_or_make_counter_operand(&mut self, bcb: BasicCoverageBlock) -> Result<CovTerm, Error> {
fn get_or_make_counter_operand(&mut self, bcb: BasicCoverageBlock) -> CovTerm {
// If the BCB already has a counter, return it.
if let Some(counter_kind) = &self.coverage_counters.bcb_counters[bcb] {
debug!("{bcb:?} already has a counter: {counter_kind:?}");
return Ok(counter_kind.as_term());
return counter_kind.as_term();
}

// A BCB with only one incoming edge gets a simple `Counter` (via `make_counter()`).
Expand Down Expand Up @@ -378,10 361,10 @@ impl<'a> MakeBcbCounters<'a> {

let mut predecessors = self.bcb_predecessors(bcb).to_owned().into_iter();
let first_edge_counter_operand =
self.get_or_make_edge_counter_operand(predecessors.next().unwrap(), bcb)?;
self.get_or_make_edge_counter_operand(predecessors.next().unwrap(), bcb);
let mut some_sumup_edge_counter_operand = None;
for predecessor in predecessors {
let edge_counter_operand = self.get_or_make_edge_counter_operand(predecessor, bcb)?;
let edge_counter_operand = self.get_or_make_edge_counter_operand(predecessor, bcb);
if let Some(sumup_edge_counter_operand) =
some_sumup_edge_counter_operand.replace(edge_counter_operand)
{
Expand Down Expand Up @@ -411,7 394,7 @@ impl<'a> MakeBcbCounters<'a> {
&mut self,
from_bcb: BasicCoverageBlock,
to_bcb: BasicCoverageBlock,
) -> Result<CovTerm, Error> {
) -> CovTerm {
// If the source BCB has only one successor (assumed to be the given target), an edge
// counter is unnecessary. Just get or make a counter for the source BCB.
let successors = self.bcb_successors(from_bcb).iter();
Expand All @@ -424,7 407,7 @@ impl<'a> MakeBcbCounters<'a> {
self.coverage_counters.bcb_edge_counters.get(&(from_bcb, to_bcb))
{
debug!("Edge {from_bcb:?}->{to_bcb:?} already has a counter: {counter_kind:?}");
return Ok(counter_kind.as_term());
return counter_kind.as_term();
}

// Make a new counter to count this edge.
Expand Down
17 changes: 1 addition & 16 deletions compiler/rustc_mir_transform/src/coverage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 26,6 @@ use rustc_span::def_id::DefId;
use rustc_span::source_map::SourceMap;
use rustc_span::{ExpnKind, SourceFile, Span, Symbol};

/// A simple error message wrapper for `coverage::Error`s.
#[derive(Debug)]
struct Error {
message: String,
}

impl Error {
pub fn from_string<T>(message: String) -> Result<T, Error> {
Err(Self { message })
}
}

/// Inserts `StatementKind::Coverage` statements that either instrument the binary with injected
/// counters, via intrinsic `llvm.instrprof.increment`, and/or inject metadata used during codegen
/// to construct the coverage map.
Expand Down Expand Up @@ -167,10 155,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
// `BasicCoverageBlock`s not already associated with a coverage span.
let bcb_has_coverage_spans = |bcb| coverage_spans.bcb_has_coverage_spans(bcb);
self.coverage_counters
.make_bcb_counters(&mut self.basic_coverage_blocks, bcb_has_coverage_spans)
.unwrap_or_else(|e| {
bug!("Error processing: {:?}: {:?}", self.mir_body.source.def_id(), e.message)
});
.make_bcb_counters(&self.basic_coverage_blocks, bcb_has_coverage_spans);

let mappings = self.create_mappings_and_inject_coverage_statements(&coverage_spans);

Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_mir_transform/src/coverage/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,15 647,13 @@ fn test_traverse_coverage_with_loops() {
fn test_make_bcb_counters() {
rustc_span::create_default_session_globals_then(|| {
let mir_body = goto_switchint();
let mut basic_coverage_blocks = graph::CoverageGraph::from_mir(&mir_body);
let basic_coverage_blocks = graph::CoverageGraph::from_mir(&mir_body);
// Historically this test would use `spans` internals to set up fake
// coverage spans for BCBs 1 and 2. Now we skip that step and just tell
// BCB counter construction that those BCBs have spans.
let bcb_has_coverage_spans = |bcb: BasicCoverageBlock| (1..=2).contains(&bcb.as_usize());
let mut coverage_counters = counters::CoverageCounters::new(&basic_coverage_blocks);
coverage_counters
.make_bcb_counters(&mut basic_coverage_blocks, bcb_has_coverage_spans)
.expect("should be Ok");
coverage_counters.make_bcb_counters(&basic_coverage_blocks, bcb_has_coverage_spans);
assert_eq!(coverage_counters.num_expressions(), 0);

let_bcb!(1);
Expand Down