about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir
AgeCommit message (Collapse)AuthorLines
2023-11-03Auto merge of #117507 - nnethercote:rustc_span, r=Nilstriebbors-1/+1
`rustc_span` cleanups Just some things I found while looking over this crate. r? `@oli-obk`
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-1/+1
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-11-01Rename hook.Camille GILLOT-1/+1
2023-11-01Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiserbors-1/+1
Support enum variants in offset_of! This MR implements support for navigating through enum variants in `offset_of!`, placing the enum variant name in the second argument to `offset_of!`. The RFC placed it in the first argument, but I think it interacts better with nested field access in the second, as you can then write things like ```rust offset_of!(Type, field.Variant.field) ``` Alternatively, a syntactic distinction could be made between variants and fields (e.g. `field::Variant.field`) but I'm not convinced this would be helpful. [RFC 3308 # Enum Support](https://rust-lang.github.io/rfcs/3308-offset_of.html#enum-support-offset_ofsomeenumstructvariant-field_on_variant) Tracking Issue #106655.
2023-10-31Enums in offset_of: update based on est31, scottmcm & llogiq reviewGeorge Bateman-2/+2
2023-10-31Support enum variants in offset_of!George Bateman-2/+2
2023-10-31Turn const_caller_location from a query to a hookOli Scherer-2/+2
2023-10-31Do not ICE on constant evaluation failure in GVN.Camille GILLOT-2/+4
2023-10-30Auto merge of #117415 - matthiaskrgr:rollup-jr2p1t2, r=matthiaskrgrbors-2/+1
Rollup of 7 pull requests Successful merges: - #116862 (Detect when trait is implemented for type and suggest importing it) - #117389 (Some diagnostics improvements of `gen` blocks) - #117396 (Don't treat closures/coroutine types as part of the public API) - #117398 (Correctly handle nested or-patterns in exhaustiveness) - #117403 (Poison check_well_formed if method receivers are invalid to prevent typeck from running on it) - #117411 (Improve some diagnostics around `?Trait` bounds) - #117414 (Don't normalize to an un-revealed opaque when we hit the recursion limit) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-30Rollup merge of #117357 - tmiasko:terminate, r=wesleywiserGuillaume Gomez-1/+1
Rename a few remaining references to abort terminator Follow up to e3f2edc75bf2becb57d7d770bba20606da1c4224
2023-10-30Rollup merge of #117317 - RalfJung:track-caller, r=oli-obkGuillaume Gomez-0/+52
share some track_caller logic between interpret and codegen Also move the code that implements the track_caller intrinsics out of the core interpreter engine -- it's just a helper creating a const-allocation, doesn't need to be part of the interpreter core.
2023-10-30Add a custom panic message for resuming `gen` blocks after they panickedOli Scherer-2/+1
2023-10-29Auto merge of #116270 - cjgillot:gvn-aggregate, r=oli-obk,RalfJungbors-0/+50
See through aggregates in GVN This PR is extracted from https://github.com/rust-lang/rust/pull/111344 The first 2 commit are cleanups to avoid repeated work. I propose to stop removing useless assignments as part of this pass, and let a later `SimplifyLocals` do it. This makes tests easier to read (among others). The next 3 commits add a constant folding mechanism to the GVN pass, presented in https://github.com/rust-lang/rust/pull/116012. ~This pass is designed to only use global allocations, to avoid any risk of accidental modification of the stored state.~ The following commits implement opportunistic simplifications, in particular: - projections of aggregates: `MyStruct { x: a }.x` gets replaced by `a`, works with enums too; - projections of arrays: `[a, b][0]` becomes `a`; - projections of repeat expressions: `[a; N][x]` becomes `a`; - transform arrays of equal operands into a repeat rvalue. Fixes https://github.com/rust-lang/miri/issues/3090 r? `@oli-obk`
2023-10-29Rename a few remaining references to abort terminatorTomasz Miąsko-1/+1
Follow up to e3f2edc75bf2becb57d7d770bba20606da1c4224
2023-10-28share the track_caller handling within a mir::BodyRalf Jung-0/+34
2023-10-28interpret: call caller_location logic the same way codegen does, and share ↵Ralf Jung-0/+18
some code
2023-10-27Apply suggestions from code reviewCamille Gillot-4/+7
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-10-27Fuse `gen` blocksOli Scherer-2/+3
2023-10-27Basic generators workOli Scherer-2/+3
2023-10-26Add hir::GeneratorKind::GenOli Scherer-0/+10
2023-10-25Rename has_provance and tweaks comments.Camille GILLOT-8/+11
2023-10-25Valtrees for primitive types are fine.Camille GILLOT-2/+3
2023-10-25Complete comments.Camille GILLOT-8/+5
2023-10-25Disambiguate non-deterministic constants.Camille GILLOT-0/+34
2023-10-25Evaluate computed values to constants.Camille GILLOT-0/+12
2023-10-23Auto merge of #117103 - matthiaskrgr:rollup-96zuuom, r=matthiaskrgrbors-6/+6
Rollup of 6 pull requests Successful merges: - #107159 (rand use getrandom for freebsd (available since 12.x)) - #116859 (Make `ty::print::Printer` take `&mut self` instead of `self`) - #117046 (return unfixed len if pat has reported error) - #117070 (rustdoc: wrap Type with Box instead of Generics) - #117074 (Remove smir from triage and add me to stablemir) - #117086 (Update .mailmap to promote my livename) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-23Rollup merge of #116859 - Nilstrieb:more-more-funny-pretty-printers, r=oli-obkMatthias Krüger-6/+6
Make `ty::print::Printer` take `&mut self` instead of `self` based on #116815 This simplifies the code by removing all the `self` assignments and makes the flow of data clearer - always into the printer. Especially in v0 mangling, which already used `&mut self` in some places, it gets a lot more uniform.
2023-10-23Auto merge of #116033 - bvanjoi:fix-116032, r=petrochenkovbors-2/+0
report `unused_import` for empty reexports even it is pub Fixes #116032 An easy fix. r? `@petrochenkov` (Discovered this issue while reviewing #115993.)
2023-10-22use visibility to check unused imports and delete some stmtsbohan-2/+0
2023-10-21Make `ty::print::Printer` take `&mut self` instead of `self`Nilstrieb-6/+6
This simplifies the code by removing all the `self` assignments and makes the flow of data clearer - always into the printer. Especially in v0 mangling, which already used `&mut self` in some places, it gets a lot more uniform.
2023-10-21Implement JumpThreading pass.Camille GILLOT-0/+9
2023-10-20Rename `CoroutineKind::Gen` to `::Coroutine`Oli Scherer-4/+8
2023-10-20s/generator/coroutine/Oli Scherer-53/+53
2023-10-20s/Generator/Coroutine/Oli Scherer-54/+54
2023-10-18coverage: Explicitly note that counter/expression IDs are function-localZalathar-0/+10
2023-10-18coverage: Update docs for `StatementKind::Coverage`Zalathar-5/+10
This new description reflects the changes made in this PR, and should hopefully be more useful to non-coverage developers who need to care about coverage statements.
2023-10-18coverage: Store expression data in function coverage infoZalathar-21/+25
Even though expression details are now stored in the info structure, we still need to inject `ExpressionUsed` statements into MIR, because if one is missing during codegen then we know that it was optimized out and we can remap all of its associated code regions to zero.
2023-10-18coverage: Store all of a function's mappings in function coverage infoZalathar-17/+30
Previously, mappings were attached to individual coverage statements in MIR. That necessitated special handling in MIR optimizations to avoid deleting those statements, since otherwise codegen would be unable to reassemble the original list of mappings. With this change, a function's list of mappings is now attached to its MIR body, and survives intact even if individual statements are deleted by optimizations.
2023-10-18coverage: Collect a function's coverage mappings into a single listZalathar-0/+14
This is an intermediate step towards being able to store all of a function's mappings in function coverage info.
2023-10-18coverage: Rename `Operand` to `CovTerm`Zalathar-7/+9
Later patches in this PR will use `CovTerm` to represent things that are not expression operands.
2023-10-18coverage: Store the number of counters/expressions in function coverage infoZalathar-9/+17
Coverage codegen can now allocate arrays based on the number of counters/expressions originally used by the instrumentor. The existing query that inspects coverage statements is still used for determining the number of counters passed to `llvm.instrprof.increment`. If some high-numbered counters were removed by MIR optimizations, the instrumented binary can potentially use less memory and disk space at runtime.
2023-10-18coverage: Attach an optional `FunctionCoverageInfo` to `mir::Body`Zalathar-2/+20
This allows coverage information to be attached to the function as a whole when appropriate, instead of being smuggled through coverage statements in the function's basic blocks. As an example, this patch moves the `function_source_hash` value out of individual `CoverageKind::Counter` statements and into the per-function info. When synthesizing unused functions for coverage purposes, the absence of this info is taken to indicate that a function was not eligible for coverage and should not be synthesized.
2023-10-16Auto merge of #114330 - RalfJung:dagling-ptr-deref, r=oli-obkbors-22/+34
don't UB on dangling ptr deref, instead check inbounds on projections This implements https://github.com/rust-lang/reference/pull/1387 in Miri. See that PR for what the change is about. Detecting dangling references in `let x = &...;` is now done by validity checking only, so some tests need to have validity checking enabled. There is no longer inherently a "nodangle" check in evaluating the expression `&*ptr` (aside from the aliasing model). r? `@oli-obk` Based on: - https://github.com/rust-lang/reference/pull/1387 - https://github.com/rust-lang/rust/pull/115524
2023-10-16Auto merge of #116724 - RalfJung:alloc-bytes, r=oli-obkbors-13/+5
interpret: clean up AllocBytes Fixes https://github.com/rust-lang/miri/issues/2836 Nothing has moved here in half a year, so let's just remove these unused stubs -- they need a proper re-design anyway. r? `@oli-obk`
2023-10-15update MIR place semantics UB commentRalf Jung-12/+9
2023-10-15more precise error for 'based on misaligned pointer' caseRalf Jung-8/+18
2023-10-15place evaluation: require the original pointer to be aligned if an access ↵Ralf Jung-2/+9
happens
2023-10-15don't UB on dangling ptr deref, instead check inbounds on projectionsRalf Jung-2/+0
2023-10-14interpret: clean up AllocBytesRalf Jung-13/+5
2023-10-13Format all the let chains in compilerMichael Goulet-2/+6