Switch Cranelift over to regalloc2. (#3989)

This PR switches Cranelift over to the new register allocator, regalloc2.

See [this document](https://gist.github.com/cfallin/08553421a91f150254fe878f67301801)
for a summary of the design changes. This switchover has implications for
core VCode/MachInst types and the lowering pass.

Overall, this change brings improvements to both compile time and speed of
generated code (runtime), as reported in #3942:

```
Benchmark       Compilation (wallclock)     Execution (wallclock)
blake3-scalar   25% faster                  28% faster
blake3-simd     no diff                     no diff
meshoptimizer   19% faster                  17% faster
pulldown-cmark  17% faster                  no diff
bz2             15% faster                  no diff
SpiderMonkey,   21% faster                  2% faster
  fib(30)
clang.wasm      42% faster                  N/A
```
This commit is contained in:
Chris Fallin
2022-04-14 10:28:21 -07:00
committed by GitHub
parent bfae6384aa
commit a0318f36f0
181 changed files with 16887 additions and 21587 deletions

View File

@@ -1,12 +1,14 @@
//! Result and error types representing the outcome of compiling a function.
use regalloc2::checker::CheckerErrors;
use crate::verifier::VerifierErrors;
use std::string::String;
/// A compilation error.
///
/// When Cranelift fails to compile a function, it will return one of these error codes.
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug)]
pub enum CodegenError {
/// A list of IR verifier errors.
///
@@ -36,6 +38,9 @@ pub enum CodegenError {
/// A failure to map Cranelift register representation to a DWARF register representation.
#[cfg(feature = "unwind")]
RegisterMappingError(crate::isa::unwind::systemv::RegisterMappingError),
/// Register allocator internal error discovered by the symbolic checker.
Regalloc(CheckerErrors),
}
/// A convenient alias for a `Result` that uses `CodegenError` as the error type.
@@ -52,6 +57,7 @@ impl std::error::Error for CodegenError {
| CodegenError::Unsupported { .. } => None,
#[cfg(feature = "unwind")]
CodegenError::RegisterMappingError { .. } => None,
CodegenError::Regalloc(..) => None,
}
}
}
@@ -65,6 +71,7 @@ impl std::fmt::Display for CodegenError {
CodegenError::Unsupported(feature) => write!(f, "Unsupported feature: {}", feature),
#[cfg(feature = "unwind")]
CodegenError::RegisterMappingError(_0) => write!(f, "Register mapping error"),
CodegenError::Regalloc(errors) => write!(f, "Regalloc validation errors: {:?}", errors),
}
}
}