Skip to content

[SandboxIR][Utils] Implement getMemoryLocation() #109724

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

Merged
merged 1 commit into from
Sep 25, 2024
Merged

Conversation

vporpo
Copy link
Contributor

@vporpo vporpo commented Sep 23, 2024

This patch implements sandboxir::Utils::getMemoryLocation() that calls MemoryLocation::getOrNone() internally.
Ideally this would require a sandboxir::MemoryLocation, but this should be good enough for now.

@vporpo
Copy link
Contributor Author

vporpo commented Sep 25, 2024

ping

Copy link
Contributor

@Sterling-Augustine Sterling-Augustine left a comment

Choose a reason for hiding this comment

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

Looks good with one small comment about naming.

if (BB.getName() == Name)
return &BB;
llvm_unreachable("Expected to find basic block!");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably refactor the parseIR/getBasicBlockByName boilerplate into something common for the entire SandboxVectorizer. Every test file duplicates it. But that is a problem for the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that needs to be refactored at some point.


/// Equivalent to MemoryLocation::getOrNone(I).
static std::optional<llvm::MemoryLocation>
getMemoryLocation(const Instruction *I) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not match the name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something like memoryLocationGetOrNone() ?

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 that makes it clearer. In my opinion, the closer we match the LLVM IR name, the easier it is to reason about.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

This patch implements sandboxir::Utils::getMemoryLocation() that calls
MemoryLocation::getOrNone() internally.
Ideally this would require a sandboxir::MemoryLocation, but this should
be good enough for now.
@vporpo vporpo merged commit eba21ac into llvm:main Sep 25, 2024
5 of 7 checks passed
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