diff options
-rw-r--r-- | src/passes/Print.cpp | 18 | ||||
-rw-r--r-- | test/passes/alignment-lowering.txt | 2 | ||||
-rw-r--r-- | test/passes/flatten.txt | 4 | ||||
-rw-r--r-- | test/passes/remove-unused-brs.txt | 2 | ||||
-rw-r--r-- | test/unreachable-instr-type.wast | 28 | ||||
-rw-r--r-- | test/unreachable-instr-type.wast.from-wast | 27 | ||||
-rw-r--r-- | test/unreachable-instr-type.wast.fromBinary | 8 | ||||
-rw-r--r-- | test/unreachable-instr-type.wast.fromBinary.noDebugInfo | 8 |
8 files changed, 86 insertions, 11 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 0c71afc7b..dc973b208 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -55,6 +55,12 @@ static Name printableLocal(Index index, Function* func) { return name; } +// Printing "unreachable" as a instruction prefix type is not valid in wasm text +// format. Print something else to make it pass. +static Type forceConcrete(Type type) { + return isConcreteType(type) ? type : i32; +} + // Prints the internal contents of an expression: everything but // the children. struct PrintExpressionContents @@ -141,7 +147,7 @@ struct PrintExpressionContents printName(curr->name, o); } void visitLoad(Load* curr) { - prepareColor(o) << printType(curr->type); + prepareColor(o) << printType(forceConcrete(curr->type)); if (curr->isAtomic) { o << ".atomic"; } @@ -167,7 +173,7 @@ struct PrintExpressionContents } } void visitStore(Store* curr) { - prepareColor(o) << printType(curr->valueType); + prepareColor(o) << printType(forceConcrete(curr->valueType)); if (curr->isAtomic) { o << ".atomic"; } @@ -192,10 +198,8 @@ struct PrintExpressionContents } } static void printRMWSize(std::ostream& o, Type type, uint8_t bytes) { - prepareColor(o) << printType(type) << ".atomic.rmw"; - if (type == unreachable) { - o << '?'; - } else if (bytes != getTypeSize(type)) { + prepareColor(o) << printType(forceConcrete(type)) << ".atomic.rmw"; + if (type != unreachable && bytes != getTypeSize(type)) { if (bytes == 1) { o << '8'; } else if (bytes == 2) { @@ -253,7 +257,7 @@ struct PrintExpressionContents } void visitAtomicWait(AtomicWait* curr) { prepareColor(o); - o << printType(curr->expectedType) << ".atomic.wait"; + o << printType(forceConcrete(curr->expectedType)) << ".atomic.wait"; if (curr->offset) { o << " offset=" << curr->offset; } diff --git a/test/passes/alignment-lowering.txt b/test/passes/alignment-lowering.txt index dd8d8ca9c..61066dc54 100644 --- a/test/passes/alignment-lowering.txt +++ b/test/passes/alignment-lowering.txt @@ -437,7 +437,7 @@ ) ) (drop - (unreachable.load offset=100 + (i32.load offset=100 (unreachable) ) ) diff --git a/test/passes/flatten.txt b/test/passes/flatten.txt index 7cfd1e6a7..5fc0a1032 100644 --- a/test/passes/flatten.txt +++ b/test/passes/flatten.txt @@ -679,7 +679,7 @@ (drop (unreachable) ) - (unreachable.load + (i32.load (unreachable) ) (unreachable) @@ -1183,7 +1183,7 @@ (i32.const 22) (block (unreachable) - (unreachable.load + (i32.load (unreachable) ) (drop diff --git a/test/passes/remove-unused-brs.txt b/test/passes/remove-unused-brs.txt index 790d943c3..0cfa94f6c 100644 --- a/test/passes/remove-unused-brs.txt +++ b/test/passes/remove-unused-brs.txt @@ -984,7 +984,7 @@ (i32.const 607395945) ) (br_if $label$1 - (unreachable.load offset=3 align=1 + (i32.load offset=3 align=1 (select (call $untaken-brs-might-prevent-block-removal (f32.const 1.4904844647389837e-07) diff --git a/test/unreachable-instr-type.wast b/test/unreachable-instr-type.wast new file mode 100644 index 000000000..220347f0f --- /dev/null +++ b/test/unreachable-instr-type.wast @@ -0,0 +1,28 @@ +(module + (memory (shared 1 1)) + (func $test + (f32.load (unreachable)) + + (f32.store + (unreachable) + (f32.const 0) + ) + + (i64.atomic.rmw.add + (unreachable) + (i64.const 0) + ) + + (i64.atomic.rmw.cmpxchg + (unreachable) + (i64.const 0) + (i64.const 1) + ) + + (i64.atomic.wait + (unreachable) + (i64.const 0) + (i64.const 0) + ) + ) +) diff --git a/test/unreachable-instr-type.wast.from-wast b/test/unreachable-instr-type.wast.from-wast new file mode 100644 index 000000000..2e3a87b49 --- /dev/null +++ b/test/unreachable-instr-type.wast.from-wast @@ -0,0 +1,27 @@ +(module + (type $FUNCSIG$v (func)) + (memory $0 (shared 1 1)) + (func $test (; 0 ;) (type $FUNCSIG$v) + (i32.load + (unreachable) + ) + (f32.store + (unreachable) + (f32.const 0) + ) + (i32.atomic.rmw.add + (unreachable) + (i64.const 0) + ) + (i32.atomic.rmw.cmpxchg + (unreachable) + (i64.const 0) + (i64.const 1) + ) + (i64.atomic.wait + (unreachable) + (i64.const 0) + (i64.const 0) + ) + ) +) diff --git a/test/unreachable-instr-type.wast.fromBinary b/test/unreachable-instr-type.wast.fromBinary new file mode 100644 index 000000000..32838581a --- /dev/null +++ b/test/unreachable-instr-type.wast.fromBinary @@ -0,0 +1,8 @@ +(module + (type $0 (func)) + (memory $0 (shared 1 1)) + (func $test (; 0 ;) (type $0) + (unreachable) + ) +) + diff --git a/test/unreachable-instr-type.wast.fromBinary.noDebugInfo b/test/unreachable-instr-type.wast.fromBinary.noDebugInfo new file mode 100644 index 000000000..16237ef69 --- /dev/null +++ b/test/unreachable-instr-type.wast.fromBinary.noDebugInfo @@ -0,0 +1,8 @@ +(module + (type $0 (func)) + (memory $0 (shared 1 1)) + (func $0 (; 0 ;) (type $0) + (unreachable) + ) +) + |