In RemoveUnusedModuleElements we clear the entire table if there is no usage of the table in the module:
https://github.com/WebAssembly/binaryen/blob/master/src/passes/RemoveUnusedModuleElements.cpp#L226
However, perhaps we could be more course grain:
- Find all the signatures used by all call_indirect instructions.
- Remove any table elements that don't match one of those signatures.
I guess this might make the table kind of sparse? Would it be observable? Using one of these slots would generate an "invalid signature" and now it would become "empty table slot". I guess we could add per-signature trapping functions. These would never be reached and would preserve the "invalid signature" trap.
In RemoveUnusedModuleElements we clear the entire table if there is no usage of the table in the module:
https://github.com/WebAssembly/binaryen/blob/master/src/passes/RemoveUnusedModuleElements.cpp#L226
However, perhaps we could be more course grain:
I guess this might make the table kind of sparse? Would it be observable? Using one of these slots would generate an "invalid signature" and now it would become "empty table slot". I guess we could add per-signature trapping functions. These would never be reached and would preserve the "invalid signature" trap.