about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/monomorphize/partitioning
AgeCommit message (Collapse)AuthorLines
2021-09-07Move monomorphize code to its own crate.Camille GILLOT-1134/+0
2021-08-22Fix more “a”/“an” typosFrank Steffahn-1/+1
2021-07-25clippy:: append_instead_of_extendMatthias Krüger-1/+1
2021-05-12Use () for codegen queries.Camille GILLOT-8/+6
2021-05-12Use () in reachable_set.Camille GILLOT-5/+7
2021-05-09Add primary marker on codegen unit to take charge of main_wrapper for ↵Charles Lew-2/+4
non-local cases.
2021-03-30Run LLVM coverage instrumentation passes before optimization passesAmanieu d'Antras-7/+1
This matches the behavior of Clang and allows us to remove several hacks which were needed to ensure functions weren't optimized away before reaching the instrumentation pass.
2021-03-19coverage bug fixes and optimization supportRich Kadel-1/+7
Adjusted LLVM codegen for code compiled with `-Zinstrument-coverage` to address multiple, somewhat related issues. Fixed a significant flaw in prior coverage solution: Every counter generated a new counter variable, but there should have only been one counter variable per function. This appears to have bloated .profraw files significantly. (For a small program, it increased the size by about 40%. I have not tested large programs, but there is anecdotal evidence that profraw files were way too large. This is a good fix, regardless, but hopefully it also addresses related issues. Fixes: #82144 Invalid LLVM coverage data produced when compiled with -C opt-level=1 Existing tests now work up to at least `opt-level=3`. This required a detailed analysis of the LLVM IR, comparisons with Clang C++ LLVM IR when compiled with coverage, and a lot of trial and error with codegen adjustments. The biggest hurdle was figuring out how to continue to support coverage results for unused functions and generics. Rust's coverage results have three advantages over Clang's coverage results: 1. Rust's coverage map does not include any overlapping code regions, making coverage counting unambiguous. 2. Rust generates coverage results (showing zero counts) for all unused functions, including generics. (Clang does not generate coverage for uninstantiated template functions.) 3. Rust's unused functions produce minimal stubbed functions in LLVM IR, sufficient for including in the coverage results; while Clang must generate the complete LLVM IR for each unused function, even though it will never be called. This PR removes the previous hack of attempting to inject coverage into some other existing function instance, and generates dedicated instances for each unused function. This change, and a few other adjustments (similar to what is required for `-C link-dead-code`, but with lower impact), makes it possible to support LLVM optimizations. Fixes: #79651 Coverage report: "Unexecuted instantiation:..." for a generic function from multiple crates Fixed by removing the aforementioned hack. Some "Unexecuted instantiation" notices are unavoidable, as explained in the `used_crate.rs` test, but `-Zinstrument-coverage` has new options to back off support for either unused generics, or all unused functions, which avoids the notice, at the cost of less coverage of unused functions. Fixes: #82875 Invalid LLVM coverage data produced with crate brotli_decompressor Fixed by disabling the LLVM function attribute that forces inlining, if `-Z instrument-coverage` is enabled. This attribute is applied to Rust functions with `#[inline(always)], and in some cases, the forced inlining breaks coverage instrumentation and reports.
2021-03-15Functions inlined into reachable functions are reachableTomasz Miąsko-0/+25
Consider functions to be reachable for code coverage purposes, either when they reach the code generation directly, or indirectly as inlined part of another function.
2021-02-24Use log level to control partitioning debug outputTomasz Miąsko-6/+15
2021-02-15Only store a LocalDefId in hir::Item.Camille GILLOT-4/+3
Items are guaranteed to be HIR owner.
2021-02-15Use an ItemId inside mir::GlobalAsm.Camille GILLOT-3/+3
2021-01-14Use Option::map_or instead of `.map(..).unwrap_or(..)`LingMan-2/+1
2020-11-16compiler: fold by valueBastian Kauschke-1/+1
2020-11-08Collapse all uses of `target.options.foo` into `target.foo`Vadim Petrochenkov-1/+1
with an eye on merging `TargetOptions` into `Target`. `TargetOptions` as a separate structure is mostly an implementation detail of `Target` construction, all its fields logically belong to `Target` and available from `Target` through `Deref` impls.
2020-10-15Replace target.target with target and target.ptr_width with target.pointer_widthest31-1/+1
Preparation for a subsequent change that replaces rustc_target::config::Config with its wrapped Target. On its own, this commit breaks the build. I don't like making build-breaking commits, but in this instance I believe that it makes review easier, as the "real" changes of this PR can be seen much more easily. Result of running: find compiler/ -type f -exec sed -i -e 's/target\.target\([)\.,; ]\)/target\1/g' {} \; find compiler/ -type f -exec sed -i -e 's/target\.target$/target/g' {} \; find compiler/ -type f -exec sed -i -e 's/target.ptr_width/target.pointer_width/g' {} \; ./x.py fmt
2020-09-25Avoid calling `Symbol::interner` in `compute_codegen_unit_name`marmeladema-3/+1
2020-09-25Rename `DefPathData::get_name()` to `DefPathData::name()`marmeladema-1/+1
2020-09-25Move from {{closure}}#0 syntax to {closure#0} for (def) path componentsmarmeladema-1/+7
2020-09-20use `array_windows` instead of `windows` in the compilerBastian Kauschke-7/+1
2020-09-16Rollup merge of #76694 - wesleywiser:partitioning_cx_trait, r=davidtwcoDylan DPC-34/+38
Introduce a PartitioningCx struct This contains all the data used by the partitioning algorithm and allows that data to be used at each stage of the partitioning. This is useful for other approaches to partitioning which may want different pieces of the data available at each step. cc @rust-lang/wg-incr-comp
2020-09-14Auto merge of #76541 - matthiaskrgr:unstable_sort, r=davidtwcobors-1/+3
use sort_unstable to sort primitive types It's not important to retain original order if we have &[1, 1, 2, 3] for example. clippy::stable_sort_primitive
2020-09-13Introduce a PartitioningCx structWesley Wiser-34/+38
2020-09-10use push(char) instead of push_str(&str) to add single chars to stringsMatthias Krüger-3/+3
clippy::single-char-push-str
2020-09-10use sort_unstable to sort primitive typesMatthias Krüger-1/+3
It's not important to retain original order if we have &[1, 1, 2, 3] for example. clippy::stable_sort_primitive
2020-09-02pretty: trim paths of unique symbolsDan Aloni-1/+2
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
2020-08-31Rollup merge of #76002 - richkadel:llvm-coverage-map-gen-6b.3, r=tmandryTyler Mandry-2/+2
Fix `-Z instrument-coverage` on MSVC Found that `-C link-dead-code` (which was enabled automatically under `-Z instrument-coverage`) was causing the linking error that resulted in segmentation faults in coverage instrumented binaries. Link dead code is now disabled under MSVC, allowing `-Z instrument-coverage` to be enabled under MSVC for the first time. More details are included in Issue #76038 . Note this PR makes it possible to support `Z instrument-coverage` but does not enable instrument coverage for MSVC in existing tests. It will be enabled in another PR to follow this one (both PRs coming from original PR #75828). r? @tmandry FYI: @wesleywiser
2020-08-31Fix `-Z instrument-coverage` on MSVCRich Kadel-2/+2
Found that -C link-dead-code (which was enabled automatically under -Z instrument-coverage) was causing the linking error that resulted in segmentation faults in coverage instrumented binaries. Link dead code is now disabled under MSVC, allowing `-Z instrument-coverage` to be enabled under MSVC for the first time. More details are included in Issue #76038. (This PR was broken out from PR #75828)
2020-08-30ty: remove obsolete printerDavid Wood-2/+2
This commit removes the obsolete printer and replaces all uses of it with `FmtPrinter`. Of the replaced uses, all but one use was in `debug!` logging, two cases were notable: - `MonoItem::to_string` is used in `-Z print-mono-items` and therefore affects the output of all codegen-units tests. - `DefPathBasedNames` was used in `librustc_codegen_llvm/type_of.rs` with `LLVMStructCreateNamed` and that'll now get different values, but this should result in no functional change. Signed-off-by: David Wood <david@davidtw.co>
2020-08-30mv compiler to compiler/mark-0/+1095