Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b97487b
Add check for doc alias attribute format
GuillaumeGomez May 30, 2020
2d6267a
Add test for doc alias attribute validation
GuillaumeGomez May 30, 2020
0c5c644
Mention that BTreeMap::new() doesn't allocate
TrolledWoods Jun 1, 2020
7ef9eb3
Merge pull request #4 from rust-lang/master
richkadel Jun 18, 2020
791cccc
Merge pull request #5 from rust-lang/master
richkadel Jun 19, 2020
8c7c84b
code coverage foundation for hash and num_counters
richkadel Jun 18, 2020
8fc2eeb
Use newtype to map from `Local` to `GeneratorSavedLocal`
ecstatic-morse Jun 10, 2020
c178e64
Look for stores between non-conflicting generator saved locals
ecstatic-morse Jun 10, 2020
b2ec645
Incorporate review suggestions
ecstatic-morse Jun 19, 2020
95f8daa
Fix -Z unpretty=everybody_loops
jyn514 Jun 20, 2020
f60513e
Move remaining `NodeId` APIs from `Definitions` to `Resolver`
marmeladema Jun 20, 2020
1d3f49f
Always create a root definition when creating a new `Definitions` obj…
marmeladema Jun 21, 2020
bd4f6f0
Move `next_disambiguator` to `Resolver`
marmeladema Jun 21, 2020
933fe80
num_counters to u32, after implementing TypeFoldable
richkadel Jun 22, 2020
932237b
fix `intrinsics::needs_drop` docs
lcnr Jun 22, 2020
3ed96a6
Point at the call spawn when overflow occurs during monomorphization
Aaron1011 Jun 22, 2020
f4a7938
implemented query for coverage data
richkadel Jun 22, 2020
f84b7e1
Provide context on E0308 involving fn items
estebank Jun 22, 2020
994d9d0
Address remaining feedback items
richkadel Jun 22, 2020
08ec4cb
moves coverage data computation from pass to query
richkadel Jun 23, 2020
3d0192e
PR no longer requires u32 impl TypeFoldable
richkadel Jun 23, 2020
a045140
using "mir_body" (vs "body") in InstrumentCoverage
richkadel Jun 23, 2020
977ce57
Updated query for num_counters to compute from max index
richkadel Jun 23, 2020
5fa8b08
The const propagator cannot trace references.
oli-obk Jun 22, 2020
0c2b025
rustc: Modernize wasm checks for atomics
alexcrichton Jun 23, 2020
6e8aa1f
review comments: wording and style
estebank Jun 23, 2020
7d2fba1
Rollup merge of #72780 - GuillaumeGomez:enforce-doc-alias-check, r=ol…
Manishearth Jun 23, 2020
317a151
Rollup merge of #72876 - TrolledWoods:patch-2, r=Dylan-DPC
Manishearth Jun 23, 2020
781b589
Rollup merge of #73244 - ecstatic-morse:validate-generator-mir, r=tma…
Manishearth Jun 23, 2020
f5e46fe
Rollup merge of #73488 - richkadel:llvm-coverage-map-gen, r=tmandry
Manishearth Jun 23, 2020
505cf52
Rollup merge of #73523 - jyn514:everybody_loops, r=ecstatic-morse
Manishearth Jun 23, 2020
045761c
Rollup merge of #73587 - marmeladema:hir-id-ification-final, r=petroc…
Manishearth Jun 23, 2020
30fba22
Rollup merge of #73601 - Aaron1011:fix/better-mono-overflow-err, r=ec…
Manishearth Jun 23, 2020
d8b4604
Rollup merge of #73613 - oli-obk:const_prop_miscompile, r=wesleywiser
Manishearth Jun 23, 2020
f7d5687
Rollup merge of #73614 - lcnr:patch-4, r=Dylan-DPC
Manishearth Jun 23, 2020
4f2e540
Rollup merge of #73630 - estebank:fn-item-e0308, r=davidtwco
Manishearth Jun 23, 2020
6ed6a84
Rollup merge of #73665 - alexcrichton:update-wasm-atomics-feature, r=…
Manishearth Jun 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
Updated query for num_counters to compute from max index
Also added FIXME comments to note the possible need to accommodate
counter increment calls in source-based functions that differ from the
function context of the caller instance (e.g., inline functions).
  • Loading branch information
richkadel committed Jun 23, 2020
commit 977ce57d915914139c4aa643e63f368913e5f437
3 changes: 3 additions & 0 deletions src/librustc_codegen_llvm/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
self.call(llfn, &[], None)
}
"count_code_region" => {
// FIXME(richkadel): The current implementation assumes the MIR for the given
// caller_instance represents a single function. Validate and/or correct if inlining
// and/or monomorphization invalidates these assumptions.
let coverage_data = tcx.coverage_data(caller_instance.def_id());
let mangled_fn = tcx.symbol_name(caller_instance);
let (mangled_fn_name, _len_val) = self.const_str(mangled_fn.name);
Expand Down
28 changes: 24 additions & 4 deletions src/librustc_mir/transform/instrument_coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_hir::lang_items;
use rustc_middle::hir;
use rustc_middle::ich::StableHashingContext;
use rustc_middle::mir::interpret::Scalar;
use rustc_middle::mir::interpret::{ConstValue, Scalar};
use rustc_middle::mir::{
self, traversal, BasicBlock, BasicBlockData, CoverageData, Operand, Place, SourceInfo,
StatementKind, Terminator, TerminatorKind, START_BLOCK,
};
use rustc_middle::ty;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::FnDef;
use rustc_middle::ty::TyCtxt;
use rustc_middle::ty::{ConstKind, FnDef};
use rustc_span::def_id::DefId;
use rustc_span::Span;

Expand All @@ -26,16 +26,36 @@ pub struct InstrumentCoverage;
pub(crate) fn provide(providers: &mut Providers<'_>) {
providers.coverage_data = |tcx, def_id| {
let mir_body = tcx.optimized_mir(def_id);
// FIXME(richkadel): The current implementation assumes the MIR for the given DefId
// represents a single function. Validate and/or correct if inlining and/or monomorphization
// invalidates these assumptions.
let count_code_region_fn =
tcx.require_lang_item(lang_items::CountCodeRegionFnLangItem, None);
let mut num_counters: u32 = 0;
// The `num_counters` argument to `llvm.instrprof.increment` is the number of injected
// counters, with each counter having an index from `0..num_counters-1`. MIR optimization
// may split and duplicate some BasicBlock sequences. Simply counting the calls may not
// not work; but computing the num_counters by adding `1` to the highest index (for a given
// instrumented function) is valid.
for (_, data) in traversal::preorder(mir_body) {
if let Some(terminator) = &data.terminator {
if let TerminatorKind::Call { func: Operand::Constant(func), .. } = &terminator.kind
if let TerminatorKind::Call { func: Operand::Constant(func), args, .. } =
&terminator.kind
{
if let FnDef(called_fn_def_id, _) = func.literal.ty.kind {
if called_fn_def_id == count_code_region_fn {
num_counters += 1;
if let Operand::Constant(constant) =
args.get(0).expect("count_code_region has at least one arg")
{
if let ConstKind::Value(ConstValue::Scalar(value)) =
constant.literal.val
{
let index = value
.to_u32()
.expect("count_code_region index at arg0 is u32");
num_counters = std::cmp::max(num_counters, index + 1);
}
}
}
}
}
Expand Down