This is an archive of the discontinued LLVM Phabricator instance.

[Webassembly] consider invalid CALL_S in removeRegisterOperands
AbandonedPublic

Authored by HerrCai0907 on Mar 23 2023, 9:30 PM.

Details

Summary

CALL_S at least need one operand as call func index. This case needs to
be identifer during removing register operands. Otherwise incorrect CALL_S
instruction will crash other part.
Invalid CALL_S will be replaced with UNREACHABLE

Diff Detail

Event Timeline

HerrCai0907 created this revision.Mar 23 2023, 9:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 9:30 PM
HerrCai0907 requested review of this revision.Mar 23 2023, 9:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 9:30 PM
HerrCai0907 added inline comments.Mar 23 2023, 11:20 PM
llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
99

I use arc diff to submit patch. It seems to format the whole file and cause this change.

I think the problem is, the call is instruction-selected as CALL, when it is supposed to be selected as CALL_INDIRECT. FastIsel selects it with CALL_INDIRECT; you can see the test passes with -fast-isel. I tried to fix this in ISel in D147033. PTAL.

detail fix see https://reviews.llvm.org/D147033, only add assert in this patch to avoid further spread of errors

aheejin added a comment.EditedMar 28 2023, 12:42 PM

detail fix see https://reviews.llvm.org/D147033, only add assert in this patch to avoid further spread of errors

I'm not sure if it makes much sense to only check about CALLs condition at the end of the pipeline. If we want to do that, we should be doing check for all instructions, which is equivalent to running a checker. We have a type checker, but this is to ensure the validity of assembly files we parse. If we emit an invalid instruction and something crashes at the end, I think that means we should be fixing the bug that emitted the invalid instruction, rather than asserting for a single instruction here.

HerrCai0907 abandoned this revision.Mar 28 2023, 3:11 PM