about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/monomorphize
AgeCommit message (Collapse)AuthorLines
2021-09-07Move monomorphize code to its own crate.Camille GILLOT-3053/+0
2021-08-28Treat macros as HIR itemsinquisitivecrystal-0/+1
2021-08-26reviewlcnr-4/+4
2021-08-26update `TypeFlags` to deal with missing ct substslcnr-4/+4
2021-08-26add `tcx` to `fn walk`lcnr-1/+1
2021-08-26make unevaluated const substs optionallcnr-8/+8
2021-08-26require a `tcx` for `TypeVisitor`lcnr-3/+11
2021-08-24Auto merge of #87739 - Aaron1011:remove-used-attrs, r=wesleywiserbors-5/+1
Remove `Session.used_attrs` and move logic to `CheckAttrVisitor` Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-08-22Fix more “a”/“an” typosFrank Steffahn-1/+1
2021-08-21Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`Aaron Hill-5/+1
Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-07-25clippy:: append_instead_of_extendMatthias Krüger-1/+1
2021-07-20Switch to store `Instance` directly within `VtblEntry`, fix `TraitVPtr` ↵Charles Lew-7/+3
representation.
2021-07-20Refactor vtable format.Charles Lew-0/+4
2021-07-14consistently treat None-tagged pointers as ints; get rid of some deprecated ↵Ralf Jung-1/+1
Scalar methods
2021-07-14CTFE/Miri engine Pointer type overhaul: make Scalar-to-Pointer conversion ↵Ralf Jung-4/+4
infallible This resolves all the problems we had around "normalizing" the representation of a Scalar in case it carries a Pointer value: we can just use Pointer if we want to have a value taht we are sure is already normalized.
2021-07-04Combine individual limit queries into single `limits` queryAaron Hill-3/+3
2021-07-04Query-ify global limit attribute handlingAaron Hill-6/+16
2021-06-28Introduce -Zprofile-closures to evaluate the impact of 2229Aman Arora-0/+81
This creates a CSV with name "closure_profile_XXXXX.csv", where the variable part is the process id of the compiler. To profile a cargo project you can run one of the following depending on if you're compiling a library or a binary: ``` cargo +stage1 rustc --lib -- -Zprofile-closures cargo +stage1 rustc --bin -- -Zprofile-closures ```
2021-06-15Refactor to make interpreter and codegen backend neutral to vtable internal ↵Charles Lew-10/+11
representation.
2021-05-27don't trim paths in collector PME messageRémy Rakic-4/+3
2021-05-25emit diagnostic after post-monomorphization errorsRémy Rakic-2/+44
Emit a diagnostic when the monomorphized item collector encounters errors during a step of the recursive item collection. These post-monomorphization errors otherwise only show the erroneous expression without a trace, making them very obscure and hard to pinpoint whenever they happen in dependencies.
2021-05-17Auto merge of #85178 - cjgillot:local-crate, r=oli-obkbors-16/+16
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-13global_asm! consts do not depend on other itemsAmanieu d'Antras-7/+4
2021-05-13Add support for const operands and options to global_asm!Amanieu d'Antras-1/+20
On x86, the default syntax is also switched to Intel to match asm!
2021-05-12Use () for codegen queries.Camille GILLOT-10/+8
2021-05-12Use () for entry_fn.Camille GILLOT-1/+1
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-04-29Implement RFC 1260 with feature_name `imported_main`.Charles Lew-2/+2
2021-04-20Add an attribute to be able to configure the limitOli Scherer-1/+6
2021-04-20Implement a lint that highlights all moves larger than 1000 bytesOli Scherer-0/+37
2021-04-02fixMario Carneiro-1/+2
2021-04-02clarify wordingMario Carneiro-3/+6
2021-04-02Monomorphization doc fixMario Carneiro-2/+2
Only public items are monomorphization roots. This can be confirmed by noting that this program compiles: ```rust fn foo<T>() { if true { foo::<Option<T>>() } } fn bar() { foo::<()>() } ```
2021-04-02Auto merge of #83207 - oli-obk:valtree2, r=lcnrbors-2/+37
normalize mir::Constant differently from ty::Const in preparation for valtrees Valtrees are unable to represent many kind of constant values (this is on purpose). For constants that are used at runtime, we do not need a valtree representation and can thus use a different form of evaluation. In order to make this explicit and less fragile, I added a `fold_constant` method to `TypeFolder` and implemented it for normalization. Normalization can now, when it wants to eagerly evaluate a constant, normalize `mir::Constant` directly into a `mir::ConstantKind::Val` instead of relying on the `ty::Const` evaluation. In the future we can get rid of the `ty::Const` in there entirely and add our own `Unevaluated` variant to `mir::ConstantKind`. This would allow us to remove the `promoted` field from `ty::ConstKind::Unevaluated`, as promoteds can never occur in the type system. cc `@rust-lang/wg-const-eval` r? `@lcnr`
2021-03-31Cleanups and commentsJack Huey-3/+1
2021-03-31Some rebinds and dummysJack Huey-3/+5
2021-03-31Add a new normalization query just for mir constantsOli Scherer-1/+30
2021-03-31We should never see unevaluated type-level constants after monomorphization ↵Oli Scherer-1/+7
unless errors occurred
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-25Auto merge of #83307 - richkadel:cov-unused-functions-1.1, r=tmandrybors-1/+7
coverage bug fixes and optimization support 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. FYI: `@wesleywiser` r? `@tmandry`
2021-03-23Add has_default to GenericParamDefKind::Constkadmin-1/+2
This currently creates a field which is always false on GenericParamDefKind for future use when consts are permitted to have defaults Update const_generics:default locations Previously just ignored them, now actually do something about them. Fix using type check instead of value Add parsing This adds all the necessary changes to lower const-generics defaults from parsing. Change P<Expr> to AnonConst This matches the arguments passed to instantiations of const generics, and makes it specific to just anonymous constants. Attempt to fix lowering bugs
2021-03-20update `const_eval_resolve`lcnr-2/+2
2021-03-20extract `ConstKind::Unevaluated` into a structlcnr-4/+4
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-18Rollup merge of #83080 - tmiasko:inline-coverage, r=wesleywiserDylan DPC-0/+25
Make source-based code coverage compatible with MIR inlining When codegenning code coverage use the instance that coverage data was originally generated for, to ensure basic level of compatibility with MIR inlining. Fixes #83061
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-03-12Prepare mir::Constant for ty::Const only supporting valtreesOli Scherer-1/+1
2021-03-04Fixes -Zpolymorphize for src/test/ui/const-generics/auxiliary/crayte.rsOli Scherer-9/+39
2021-03-04Spread tracing instrumentation into the polymorphization logicOli Scherer-33/+27