From e234096e6acb3662fdedcdf6651fd5e9e7609ab2 Mon Sep 17 00:00:00 2001 From: losfair Date: Thu, 30 Apr 2020 00:05:45 +0800 Subject: [PATCH] Add test for issue #1409. --- tests/custom/singlepass-r10-overwrite.wast | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/custom/singlepass-r10-overwrite.wast diff --git a/tests/custom/singlepass-r10-overwrite.wast b/tests/custom/singlepass-r10-overwrite.wast new file mode 100644 index 000000000..7e1f2a1ca --- /dev/null +++ b/tests/custom/singlepass-r10-overwrite.wast @@ -0,0 +1,53 @@ +;; A bug was introduced in the commit below, where the `R10` register is incorrectly overwritten. +;; This test case covers this specific case. +;; +;; https://github.com/wasmerio/wasmer/commit/ed826cb389b17273002e729160bf076213b7e2f2#diff-8c30560d501545a19acafa7ebb21ebfeR1784 +;; + +(module + (func $call_target (param i64) (param i64) (param i64) (param i64) (param i64) (param i64) (result i64) + (local.get 0) + ) + + (func (export "test") (result i64) + ;; Use `i64.add`s to actually push values onto the runtime stack. + + ;; rsi + (i64.const 1) + (i64.const 1) + (i64.add) + + ;; rdi + (i64.const 1) + (i64.const 1) + (i64.add) + + ;; r8 + (i64.const 1) + (i64.const 1) + (i64.add) + + ;; r9 + (i64.const 1) + (i64.const 1) + (i64.add) + + ;; r10 (!) + (i64.const 1) + (i64.const 1) + (i64.add) + + ;; Imm64's as arguments + (i64.const 1) + (i64.const 1) + (i64.const 1) + (i64.const 1) + (i64.const 1) ;; allocated to the first memory slot + + ;; call + (call $call_target) + (return) + ) +) + +(assert_return (invoke "test") (i64.const 2))