Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/passes/InstrumentFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,12 @@ struct InstrumentFunctions

void addLogCallImport(Module* module) {
// Add import of external log function
auto loggerFunctionImport =
Builder::makeFunction(m_LoggerFunctionName,
Signature(Type{Type::i32, Type::i32}, Type::none),
{});
auto loggerFunctionImport = Builder::makeFunction(
m_LoggerFunctionName,
Type(Signature(Type{Type::i32, Type::i32}, Type::none),
NonNullable,
Inexact),
{});
loggerFunctionImport->base = m_LoggerFunctionName;
loggerFunctionImport->module = m_ImportModule;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
(module
(type $2 (func (result i64)))
(type $0 (func))
(type $1 (func (result i32)))
(type $3 (func (result f32)))
(type $4 (func (result f64)))
(type $6 (func (param i32) (result i32)))
(type $5 (func (result v128)))
(type $7 (func (param i32 i32)))
(import "env" "log_execution" (func $log_execution (param i32 i32)))
(memory $0 256 256)
(data $.ro-data0 (i32.const 0) "Hello World\00")
(data $label_0 (i32.const 12) "Submodule 1\00")
(data $label_1 (i32.const 24) "Submodule 2\00")
(data $label_2 (i32.const 36) "Submodule 3\00")
(export "a" (func $a))
(export "b" (func $b))
(export "c" (func $c))
(export "d" (func $d))
(export "e" (func $e))
(export "f" (func $f))
(export "g" (func $g))
(export "h" (func $h))
(export "memory" (memory $0))
(func $a
(call $log_execution
(i32.const 0)
(i32.const 12)
)
(nop)
)
(func $b (result i32)
(call $log_execution
(i32.const 1)
(i32.const 12)
)
(return
(i32.const 1337)
)
)
(func $c (result i64)
(call $log_execution
(i32.const 2)
(i32.const 12)
)
(return
(i64.const 1337)
)
)
(func $d (result f32)
(call $log_execution
(i32.const 3)
(i32.const 12)
)
(return
(f32.const 1337)
)
)
(func $e (result f64)
(call $log_execution
(i32.const 4)
(i32.const 12)
)
(return
(f64.const 1337)
)
)
(func $f (param $0 i32) (result i32)
(call $log_execution
(i32.const 5)
(i32.const 24)
)
(return
(i32.const 1337)
)
)
(func $g (result i64)
(drop
(call $unexported_func)
)
(return
(i64.const 1337)
)
)
(func $unexported_func (result i64)
(return
(i64.const 1337)
)
)
(func $h (result v128)
(call $log_execution
(i32.const 8)
(i32.const 36)
)
(return
(v128.const i32x4 0x00000001 0x00000003 0x00000003 0x00000007)
)
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
(module
(memory $0 256 256)
(data $.ro-data0 (i32.const 0) "Hello World\00")
(type $0 (func))
(type $1 (func (result i32)))
(type $2 (func (result i64)))
(type $3 (func (result f32)))
(type $4 (func (result f64)))
(type $5 (func (result v128)))
(type $6 (func (param i32) (result i32)))
(export "a" (func $a))
(export "b" (func $b))
(export "c" (func $c))
(export "d" (func $d))
(export "e" (func $e))
(export "f" (func $f))
(export "g" (func $g))
(export "h" (func $h))
(export "memory" (memory $0))
(func $a (type $0)
(nop)
)
(func $b (type $1)
(return
(i32.const 1337)
)
)
(func $c (type $2)
(return
(i64.const 1337)
)
)
(func $d (type $3)
(return
(f32.const 1337)
)
)
(func $e (type $4)
(return
(f64.const 1337)
)
)
(func $f (type $6)
(return
(i32.const 1337)
)
)
(func $g (type $2)
(drop
(call $unexported_func)
)
(return
(i64.const 1337)
)
)
(func $unexported_func (type $2)
(return
(i64.const 1337)
)
)
(func $h (type $5)
(return
(v128.const i32x4 1 3 3 7)
)
)
)
41 changes: 41 additions & 0 deletions test/passes/remove-functions=a;b;c;d;e;f;g;h_enable-simd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
(module
(type $2 (func (result i64)))
(type $0 (func))
(type $1 (func (result i32)))
(type $3 (func (result f32)))
(type $4 (func (result f64)))
(type $6 (func (param i32) (result i32)))
(type $5 (func (result v128)))
(export "a" (func $a))
(export "b" (func $b))
(export "c" (func $c))
(export "d" (func $d))
(export "e" (func $e))
(export "f" (func $f))
(export "g" (func $g))
(export "h" (func $h))
(func $a
(return)
)
(func $b (result i32)
(i32.const 0)
)
(func $c (result i64)
(i64.const 0)
)
(func $d (result f32)
(f32.const 0)
)
(func $e (result f64)
(f64.const 0)
)
(func $f (param $0 i32) (result i32)
(i32.const 0)
)
(func $g (result i64)
(i64.const 0)
)
(func $h (result v128)
(v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000)
)
)
64 changes: 64 additions & 0 deletions test/passes/remove-functions=a;b;c;d;e;f;g;h_enable-simd.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
(module
(memory 256 256)
(type $0 (func))
(type $1 (func (result i32)))
(type $2 (func (result i64)))
(type $3 (func (result f32)))
(type $4 (func (result f64)))
(type $5 (func (result v128)))
(type $6 (func (param i32) (result i32)))
(export "a" (func $a))
(export "b" (func $b))
(export "c" (func $c))
(export "d" (func $d))
(export "e" (func $e))
(export "f" (func $f))
(export "g" (func $g))
(export "h" (func $h))
(func $a (type $0)
(nop)
)
(func $b (type $1)
(return
(i32.const 1337)
)
)
(func $c (type $2)
(return
(i64.const 1337)
)
)
(func $d (type $3)
(return
(f32.const 1337)
)
)
(func $e (type $4)
(return
(f64.const 1337)
)
)
(func $f (type $6)
(return
(i32.const 1337)
)
)
(func $g (type $2)
(drop
(call $unexported_func)
)
(return
(i64.const 1337)
)
)
(func $unexported_func (type $2)
(return
(i64.const 1337)
)
)
(func $h (type $5)
(return
(v128.const i32x4 1 3 3 7)
)
)
)
Loading