Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #127777

Merged
merged 21 commits into from
Jul 15, 2024
Merged

Rollup of 6 pull requests #127777

merged 21 commits into from
Jul 15, 2024

Commits on Jul 6, 2024

  1. Configuration menu
    Copy the full SHA
    f6c377c View commit details
    Browse the repository at this point in the history

Commits on Jul 12, 2024

  1. Make parse error suggestions verbose and fix spans

    Go over all structured parser suggestions and make them verbose style.
    
    When suggesting to add or remove delimiters, turn them into multiple suggestion parts.
    estebank committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    692bc34 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c2b3287 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    dd40e0b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b5f94c6 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    377d14b View commit details
    Browse the repository at this point in the history
  6. fix unused binding

    estebank committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    b6f5188 View commit details
    Browse the repository at this point in the history
  7. Make ; suggestions inline

    estebank committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    71f16bd View commit details
    Browse the repository at this point in the history

Commits on Jul 13, 2024

  1. Configuration menu
    Copy the full SHA
    90c9e32 View commit details
    Browse the repository at this point in the history

Commits on Jul 14, 2024

  1. Configuration menu
    Copy the full SHA
    dc20733 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f08c43a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    80393ea View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f18d4a8 View commit details
    Browse the repository at this point in the history

Commits on Jul 15, 2024

  1. coverage: Store a copy of num_bcbs in ExtractedMappings

    This makes it possible to allocate per-BCB data structures without needing
    access to the whole graph.
    Zalathar committed Jul 15, 2024
    Configuration menu
    Copy the full SHA
    741ed01 View commit details
    Browse the repository at this point in the history
  2. coverage: Restrict ExpressionUsed simplification to Code mappings

    In the future, branch and MC/DC mappings might have expressions that don't
    correspond to any single point in the control-flow graph. That makes it
    trickier to keep track of which expressions should expect an `ExpressionUsed`
    node.
    
    We therefore sidestep that complexity by only performing `ExpressionUsed`
    simplification for expressions associated directly with ordinary `Code`
    mappings.
    Zalathar committed Jul 15, 2024
    Configuration menu
    Copy the full SHA
    d4f1f92 View commit details
    Browse the repository at this point in the history
  3. Rollup merge of rust-lang#124921 - RalfJung:offset-from-same-addr, r=…

    …oli-obk
    
    offset_from: always allow pointers to point to the same address
    
    This PR implements the last remaining part of the t-opsem consensus in rust-lang/unsafe-code-guidelines#472: always permits offset_from when both pointers have the same address, no matter how they are computed. This is required to achieve *provenance monotonicity*.
    
    Tracking issue: rust-lang#117945
    
    ### What is provenance monotonicity and why does it matter?
    
    Provenance monotonicity is the property that adding arbitrary provenance to any no-provenance pointer must never make the program UB. More specifically, in the program state, data in memory is stored as a sequence of [abstract bytes](https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#abstract-byte), where each byte can optionally carry provenance. When a pointer is stored in memory, all of the bytes it is stored in carry that provenance. Provenance monotonicity means: if we take some byte that does not have provenance, and give it some arbitrary provenance, then that cannot change program behavior or introduce UB into a UB-free program.
    
    We care about provenance monotonicity because we want to allow the optimizer to remove provenance-stripping operations. Removing a provenance-stripping operation effectively means the program after the optimization has provenance where the program before the optimization did not -- since the provenance removal does not happen in the optimized program. IOW, the compiler transformation added provenance to previously provenance-free bytes. This is exactly what provenance monotonicity lets us do.
    
    We care about removing provenance-stripping operations because `*ptr = *ptr` is, in general, (likely) a provenance-stripping operation. Specifically, consider `ptr: *mut usize` (or any integer type), and imagine the data at `*ptr` is actually a pointer (i.e., we are type-punning between pointers and integers). Then `*ptr` on the right-hand side evaluates to the data in memory *without* any provenance (because [integers do not have provenance](https://rust-lang.github.io/rfcs/3559-rust-has-provenance.html#integers-do-not-have-provenance)). Storing that back to `*ptr` means that the abstract bytes `ptr` points to are the same as before, except their provenance is now gone. This makes  `*ptr = *ptr`  a provenance-stripping operation  (Here we assume `*ptr` is fully initialized. If it is not initialized, evaluating `*ptr` to a value is UB, so removing `*ptr = *ptr` is trivially correct.)
    
    ### What does `offset_from` have to do with provenance monotonicity?
    
    With `ptr = without_provenance(N)`, `ptr.offset_from(ptr)` is always well-defined and returns 0. By provenance monotonicity, I can now add provenance to the two arguments of `offset_from` and it must still be well-defined. Crucially, I can add *different* provenance to the two arguments, and it must still be well-defined. In other words, this must always be allowed: `ptr1.with_addr(N).offset_from(ptr2.with_addr(N))` (and it returns 0). But the current spec for `offset_from` says that the two pointers must either both be derived from an integer or both be derived from the same allocation, which is not in general true for arbitrary `ptr1`, `ptr2`.
    
    To obtain provenance monotonicity, this PR hence changes the spec for offset_from to say that if both pointers have the same address, the function is always well-defined.
    
    ### What further consequences does this have?
    
    It means the compiler can no longer transform `end2 = begin.offset(end.offset_from(begin))` into `end2 = end`. However, it can still be transformed into `end2 = begin.with_addr(end.addr())`, which later parts of the backend (when provenance has been erased) can trivially turn into `end2 = end`.
    
    The only alternative I am aware of is a fundamentally different handling of zero-sized accesses, where a "no provenance" pointer is not allowed to do zero-sized accesses and instead we have a special provenance that indicates "may be used for zero-sized accesses (and nothing else)". `offset` and `offset_from` would then always be UB on a "no provenance" pointer, and permit zero-sized offsets on a "zero-sized provenance" pointer. This achieves provenance monotonicity. That is, however, a breaking change as it contradicts what we landed in rust-lang#117329. It's also a whole bunch of extra UB, which doesn't seem worth it just to achieve that transformation.
    
    ### What about the backend?
    
    LLVM currently doesn't have an intrinsic for pointer difference, so we anyway cast to integer and subtract there. That's never UB so it is compatible with any relaxation we may want to apply.
    
    If LLVM gets a `ptrsub` in the future, then plausibly it will be consistent with `ptradd` and [consider two equal pointers to be inbounds](rust-lang#124921 (comment)).
    matthiaskrgr authored Jul 15, 2024
    Configuration menu
    Copy the full SHA
    78529d9 View commit details
    Browse the repository at this point in the history
  4. Rollup merge of rust-lang#127407 - estebank:parser-suggestions, r=oli…

    …-obk
    
    Make parse error suggestions verbose and fix spans
    
    Go over all structured parser suggestions and make them verbose style.
    
    When suggesting to add or remove delimiters, turn them into multiple suggestion parts.
    matthiaskrgr authored Jul 15, 2024
    Configuration menu
    Copy the full SHA
    2b82729 View commit details
    Browse the repository at this point in the history
  5. Rollup merge of rust-lang#127684 - RalfJung:unleashed-mutable-refs, r…

    …=oli-obk
    
    consolidate miri-unleashed tests for mutable refs into one file
    
    r? ```@oli-obk```
    matthiaskrgr authored Jul 15, 2024
    Configuration menu
    Copy the full SHA
    4f9b598 View commit details
    Browse the repository at this point in the history
  6. Rollup merge of rust-lang#127729 - compiler-errors:ed-2024-gen, r=oli…

    …-obk
    
    Stop using the `gen` identifier in the compiler
    
    In preparation for edition 2024, this PR previews the fallout of removing usages of `gen` since it's being reserved as a keyword.
    
    There are two notable changes here:
    1. Had to rename `fn gen(..)` in gen/kill analysis to `gen_`. Not certain there's a better name than that.
    2. There are (false?[^1]) positives in `rustc_macros` when using synstructure, which uses `gen impl` to mark an implementation. We could suppress this in a one-off way, or perhaps just ignore `gen` in macros altogether, since if an identifier ends up in expanded code then it'll get properly denied anyways.
    
    Not relevant to the compiler, but it's gonna be really annoying to change `rand`'s `gen` fn in the library and miri...
    
    [^1]: I haven't looked at the synstructure proc macro code itself so I'm not certain if it'll start to fail when converted to ed2024 (or, e.g., when syn starts parsing `gen` as a kw).
    matthiaskrgr authored Jul 15, 2024
    Configuration menu
    Copy the full SHA
    3f13562 View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#127736 - tgross35:patch-1, r=Amanieu

    Add myself to the review rotation
    matthiaskrgr authored Jul 15, 2024
    Configuration menu
    Copy the full SHA
    cd25232 View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#127758 - Zalathar:expression-used, r=oli-obk

    coverage: Restrict `ExpressionUsed` simplification to `Code` mappings
    
    In the future, branch and MC/DC mappings might have expressions that don't correspond to any single point in the control-flow graph. That makes it trickier to keep track of which expressions should expect an `ExpressionUsed` node.
    
    We therefore sidestep that complexity by only performing `ExpressionUsed` simplification for expressions associated directly with ordinary `Code` mappings.
    
    (This simplification step is inherited from the original coverage implementation, which only supported `Code` mappings anyway, so there's no particular reason to extend it to other kinds of mappings unless we specifically choose to.)
    
    Relevant to:
    - rust-lang#124154
    - rust-lang#126677
    - rust-lang#124278
    
    ```@rustbot``` label +A-code-coverage
    matthiaskrgr authored Jul 15, 2024
    Configuration menu
    Copy the full SHA
    e5d65e4 View commit details
    Browse the repository at this point in the history