mach backend: allow snapshotting IR graphs with the SNAPSHOT_REGALLOC env variable;
This also requires the serde feature, which isn't enabled by default, thus it must be passed as a command-line argument to cargo.
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -368,6 +368,7 @@ dependencies = [
|
|||||||
name = "cranelift-codegen"
|
name = "cranelift-codegen"
|
||||||
version = "0.64.0"
|
version = "0.64.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"bincode",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"cranelift-bforest",
|
"cranelift-bforest",
|
||||||
"cranelift-codegen-meta",
|
"cranelift-codegen-meta",
|
||||||
@@ -1669,6 +1670,7 @@ checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
|
"serde",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ hashbrown = { version = "0.7", optional = true }
|
|||||||
target-lexicon = "0.10"
|
target-lexicon = "0.10"
|
||||||
log = { version = "0.4.6", default-features = false }
|
log = { version = "0.4.6", default-features = false }
|
||||||
serde = { version = "1.0.94", features = ["derive"], optional = true }
|
serde = { version = "1.0.94", features = ["derive"], optional = true }
|
||||||
|
bincode = { version = "1.2.1", optional = true }
|
||||||
gimli = { version = "0.21.0", default-features = false, features = ["write"], optional = true }
|
gimli = { version = "0.21.0", default-features = false, features = ["write"], optional = true }
|
||||||
smallvec = { version = "1.0.0" }
|
smallvec = { version = "1.0.0" }
|
||||||
thiserror = "1.0.4"
|
thiserror = "1.0.4"
|
||||||
@@ -74,6 +75,10 @@ all-arch = [
|
|||||||
# For dependent crates that want to serialize some parts of cranelift
|
# For dependent crates that want to serialize some parts of cranelift
|
||||||
enable-serde = ["serde"]
|
enable-serde = ["serde"]
|
||||||
|
|
||||||
|
# Allow snapshotting regalloc test cases. Useful only to report bad register
|
||||||
|
# allocation failures, or for regalloc.rs developers.
|
||||||
|
regalloc-snapshot = ["bincode", "regalloc/enable-serde"]
|
||||||
|
|
||||||
# Recompile our optimizations that are written in the `peepmatic` DSL into a
|
# Recompile our optimizations that are written in the `peepmatic` DSL into a
|
||||||
# compact finite-state transducer automaton.
|
# compact finite-state transducer automaton.
|
||||||
rebuild-peephole-optimizers = ["peepmatic"]
|
rebuild-peephole-optimizers = ["peepmatic"]
|
||||||
|
|||||||
@@ -44,6 +44,19 @@ where
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "regalloc-snapshot")]
|
||||||
|
{
|
||||||
|
use std::fs;
|
||||||
|
use std::path::Path;
|
||||||
|
if let Some(path) = std::env::var("SERIALIZE_REGALLOC").ok() {
|
||||||
|
let snapshot = regalloc::IRSnapshot::from_function(&vcode, b.reg_universe());
|
||||||
|
let serialized = bincode::serialize(&snapshot).expect("couldn't serialize snapshot");
|
||||||
|
|
||||||
|
let file_path = Path::new(&path).join(Path::new(&format!("ir{}.bin", f.name)));
|
||||||
|
fs::write(file_path, &serialized).expect("couldn't write IR snapshot file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let result = {
|
let result = {
|
||||||
let _tt = timing::regalloc();
|
let _tt = timing::regalloc();
|
||||||
allocate_registers_with_opts(
|
allocate_registers_with_opts(
|
||||||
|
|||||||
Reference in New Issue
Block a user