Skip to content

Commit

Permalink
Bug 1664453: vendor Cranelift to 379aed8092cd1241ec7839e77d05557b1dce…
Browse files Browse the repository at this point in the history
…b234 to resolve two Wasm translation bugs. r=jseward

This Cranelift update to revision 379aed8092cd1241ec7839e77d05557b1dceb234
includes its PRs #2197 and #2194, which fix two Wasm translation bugs, as well a
other miscellaneous updates and fixes.

Fixes both Bug 1664453 and Bug 1663861.

Differential Revision: https://phabricator.services.mozilla.com/D90306
  • Loading branch information
cfallin committed Sep 15, 2020
1 parent d027c5b commit 0931312
Show file tree
Hide file tree
Showing 38 changed files with 2,510 additions and 1,914 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ rev = "3224e2dee65c0726c448484d4c3c43956b9330ec"
[source."https://github.com/bytecodealliance/wasmtime"]
git = "https://github.com/bytecodealliance/wasmtime"
replace-with = "vendored-sources"
rev = "a7f7c23bf9c37c642da962d575b7c99007918872"
rev = "379aed8092cd1241ec7839e77d05557b1dceb234"

[source."https://github.com/badboy/failure"]
git = "https://github.com/badboy/failure"
Expand Down
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ failure_derive = { git = "https://github.com/badboy/failure", rev = "64af847bc5f

[patch.crates-io.cranelift-codegen]
git = "https://github.com/bytecodealliance/wasmtime"
rev = "a7f7c23bf9c37c642da962d575b7c99007918872"
rev = "379aed8092cd1241ec7839e77d05557b1dceb234"

[patch.crates-io.cranelift-wasm]
git = "https://github.com/bytecodealliance/wasmtime"
rev = "a7f7c23bf9c37c642da962d575b7c99007918872"
rev = "379aed8092cd1241ec7839e77d05557b1dceb234"
Empty file.
2 changes: 1 addition & 1 deletion third_party/rust/cranelift-codegen/.cargo-checksum.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions third_party/rust/cranelift-codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ peepmatic = { path = "../peepmatic", optional = true, version = "0.66.0" }
peepmatic-traits = { path = "../peepmatic/crates/traits", optional = true, version = "0.66.0" }
peepmatic-runtime = { path = "../peepmatic/crates/runtime", optional = true, version = "0.66.0" }
regalloc = "0.0.30"
souper-ir = { version = "1", optional = true }
wast = { version = "22.0.0", optional = true }
# It is a goal of the cranelift-codegen crate to have minimal external dependencies.
# Please don't add any unless they are essential to the task of creating binary
Expand Down Expand Up @@ -87,5 +88,8 @@ rebuild-peephole-optimizers = ["peepmatic", "peepmatic-traits", "wast"]
# Enable the use of `peepmatic`-generated peephole optimizers.
enable-peepmatic = ["peepmatic-runtime", "peepmatic-traits", "serde"]

# Enable support for the Souper harvester.
souper-harvest = ["souper-ir", "souper-ir/stringify"]

[badges]
maintenance = { status = "experimental" }
15 changes: 15 additions & 0 deletions third_party/rust/cranelift-codegen/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ use crate::timing;
use crate::unreachable_code::eliminate_unreachable_code;
use crate::value_label::{build_value_labels_ranges, ComparableSourceLoc, ValueLabelsRanges};
use crate::verifier::{verify_context, verify_locations, VerifierErrors, VerifierResult};
#[cfg(feature = "souper-harvest")]
use alloc::string::String;
use alloc::vec::Vec;
use log::debug;

#[cfg(feature = "souper-harvest")]
use crate::souper_harvest::do_souper_harvest;

/// Persistent data structures and compilation pipeline.
pub struct Context {
/// The function we're compiling.
Expand Down Expand Up @@ -447,4 +452,14 @@ impl Context {
isa,
))
}

/// Harvest candidate left-hand sides for superoptimization with Souper.
#[cfg(feature = "souper-harvest")]
pub fn souper_harvest(
&mut self,
out: &mut std::sync::mpsc::Sender<String>,
) -> CodegenResult<()> {
do_souper_harvest(&self.func, out);
Ok(())
}
}
49 changes: 49 additions & 0 deletions third_party/rust/cranelift-codegen/src/ir/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::isa;

use crate::bitset::BitSet;
use crate::entity;
use ir::condcodes::{FloatCC, IntCC};

/// Some instructions use an external list of argument values because there is not enough space in
/// the 16-byte `InstructionData` struct. These value lists are stored in a memory pool in
Expand Down Expand Up @@ -295,6 +296,33 @@ impl InstructionData {
}
}

/// If this is a control-flow instruction depending on an integer condition, gets its
/// condition. Otherwise, return `None`.
pub fn cond_code(&self) -> Option<IntCC> {
match self {
&InstructionData::IntCond { cond, .. }
| &InstructionData::BranchIcmp { cond, .. }
| &InstructionData::IntCompare { cond, .. }
| &InstructionData::IntCondTrap { cond, .. }
| &InstructionData::BranchInt { cond, .. }
| &InstructionData::IntSelect { cond, .. }
| &InstructionData::IntCompareImm { cond, .. } => Some(cond),
_ => None,
}
}

/// If this is a control-flow instruction depending on a floating-point condition, gets its
/// condition. Otherwise, return `None`.
pub fn fp_cond_code(&self) -> Option<FloatCC> {
match self {
&InstructionData::BranchFloat { cond, .. }
| &InstructionData::FloatCompare { cond, .. }
| &InstructionData::FloatCond { cond, .. }
| &InstructionData::FloatCondTrap { cond, .. } => Some(cond),
_ => None,
}
}

/// If this is a trapping instruction, get an exclusive reference to its
/// trap code. Otherwise, return `None`.
pub fn trap_code_mut(&mut self) -> Option<&mut TrapCode> {
Expand All @@ -307,6 +335,27 @@ impl InstructionData {
}
}

/// If this is an atomic read/modify/write instruction, return its subopcode.
pub fn atomic_rmw_op(&self) -> Option<ir::AtomicRmwOp> {
match self {
&InstructionData::AtomicRmw { op, .. } => Some(op),
_ => None,
}
}

/// If this is a load/store instruction, returns its immediate offset.
pub fn load_store_offset(&self) -> Option<i32> {
match self {
&InstructionData::Load { offset, .. }
| &InstructionData::StackLoad { offset, .. }
| &InstructionData::LoadComplex { offset, .. }
| &InstructionData::Store { offset, .. }
| &InstructionData::StackStore { offset, .. }
| &InstructionData::StoreComplex { offset, .. } => Some(offset.into()),
_ => None,
}
}

/// Return information about a call instruction.
///
/// Any instruction that can call another function reveals its call signature here.
Expand Down
Loading

0 comments on commit 0931312

Please sign in to comment.