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

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
06fe278
Fix unindent behavior between different doc comments
GuillaumeGomez Oct 26, 2020
b4c3536
Add test for doc comments unindent fix
GuillaumeGomez Oct 26, 2020
f3e6d88
Fix typos and replace static vector with slice
bugadani Oct 28, 2020
a21f3a7
Clean up encode_dep_graph
bugadani Oct 28, 2020
5248b20
Reuse memory
bugadani Oct 28, 2020
2fa3598
Avoid reallocating cgu_path_components
bugadani Oct 28, 2020
a8803d3
Delete files immediately, instead of collecting into vector
bugadani Oct 28, 2020
6bbb7fd
Change a bit how the first doc comment lines are handled
GuillaumeGomez Oct 29, 2020
fcee70f
Update tests
GuillaumeGomez Oct 29, 2020
ad27894
Move compiletest meta tests to a separate directory
tmiasko Oct 30, 2020
affb47f
Add a test for compiletest rustc-env & unset-rustc-env directives
tmiasko Oct 30, 2020
289c0d8
Retagging: do not retag 'raw reborrows'
RalfJung Oct 31, 2020
fef9c63
Rust coverage before splitting instrument_coverage.rs
richkadel Oct 5, 2020
0bb09c1
Splitting transform/instrument_coverage.rs into transform/coverage/...
richkadel Oct 23, 2020
7b87ae4
Implemented CoverageGraph of BasicCoverageBlocks
richkadel Oct 23, 2020
af0c84c
Adds coverage graphviz
richkadel Oct 23, 2020
868de57
Injecting expressions in place of counters where helpful
richkadel Oct 22, 2020
da20b67
Added comments on remapping expression IDs, and URL to spanviews
richkadel Oct 25, 2020
0edf4a5
Addressed all feedback to date
richkadel Oct 25, 2020
3685689
Responded to all feedback as of 2020-10-30
richkadel Oct 30, 2020
87f2897
Improve code in unindent_comment a bit more
GuillaumeGomez Nov 1, 2020
c0cbf63
inliner: Remove redundant loop
tmiasko Nov 2, 2020
a8dfb26
Document -Zinstrument-coverage
richkadel Oct 31, 2020
c83c635
Fix intrinsic size_of stable link
pickfire Nov 2, 2020
e78e9d4
Treat trailing semicolon as a statement in macro call
Aaron1011 Oct 25, 2020
6d94911
addressed feedback
richkadel Nov 2, 2020
3d7baee
fix cross-platform test bugs
richkadel Nov 2, 2020
974c03d
Rollup merge of #78267 - richkadel:llvm-coverage-counters-2.0.3r1, r=…
Dylan-DPC Nov 3, 2020
3a110ef
Rollup merge of #78376 - Aaron1011:feature/consistent-empty-expr, r=p…
Dylan-DPC Nov 3, 2020
1425ac0
Rollup merge of #78400 - GuillaumeGomez:fix-unindent, r=jyn514
Dylan-DPC Nov 3, 2020
01e7c01
Rollup merge of #78489 - bugadani:array, r=estebank
Dylan-DPC Nov 3, 2020
5f0c9c1
Rollup merge of #78575 - tmiasko:compiletest-rustc-env, r=Aaron1011
Dylan-DPC Nov 3, 2020
8088713
Rollup merge of #78597 - RalfJung:raw-retag, r=oli-obk
Dylan-DPC Nov 3, 2020
d56e305
Rollup merge of #78616 - richkadel:unstable-book-instr-cov, r=tmandry
Dylan-DPC Nov 3, 2020
bb3ef75
Rollup merge of #78664 - pickfire:patch-4, r=jonas-schievink
Dylan-DPC Nov 3, 2020
04245d1
Rollup merge of #78668 - tmiasko:inline, r=oli-obk
Dylan-DPC Nov 3, 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
7 changes: 7 additions & 0 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,13 @@ pub struct Stmt {
}

impl Stmt {
pub fn has_trailing_semicolon(&self) -> bool {
match &self.kind {
StmtKind::Semi(_) => true,
StmtKind::MacCall(mac) => matches!(mac.style, MacStmtStyle::Semicolon),
_ => false,
}
}
pub fn add_trailing_semicolon(mut self) -> Self {
self.kind = match self.kind {
StmtKind::Expr(expr) => StmtKind::Semi(expr),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl CoverageMapGenerator {
let (filenames_index, _) = self.filenames.insert_full(c_filename);
virtual_file_mapping.push(filenames_index as u32);
}
debug!("Adding counter {:?} to map for {:?}", counter, region,);
debug!("Adding counter {:?} to map for {:?}", counter, region);
mapping_regions.push(CounterMappingRegion::code_region(
counter,
current_file_id,
Expand Down
63 changes: 41 additions & 22 deletions compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_codegen_ssa::traits::{
use rustc_data_structures::fx::FxHashMap;
use rustc_llvm::RustString;
use rustc_middle::mir::coverage::{
CodeRegion, CounterValueReference, ExpressionOperandId, InjectedExpressionIndex, Op,
CodeRegion, CounterValueReference, ExpressionOperandId, InjectedExpressionId, Op,
};
use rustc_middle::ty::Instance;

Expand All @@ -27,16 +27,16 @@ const COVMAP_VAR_ALIGN_BYTES: usize = 8;

/// A context object for maintaining all state needed by the coverageinfo module.
pub struct CrateCoverageContext<'tcx> {
// Coverage region data for each instrumented function identified by DefId.
pub(crate) function_coverage_map: RefCell<FxHashMap<Instance<'tcx>, FunctionCoverage>>,
// Coverage data for each instrumented function identified by DefId.
pub(crate) function_coverage_map: RefCell<FxHashMap<Instance<'tcx>, FunctionCoverage<'tcx>>>,
}

impl<'tcx> CrateCoverageContext<'tcx> {
pub fn new() -> Self {
Self { function_coverage_map: Default::default() }
}

pub fn take_function_coverage_map(&self) -> FxHashMap<Instance<'tcx>, FunctionCoverage> {
pub fn take_function_coverage_map(&self) -> FxHashMap<Instance<'tcx>, FunctionCoverage<'tcx>> {
self.function_coverage_map.replace(FxHashMap::default())
}
}
Expand All @@ -58,47 +58,66 @@ impl CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
unsafe { llvm::LLVMRustCoverageCreatePGOFuncNameVar(llfn, mangled_fn_name.as_ptr()) }
}

fn add_counter_region(
fn set_function_source_hash(
&mut self,
instance: Instance<'tcx>,
function_source_hash: u64,
) -> bool {
if let Some(coverage_context) = self.coverage_context() {
debug!(
"ensuring function source hash is set for instance={:?}; function_source_hash={}",
instance, function_source_hash,
);
let mut coverage_map = coverage_context.function_coverage_map.borrow_mut();
coverage_map
.entry(instance)
.or_insert_with(|| FunctionCoverage::new(self.tcx, instance))
.set_function_source_hash(function_source_hash);
true
} else {
false
}
}

fn add_coverage_counter(
&mut self,
instance: Instance<'tcx>,
id: CounterValueReference,
region: CodeRegion,
) -> bool {
if let Some(coverage_context) = self.coverage_context() {
debug!(
"adding counter to coverage_regions: instance={:?}, function_source_hash={}, id={:?}, \
at {:?}",
instance, function_source_hash, id, region,
"adding counter to coverage_map: instance={:?}, id={:?}, region={:?}",
instance, id, region,
);
let mut coverage_regions = coverage_context.function_coverage_map.borrow_mut();
coverage_regions
let mut coverage_map = coverage_context.function_coverage_map.borrow_mut();
coverage_map
.entry(instance)
.or_insert_with(|| FunctionCoverage::new(self.tcx, instance))
.add_counter(function_source_hash, id, region);
.add_counter(id, region);
true
} else {
false
}
}

fn add_counter_expression_region(
fn add_coverage_counter_expression(
&mut self,
instance: Instance<'tcx>,
id: InjectedExpressionIndex,
id: InjectedExpressionId,
lhs: ExpressionOperandId,
op: Op,
rhs: ExpressionOperandId,
region: CodeRegion,
region: Option<CodeRegion>,
) -> bool {
if let Some(coverage_context) = self.coverage_context() {
debug!(
"adding counter expression to coverage_regions: instance={:?}, id={:?}, {:?} {:?} {:?}, \
at {:?}",
"adding counter expression to coverage_map: instance={:?}, id={:?}, {:?} {:?} {:?}; \
region: {:?}",
instance, id, lhs, op, rhs, region,
);
let mut coverage_regions = coverage_context.function_coverage_map.borrow_mut();
coverage_regions
let mut coverage_map = coverage_context.function_coverage_map.borrow_mut();
coverage_map
.entry(instance)
.or_insert_with(|| FunctionCoverage::new(self.tcx, instance))
.add_counter_expression(id, lhs, op, rhs, region);
Expand All @@ -108,14 +127,14 @@ impl CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
}
}

fn add_unreachable_region(&mut self, instance: Instance<'tcx>, region: CodeRegion) -> bool {
fn add_coverage_unreachable(&mut self, instance: Instance<'tcx>, region: CodeRegion) -> bool {
if let Some(coverage_context) = self.coverage_context() {
debug!(
"adding unreachable code to coverage_regions: instance={:?}, at {:?}",
"adding unreachable code to coverage_map: instance={:?}, at {:?}",
instance, region,
);
let mut coverage_regions = coverage_context.function_coverage_map.borrow_mut();
coverage_regions
let mut coverage_map = coverage_context.function_coverage_map.borrow_mut();
coverage_map
.entry(instance)
.or_insert_with(|| FunctionCoverage::new(self.tcx, instance))
.add_unreachable_region(region);
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_codegen_ssa/src/coverageinfo/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_middle::mir::coverage::{CounterValueReference, MappedExpressionIndex};
/// Aligns with [llvm::coverage::Counter::CounterKind](https://github.com/rust-lang/llvm-project/blob/rustc/10.0-2020-05-05/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h#L91)
#[derive(Copy, Clone, Debug)]
#[repr(C)]
enum CounterKind {
pub enum CounterKind {
Zero = 0,
CounterValueReference = 1,
Expression = 2,
Expand All @@ -23,8 +23,8 @@ enum CounterKind {
#[repr(C)]
pub struct Counter {
// Important: The layout (order and types of fields) must match its C++ counterpart.
kind: CounterKind,
id: u32,
pub kind: CounterKind,
pub id: u32,
}

impl Counter {
Expand Down Expand Up @@ -55,9 +55,9 @@ pub enum ExprKind {
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct CounterExpression {
kind: ExprKind,
lhs: Counter,
rhs: Counter,
pub kind: ExprKind,
pub lhs: Counter,
pub rhs: Counter,
}

impl CounterExpression {
Expand Down
Loading