-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1009: Fix LLVM crash on `return` with a float on the stack and a crash with gas metering. r=nlewycky a=nlewycky # Description This PR fixes some matters of testing. The return+float bug is caught by the LLVM verifier, which was accidentally unconditionally disabled even when running "make test check". Add a new cargo feature named "test" which is enabled by all the test crates. When the "test" feature is passed to the llvm-backend, run the LLVM verifier. Add a new crate `llvm-backend-test` which has one test so far, to ensure that this bug with the return+float does not crash LLVM. Include this new crate in runs of `make llvm`. Fix LLVM crash on `return` when there is a float with pending NaN canonicalization on the stack. Now that we run the verifier in testing, we discover another bug where `internal_field()` incorrectly labels a GEP with a TBAA label instead of the intended load. Fix this by labeling the correct instruction. No new test is introduced since this is already caught with `make bench-llvm`. # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Nick Lewycky <[email protected]>
- Loading branch information
Showing
15 changed files
with
72 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "wasmer-llvm-backend-tests" | ||
version = "0.10.2" | ||
authors = ["Nick Lewycky <[email protected]>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
wabt = "0.9.1" | ||
wasmer-runtime-core = { path = "../runtime-core", version = "0.11.0" } | ||
wasmer-runtime = { path = "../runtime", version = "0.11.0" } | ||
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.11.0", features = ["test"] } | ||
|
||
[features] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pub use wabt::wat2wasm; | ||
use wasmer_llvm_backend::LLVMCompiler; | ||
use wasmer_runtime_core::backend::Compiler; | ||
|
||
pub fn get_compiler() -> impl Compiler { | ||
LLVMCompiler::new() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use wasmer_llvm_backend_tests::{get_compiler, wat2wasm}; | ||
use wasmer_runtime::imports; | ||
use wasmer_runtime_core::compile_with; | ||
|
||
#[test] | ||
fn crash_return_with_float_on_stack() { | ||
const MODULE: &str = r#" | ||
(module | ||
(type (;0;) (func)) | ||
(type (;1;) (func (param f64) (result f64))) | ||
(func $_start (type 0)) | ||
(func $fmod (type 1) (param f64) (result f64) | ||
local.get 0 | ||
f64.const 0x0p+0 (;=0;) | ||
f64.mul | ||
return) | ||
) | ||
"#; | ||
let wasm_binary = wat2wasm(MODULE.as_bytes()).expect("WAST not valid or malformed"); | ||
let module = compile_with(&wasm_binary, &get_compiler()).unwrap(); | ||
let instance = module.instantiate(&imports! {}).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,4 @@ wabt = "0.9.1" | |
|
||
[features] | ||
debug = ["wasmer-runtime-core/debug"] | ||
test = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters