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

Add regalloc2-tool #148

Merged
merged 1 commit into from
Jul 12, 2023
Merged

Add regalloc2-tool #148

merged 1 commit into from
Jul 12, 2023

Conversation

Amanieu
Copy link
Contributor

@Amanieu Amanieu commented Jul 12, 2023

This PR has 2 components:

  • A SerializableFunction which wraps a Function and MachineEnv. This type can be serialized and deserialized with Serde, and is enabled by the "enable-serde" feature.
  • A regalloc2-tool binary which reads a bincode-encoded SerializableFunction and then runs the register allocator and checker on it.

This is a useful tool for debugging register allocation failures and to investigate cases of poor register allocation.

@Amanieu
Copy link
Contributor Author

Amanieu commented Jul 12, 2023

Here is an example of the output of this tool with the -v option which prints the function before and after register allocation. Note that this example is based on #131 since it requires 128 integer pregs.

Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

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

Thanks a bunch -- this will be really useful to have!

let mut checker = Checker::new(&function, function.machine_env());
checker.prepare(&output);
if let Err(e) = checker.run() {
panic!("Regsiter allocation checker failed: {e:#?}");
Copy link
Member

Choose a reason for hiding this comment

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

s/Regsiter/Register/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

impl SerializableFunction {
/// Creates a new `SerializableFunction` from an arbitray `Function` and
/// `MachineEnv`.
pub fn new(func: &impl Function, machine_env: MachineEnv) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

Should the second arg be a &MachineEnv? Alternately, no clone two lines below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the clone.

deny.toml Show resolved Hide resolved
This PR has 2 components:
- A `SerializableFunction` which wraps a `Function` and `MachineEnv`.
This type can be serialized and deserialized with Serde, and is enabled
by the "enable-serde" feature.
- A `regalloc2-tool` binary which reads a bincode-encoded
`SerializableFunction` and then runs the register allocator and checker
on it.

This is a useful tool for debugging register allocation failures and to
investigate cases of poor register allocation.
@cfallin cfallin merged commit 24c0517 into bytecodealliance:main Jul 12, 2023
@Amanieu Amanieu deleted the regalloc2-tool branch November 24, 2023 08:47
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