Santiago Pastorino
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
--- tags: mir, rustc --- # MIR 2.0 to-do list ## To-do list ideas General plan: 1. Decide on whether to use virtual locals or to make borrowck more powerful https://github.com/rust-lang/rust/issues/71265 2. ### Space optimizations and minor tweaks - intern entire places at the MIR level - interning `(base, Vec<projection>)` means less re-use overall though - nice hack: rfirst 128 (eddyb suggests 2^16) locals or so can be mapped to themselves - could even be extended for whatever the most common projections are if that proves useful - insert gratuitous reference to random compression methods here - intern the `Vec<Projection>` to a per-MIR integer (unlikely to be the first first step) - maybe we can retain `MutVisitor` in its current design if MIR still owns the `Projection` arrays - maybe an interesting intermediate step to start from, as it removes one of the challenges, and just leaves us with construction - but it comes with its *own* challenges, like now you can't just take a `Place` and get its data without a MIR (you have to do `mir.projection_data(index)`) - Other interning alternatives like interning both projection and place? ### Improving the "ergonomics" of MIR - Making MIR more readily mutated - Avoiding vectors and indices in favor of linked lists and persistent identifiers - can we remove the need for MIR patch and/or simplify it? - Merging optimizations, particularly peephole ones - Can we have only a single visitor pass? - Transactional MIR modifications (requires more design) - We can find a general solution where instead of modifying the MIR, you register a list of modifications and the compiler applies them after you have specified them all - Isn't this`MirPatch`? - The alternative is to not have indices and invent some other scheme, that was also discussed - "Better" fix temporaries that lives across a yield - https://github.com/rust-lang/rust/issues/67611#issuecomment-577755476 ### Specific optimizations - MIR inlining ### Extending MIR to better support optimizations - Remove `Deref` and `Index` from the list of projections - observation: today's *places* are complex to reason about for optimizations and could be lower level - if would be nice to simplify `&mut *(*foo.bar).baz` for example into smaller operations - however: they were made to match borrowck, and we can't just introduce things like `let tmp0 = &mut *foo.bar` because it will cause new errors - there have been various threads about it where you can read up on more details: - [There was a thread about it](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Deref.20is.20not.20a.20projection), but got derailed into different projection representations. - last "known good" position was [here](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Deref.20is.20not.20a.20projection/near/177271588), which links to [this dropbox](https://paper.dropbox.com/doc/Proposal-Deref-is-not-a-Projection--Ap8a1WNdiHeXB93K7dzWqIQGAg-aGnvFEPxejaDOXWDvfcf0) - one scheme would be to introduce - create a “pseudo-reborrow” `Rvalue` (or maybe an `Operand`?) which just takes a place - this means what was `(*foo.bar).boo` now becomes `let tmp = &*foo.bar; tmp.boo` - We can try out a compiler flag that makes mir building generate an intermediate temporary - We need to check borrowck and miri :) - [nikomatsakis describes one scheme around here](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/2020.2E01.2E07.20MIR.202.2E0.20meeting/near/185022107): I guess then that x = &*(*tmp.bar).baz would be something like ``` P0 = LOAD(tmp.bar) // P0 is a "place temporary", meaning that it is a pointer effectively P1 = LOAD(P0.baz) X = &P1 ``` - and borrowck would understand that (e.g.) tmp.bar was not borrowed - nikomatsakis: in some ways this might simplify borrowck, since right now I think we have to figure out which loads and other accesses occur as part of a borrow.. maybe? that maybe just falls out. nikomatsakis: anyway, I think we should table these details and turn back to the higher level questions? - Remove `Index` from the list of projections - The `Local` field for the actual index is slightly inconvenient - Add an `Option<Local>` field to `Rvalue::Ref` - Later refactor the `Local` to `Operand` - Remove `field` from Projection - essentially eliminate `Projection`s entirely from places - instead we'd have `Projection`+`Ref` `Rvalue`s that create a new local which is a pointer to the projected to place - Formalizing out parameters (or args passed by pointer because they are too large) - in other words, make it possible for MIR to express writing return values directly into the caller frame - see also [notes on NRVO here](https://paper.dropbox.com/doc/Topic-MIR-2.0-and-MIR-Optimizations--Ar_DezRvHY6zSzu1gCqSwicbAg-BwHR7kOhxDwL6vuAUoSTQ#:uid=104340020150096374938901&h2=NRVO-Discussion) ## Cleanups - [x] Make Local Copy - [#68512](https://github.com/rust-lang/rust/pull/68512) - [x] Make PlaceRef take just one lifetime - [#69714](https://github.com/rust-lang/rust/pull/69714) - [x] Make Operand Copy - [x] Use place directly its copy - [#70627](https://github.com/rust-lang/rust/pull/70627) - [x] Local is Copy we can pass it by value in these cases - [#69787](https://github.com/rust-lang/rust/pull/69787) - [x] Replace fragile erroneous const sys - [#70820](https://github.com/rust-lang/rust/pull/70820) - [ ] Tidy up Visitors - Now that there's no more base, just local a lot of things can be made simpler - Remove weird macro related to visit_place_projection - Remove cow on visitor - visit_place_base is just visit_local [#71401](https://github.com/rust-lang/rust/pull/71401) - [ ] Remove PlaceRef - [ ] Match on self.projection (comment from oli) - [ ] Make a pattern to iterate over projection - [ ] Do we need ProjectionElem or are we ok with just PlaceElem - Today ProjectionElem is a generic and there are two concrete structures that use that PlaceElem and ProjectionKind. Unsure if after some changes we want to revisit this. not sure, I think we may want to make places not have a list of projections, and instead just refer to a local so... niko has this idea where we have virtual locals so you can do _virt1 = _1.foo, which does not read from the foo field but it it makes _virt1 refer to that field now there was a problem he posted just yesterday I think where borrowck allows some fancy things around projection overlap https://github.com/rust-lang/rust/issues/71265 ## Documents from previous all hands * https://paper.dropbox.com/doc/Topic-MIR-2.0-and-MIR-Optimizations--Ar_DezRvHY6zSzu1gCqSwicbAg-BwHR7kOhxDwL6vuAUoSTQ * https://paper.dropbox.com/doc/Place-2.0-current-PR-status--Ar9Gy9RgX1sOhirE3w93~hSnAg-vmbnFv8VkCEuL57QfWWMH

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully