Find a file
bors e32ea4822b Auto merge of #126541 - scottmcm:more-ptr-metadata-gvn, r=cjgillot
More ptr metadata gvn

There's basically 3 parts to this PR.

1. Allow references as arguments to `UnOp::PtrMetadata`

This is a MIR semantics addition, so
r? mir

Rather than just raw pointers, also allow references to be passed to `PtrMetadata`.  That means the length of a slice can be just `PtrMetadata(_1)` instead of also needing a ref-to-pointer statement (`_2 = &raw *_1` + `PtrMetadata(_2)`).

AFAIK there should be no provenance or tagging implications of looking at the *metadata* of a pointer, and the code in the backends actually already supported it (other than a debug assert, given that they don't care about ptr vs reference, really), so we might as well allow it.

2. Simplify the argument to `PtrMetadata` in GVN

Because the specific kind of pointer-like thing isn't that important, GVN can simplify all those details away.  Things like `*const`-to-`*mut` casts and `&mut`-to-`&` reborrows are irrelevant, and skipping them lets it see more interesting things.

cc `@cjgillot`

Notably, unsizing casts for arrays.  GVN supported that for `Len`, and now it sees it for `PtrMetadata` as well, allowing `PtrMetadata(pointer)` to become a constant if that pointer came from an array-to-slice unsizing, even through a bunch of other possible steps.

3. Replace `NormalizeArrayLen` with GVN

The `NormalizeArrayLen` pass hasn't been running even in optimized builds for well over a year, and it turns out that GVN -- which *is* on in optimized builds -- can do everything it was trying to do.

So the code for the pass is deleted, but the tests are kept, just changed to the different pass.

As part of this, `LowerSliceLen` was changed to emit `PtrMetadata(_1)` instead of `Len(*_1)`, a small step on the road to eventually eliminating `Rvalue::Len`.
2024-06-21 07:12:50 +00:00
.github make bors ignore comments in PR template 2024-06-14 21:52:25 +00:00
.reuse
compiler Auto merge of #126541 - scottmcm:more-ptr-metadata-gvn, r=cjgillot 2024-06-21 07:12:50 +00:00
library [GVN] Add tests for generic pointees with PtrMetadata 2024-06-20 22:16:59 -07:00
LICENSES
src Auto merge of #124032 - Voultapher:a-new-sort, r=thomcc 2024-06-20 20:40:43 +00:00
tests Auto merge of #126541 - scottmcm:more-ptr-metadata-gvn, r=cjgillot 2024-06-21 07:12:50 +00:00
.editorconfig
.git-blame-ignore-revs
.gitattributes
.gitignore Add /rustc-ice*/ to .gitignore` 2024-06-17 23:00:33 -05:00
.gitmodules
.mailmap .mailmap: Associate both my work and my private email with me 2024-06-15 09:27:39 +02:00
Cargo.lock Rollup merge of #126636 - tgross35:clippy-f16-f128-fixme, r=flip1995 2024-06-20 14:07:01 +02:00
Cargo.toml Remove src/tools/rust-demangler 2024-06-19 20:41:34 +10:00
CODE_OF_CONDUCT.md
config.example.toml Remove src/tools/rust-demangler 2024-06-19 20:41:34 +10:00
configure
CONTRIBUTING.md
COPYRIGHT
INSTALL.md
LICENSE-APACHE
LICENSE-MIT
README.md
RELEASES.md Rollup merge of #126250 - epage:change, r=Mark-Simulacrum 2024-06-17 04:53:55 +01:00
rust-bors.toml
rustfmt.toml
triagebot.toml
x
x.ps1
x.py

This is the main source code repository for Rust. It contains the compiler, standard library, and documentation.

Why Rust?

  • Performance: Fast and memory-efficient, suitable for critical services, embedded devices, and easily integrate with other languages.

  • Reliability: Our rich type system and ownership model ensure memory and thread safety, reducing bugs at compile-time.

  • Productivity: Comprehensive documentation, a compiler committed to providing great diagnostics, and advanced tooling including package manager and build tool (Cargo), auto-formatter (rustfmt), linter (Clippy) and editor support (rust-analyzer).

Quick Start

Read "Installation" from The Book.

Installing from Source

If you really want to install from source (though this is not recommended), see INSTALL.md.

Getting Help

See https://www.rust-lang.org/community for a list of chat platforms and forums.

Contributing

See CONTRIBUTING.md.

License

Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.

Trademark

The Rust Foundation owns and protects the Rust and Cargo trademarks and logos (the "Rust Trademarks").

If you want to use these names or brands, please read the media guide.

Third-party logos may be subject to third-party copyrights and trademarks. See Licenses for details.