Skip to content

Commit 1753d16

Browse files
authored
[WebAssembly] Print instructions with type checking errors (#111067)
When there was a type checking error, we didn't run `InstPrinter`. This can be confusing because when there is an error in, say, block parameter type, `InstPrinter` doesn't run even if it has nothing to do with block parameter types, and all those updates to `ControlFlowStack` or `TryStack` do not happen: https://github.com/llvm/llvm-project/blob/c20b90ab8557b38efe8e8e993d41d8c08b798267/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp#L135-L151 For example, ```wast block (i32) -> () ;; Block input parameter error end_block ;; Now this errors out as "End marker mismatch" ``` This is confusing because there is a `block` and the `end_block` is not a mismatch. Only that `block` has a type checking error, but that's not an end marker mismatch. I think we can just print the instruction whether we had a type checking error or not, and this will be less confusing.
1 parent 635db5e commit 1753d16

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,8 +1157,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
11571157
Inst.setOpcode(Opc64);
11581158
}
11591159
}
1160-
if (!SkipTypeCheck && TC.typeCheck(IDLoc, Inst, Operands))
1161-
return true;
1160+
if (!SkipTypeCheck)
1161+
TC.typeCheck(IDLoc, Inst, Operands);
11621162
Out.emitInstruction(Inst, getSTI());
11631163
if (CurrentState == EndFunction) {
11641164
onEndOfFunction(IDLoc);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# RUN: not llvm-mc -triple=wasm32-unknown-unknown < %s | FileCheck %s
2+
3+
# This tests annotations are handled correctly even if there is a type checking
4+
# error (which are unrelated to the block annotations).
5+
test_annotation:
6+
.functype test_annotation () -> ()
7+
block (i32) -> ()
8+
drop
9+
# CHECK-NOT: # End marker mismatch!
10+
end_block
11+
end_function

0 commit comments

Comments
 (0)