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

Better document Direct/Indirect locations. #1538

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ptersilie
Copy link
Contributor

While we are here add an assertion that's been on my mind and is loosely related to direct locations.

@ltratt I'm not sure if you wanted more documentation here, but my mind is blank. So please let me know if you think there's more that can be added here.

yksmp/src/lib.rs Outdated
/// dereferencing LLVM just records the value as an (offset, register) pair where the register
/// is typically the base pointer:
/// * `u16`: Dwarf register number
/// The live variable's value is a pointer that point into the stack. Pointer values may be
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the first sentence is sort-of correct, but it's also what has led both of us up the garden path.

I think the first thing to do is to put Indirect before Direct in the enum, since Indirect is the general case. Then Direct can say something like "Direct is an optimisation for those Indirect values that are themselves pointers to things on the stack. In other words, if an Indirect value is a pointer, then we can skip a dereference, and turn that Indirect into a Direct". [That's not very good, but hopefully you get the idea!]

I also think that one more more examples -- even brief sketches -- will help. The problem here is that it's really easy to misread what "pointer of pointer" and "value" and whatnot are. Thanks to your explanation yesterday, I (think I) now understand, but without that, I don't think the text here would quite be enough to kick my brain in the right direction.

yksmp/src/lib.rs Outdated
/// out the value the address described by the (offset, register) pair needs to be dereferenced
/// first.
/// The live variable lives on the stack. It may have been put there directly via an `alloca`
/// or has been spilled. Similar to `Direct`, the location is encoded as an offset relative to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would drop "similar to Direct" because Indirect is the general case.

@ltratt
Copy link
Contributor

ltratt commented Jan 8, 2025

Please force push updates if you think it sensible based on my questions / comments.

@ptersilie
Copy link
Contributor Author

Try this!

@ltratt
Copy link
Contributor

ltratt commented Jan 8, 2025

Perfect, thanks!

@ltratt ltratt added this pull request to the merge queue Jan 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 9, 2025
@vext01 vext01 added this pull request to the merge queue Jan 13, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants