about summary refs log tree commit diff
path: root/src/librustc_mir/interpret
AgeCommit message (Collapse)AuthorLines
2020-07-22Rollup merge of #74538 - nbdd0121:issue-73976, r=lcnrManish Goregaokar-2/+10
Guard against non-monomorphized type_id intrinsic call This PR checks whether the type is sufficient monomorphized when calling type_id or type_name intrinsics. If the type is not sufficiently monomorphized, e.g. used in a pattern, the code will be rejected. Fixes #73976
2020-07-20mir: `unused_generic_params` queryDavid Wood-2/+2
This commit implements the `unused_generic_params` query, an initial version of polymorphization which detects when an item does not use generic parameters and is being needlessly monomorphized as a result. Signed-off-by: David Wood <david@davidtw.co>
2020-07-19Guard against non-monomorphized type_id intrinsic callGary Guo-2/+10
2020-07-18Rollup merge of #74459 - canova:const-unreachable-unchecked, r=oli-obkManish Goregaokar-0/+1
Make unreachable_unchecked a const fn This PR makes `std::hint::unreachable_unchecked` a const fn so we can use it inside a const function. r? @RalfJung Fixes #53188.
2020-07-17Make unreachable_unchecked a const fnNazım Can Altınova-0/+1
2020-07-17Rename TypeckTables to TypeckResults.Valentin Lazureanu-6/+4
2020-07-15update promoted_mirBastian Kauschke-5/+1
2020-07-15update const arg queriesBastian Kauschke-3/+3
2020-07-15const generics work!Bastian Kauschke-1/+5
2020-07-15continue mir pipelineBastian Kauschke-1/+5
2020-07-15InstanceDef::ItemBastian Kauschke-9/+11
2020-07-15ConstKind::UnevaluatedBastian Kauschke-2/+2
2020-07-10Avoid "whitelist"Tamir Duberstein-1/+1
Other terms are more inclusive and precise.
2020-07-05fmtRalf Jung-4/+9
2020-07-05catch errors more locally around read_discriminantRalf Jung-21/+40
2020-07-05catch InvalidUninitBytes during validationRalf Jung-5/+11
2020-07-02Rollup merge of #73684 - richkadel:llvm-coverage-map-gen-2, r=wesleywiserManish Goregaokar-1/+4
add spans to injected coverage counters, extract with CoverageData query This is the next iteration on the Rust Coverage implementation, and follows PR #73488 @tmandry @wesleywiser I came up with an approach for coverage spans, pushing them through the Call terminator as additional args so they can be extracted by the CoverageData query. I'm using an IndexVec to store them in CoverageData such that there can be only one per index (even if parts of the MIR get duplicated during optimization). If this approach works for you, I can quickly expand on this to build a separate IndexVec for counter expressions, using a separate call that will be ignored during code generation, but from which I can extract the counter expression values. Let me know your thoughts. Thanks! r? @tmandry Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-07-01Rollup merge of #73778 - nbdd0121:const_likely, r=oli-obkManish Goregaokar-0/+4
Make `likely` and `unlikely` const, gated by feature `const_unlikely` This PR also contains a fix to allow `#[allow_internal_unstable]` to work properly with `#[rustc_const_unstable]`. cc @RalfJung @nagisa r? @oli-obk
2020-06-29add spans to injected coverage countersRich Kadel-1/+4
added regions with counter expressions and counters. Added codegen_llvm/coverageinfo mod for upcoming coverage map Move coverage region collection to CodegenCx finalization Moved from `query coverageinfo` (renamed from `query coverage_data`), as discussed in the PR at: https://github.com/rust-lang/rust/pull/73684#issuecomment-649882503 Address merge conflict in MIR instrument_coverage test The MIR test output format changed for int types. moved debug messages out of block.rs This makes the block.rs calls to add coverage mapping data to the CodegenCx much more concise and readable. move coverage intrinsic handling into llvm impl I realized that having half of the coverage intrinsic handling in `rustc_codegen_ssa` and half in `rustc_codegen_llvm` meant that any non-llvm backend would be bound to the same decisions about how the coverage-related MIR terminators should be handled. To fix this, I moved the non-codegen portion of coverage intrinsic handling into its own trait, and implemented it in `rustc_codegen_llvm` alongside `codegen_intrinsic_call`. I also added the (required?) stubs for the new intrinsics to `IntrepretCx::emulate_intrinsic()`, to ensure calls to this function do not fail if called with these new but known intrinsics. address PR Feedback on 28 June 2020 2:48pm PDT
2020-06-28Rollup merge of #73757 - oli-obk:const_prop_hardening, r=wesleywiserManish Goregaokar-5/+33
Const prop: erase all block-only locals at the end of every block I messed up this erasure in https://github.com/rust-lang/rust/pull/73656#discussion_r446040140. I think it is too fragile to have the previous scheme. Let's benchmark the new scheme and see what happens. r? @wesleywiser cc @felix91gr
2020-06-28Erase all block-only locals at the end of every block, even if they have not ↵Oliver Scherer-5/+33
been touched.
2020-06-27Rollup merge of #72796 - RalfJung:mir-assign-sanity, r=matthewjasperManish Goregaokar-39/+29
MIR sanity check: validate types on assignment This expands the MIR validation added by @jonas-schievink in https://github.com/rust-lang/rust/pull/72093 to also check that on an assignment, the types of both sides match. Cc @eddyb @oli-obk
2020-06-27Update src/librustc_mir/interpret/intrinsics.rsGary Guo-2/+1
Co-authored-by: Oliver Scherer <github35764891676564198441@oli-obk.de>
2020-06-26Make `likely` and `unlikely` constGary Guo-0/+5
They are gated by internal feature gate const_likely
2020-06-26Show the values and computation that would overflow a const evaluation or ↵Oliver Scherer-1/+14
propagation
2020-06-24Implement intrinsicNathan Corbyn-2/+12
2020-06-24reduce sanity check in debug modeRalf Jung-2/+8
2020-06-23Auto merge of #73643 - Manishearth:rollup-68dr8fz, r=Manishearthbors-0/+5
Rollup of 9 pull requests Successful merges: - #72271 (Improve compiler error message for wrong generic parameter order) - #72493 ( move leak-check to during coherence, candidate eval) - #73398 (A way forward for pointer equality in const eval) - #73472 (Clean up E0689 explanation) - #73496 (Account for multiple impl/dyn Trait in return type when suggesting `'_`) - #73515 (Add second message for LiveDrop errors) - #73567 (Clarify --extern documentation.) - #73572 (Fix typos in doc comments) - #73590 (bootstrap: no `config.toml` exists regression) Failed merges: r? @ghost
2020-06-23Rollup merge of #73398 - oli-obk:const_raw_ptr_cmp, r=varkor,RalfJung,nagisaManish Goregaokar-0/+5
A way forward for pointer equality in const eval r? @varkor on the first commit and @RalfJung on the second commit cc #53020
2020-06-23Rollup merge of #73586 - RalfJung:switch-ty, r=oli-obkDylan DPC-9/+3
switch_ty is redundant This field is redundant, but we cannot remove it currently as pretty-printing relies on it (and it does not have access to `mir::Body` to compute the type itself). Cc @oli-obk @matthewjasper @jonas-schievink
2020-06-23Rollup merge of #73578 - RalfJung:ty-ctxt-at, r=jonas-schievinkDylan DPC-2/+2
Make is_freeze and is_copy_modulo_regions take TyCtxtAt Make is_freeze and is_copy_modulo_regions take TyCtxtAt instead of separately taking TyCtxt and Span. This is consistent with is_sized.
2020-06-22make layout check a mere sanity checkRalf Jung-18/+7
2020-06-22expand a commentRalf Jung-1/+3
2020-06-22also use relator in interpreter assignment sanity checkRalf Jung-29/+21
2020-06-22also normalize constants when comparing typesRalf Jung-0/+1
2020-06-21fmtRalf Jung-8/+1
2020-06-21remove switch_ty reliance in codegenRalf Jung-2/+3
2020-06-21Miri: replace many bug! by span_bug!Ralf Jung-28/+61
2020-06-21Make is_freeze and is_copy_modulo_regions take TyCtxtAtRalf Jung-2/+2
2020-06-19Add fuzzy pointer comparison intrinsicsOliver Scherer-0/+5
2020-06-19Rollup merge of #73011 - richkadel:llvm-count-from-mir-pass, r=tmandryRalf Jung-0/+2
first stage of implementing LLVM code coverage This PR replaces #70680 (WIP toward LLVM Code Coverage for Rust) since I am re-implementing the Rust LLVM code coverage feature in a different part of the compiler (in MIR pass(es) vs AST). This PR updates rustc with `-Zinstrument-coverage` option that injects the llvm intrinsic `instrprof.increment()` for code generation. This initial version only injects counters at the top of each function, and does not yet implement the required coverage map. Upcoming PRs will add the coverage map, and add more counters and/or counter expressions for each conditional code branch. Rust compiler MCP https://github.com/rust-lang/compiler-team/issues/278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation ***[I put together some development notes here, under a separate branch.](https://github.com/richkadel/rust/blob/cfa0b21d34ee64e4ebee226101bd2ef0c6757865/src/test/codegen/coverage-experiments/README-THIS-IS-TEMPORARY.md)***
2020-06-19Rollup merge of #73130 - wesleywiser:remove_const_prop_for_indirects, r=oli-obkRalf Jung-6/+6
Remove const prop for indirects This was only used by one mir-opt test and since it causes buggy behavior under `-Zmir-opt-level=2`, it seems like we should remove it. This was split out from #71946. Closes #72679 Closes #72372 Closes #72285
2020-06-19Rollup merge of #72497 - RalfJung:tag-term, r=oli-obkRalf Jung-44/+42
tag/niche terminology cleanup The term "discriminant" was used in two ways throughout the compiler: * every enum variant has a corresponding discriminant, that can be given explicitly with `Variant = N`. * that discriminant is then encoded in memory to store which variant is active -- but this encoded form of the discriminant was also often called "discriminant", even though it is conceptually quite different (e.g., it can be smaller in size, or even use niche-filling). After discussion with @eddyb, this renames the second term to "tag". The way the tag is encoded can be either `TagEncoding::Direct` (formerly `DiscriminantKind::Tag`) or `TagEncoding::Niche` (formerly `DiscrimianntKind::Niche`). This finally resolves some long-standing confusion I had about the handling of variant indices and discriminants, which surfaced in https://github.com/rust-lang/rust/pull/72419. (There is also a `DiscriminantKind` type in libcore, it remains unaffected. I think this corresponds to the discriminant, not the tag, so that seems all right.) r? @eddyb
2020-06-18Rollup merge of #72814 - RalfJung:mir-visir-terminator, r=oli-obkManish Goregaokar-3/+3
remove visit_terminator_kind from MIR visitor For some reason, we had both `visit_terminator` and `visit_terminator_kind`. In contrast, for `Statement` we just have `visit_statement`. So this cleans things up by removing `visit_terminator_kind` and porting its users to `visit_terminator`.
2020-06-16rename location field of Drop terminators to placeRalf Jung-3/+3
2020-06-15added test, Operand::const_from_scalar, require_lang_item, & commentsRich Kadel-0/+1
Addresses feedback from @oli-obk (Thanks!)
2020-06-15moved to post_borrowck_cleanup & used MirPatchRich Kadel-0/+1
2020-06-15Add case for count_code_region() extern lang_itemRich Kadel-3/+0
As suggested in PR feedback: https://github.com/rust-lang/rust/pull/73011#discussion_r435728923 This allows count_code_region() to be handled like a normal intrinsic so the InstanceDef::InjectedCode variant is no longer needed.
2020-06-15[WIP] injects llvm intrinsic instrprof.increment for coverage reportsRich Kadel-0/+3
This initial version only injects counters at the top of each function. Rust Coverage will require injecting additional counters at each conditional code branch.
2020-06-15make all uses of ty::Error or ConstKind::Error delay a span bugmark-3/+3