Skip to content

cranelift: Merge all run tests into runtests dir#2964

Merged
cfallin merged 2 commits into
bytecodealliance:mainfrom
afonso360:merge-runtests
Jun 9, 2021
Merged

cranelift: Merge all run tests into runtests dir#2964
cfallin merged 2 commits into
bytecodealliance:mainfrom
afonso360:merge-runtests

Conversation

@afonso360

Copy link
Copy Markdown
Contributor

With this change we now reuse tests across multiple arches.

Duplicate tests were merged into the same file where possible.
Some legacy x86 tests were left in separate files due to incompatibilities with the rest of the test suite.

We need someone with access to a s390x machine to check which ones of these should be commented out.

@bjorn3

bjorn3 commented Jun 3, 2021

Copy link
Copy Markdown
Contributor

We need someone with access to a s390x machine to check which ones of these should be commented out.

cc @uweigand

@github-actions github-actions Bot added the cranelift Issues related to the Cranelift code generator label Jun 3, 2021
@uweigand

uweigand commented Jun 7, 2021

Copy link
Copy Markdown
Member

On s390x, we currently do not support any SIMD or i128 operations, so all the simd-* and i128-* tests need to be commented out for now.

Also, the const.clif test case exposes a pre-existing endian bug with handling bool test case return values: those are written as integers of the same width by the trampoline, but are always read out as the Rust "bool" type. This happens to work on little-endian systems, but fails for any boolean type larger than 1 byte on big-endian systems. I was able to fix this using the following patch:

diff --git a/cranelift/filetests/src/function_runner.rs b/cranelift/filetests/src/function_runner.rs
index a41d5f286..e4dcfeff4 100644
--- a/cranelift/filetests/src/function_runner.rs
+++ b/cranelift/filetests/src/function_runner.rs
@@ -251,7 +251,13 @@ impl UnboxedValues {
             ir::types::I64 => DataValue::I64(ptr::read(p as *const i64)),
             ir::types::F32 => DataValue::F32(ptr::read(p as *const Ieee32)),
             ir::types::F64 => DataValue::F64(ptr::read(p as *const Ieee64)),
-            _ if ty.is_bool() => DataValue::B(ptr::read(p as *const bool)),
+            _ if ty.is_bool() => match ty.bytes() {
+                1 => DataValue::B(ptr::read(p as *const i8) != 0),
+                2 => DataValue::B(ptr::read(p as *const i16) != 0),
+                4 => DataValue::B(ptr::read(p as *const i32) != 0),
+                8 => DataValue::B(ptr::read(p as *const i64) != 0),
+                _ => unimplemented!(),
+            }
             _ if ty.is_vector() && ty.bytes() == 16 => {
                 DataValue::V128(ptr::read(p as *const [u8; 16]))
             }

afonso360 added 2 commits June 7, 2021 14:44
With this change we now reuse tests across multiple arches.

Duplicate tests were merged into the same file where possible.
Some legacy x86 tests were left in separate files due to incompatibilities with the rest of the test suite.
Enabling runtests for the s390x backend exposed a pre-existing endian bug with handling bool test case return values.

These are written as integers of the same width by the trampoline, but are always read out as the Rust "bool" type. This happens to work on little-endian systems, but fails for any boolean type larger than 1 byte on big-endian systems.

See: bytecodealliance#2964 (comment)
@afonso360

Copy link
Copy Markdown
Contributor Author

@uweigand Thank you for taking a look at this! I've disabled simd & i128 tests, and applied your patch.

@cfallin cfallin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the delay in reviewing this! LGTM.

The CI failure appears to be a flaky WASI test; I'll respawn.

@cfallin cfallin merged commit 59ebe4f into bytecodealliance:main Jun 9, 2021
@afonso360 afonso360 deleted the merge-runtests branch June 9, 2021 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants