Repository navigation
[NFC] Simplify printing of unreachable replacements - #8616
Conversation
When an instruction has a type immediate that we cannot print because the expression it is supposed to come from has unreachable or null type, we instead print an unreachable block with a comment saying what instruction we failed to print. We previously handled this via different code paths for type immediates that come from child expressions that type immediates that come from the printed expression's own return type. Unify these code paths in the printer by improving `Properties::hasUnwritableTypeImmediate` to handle both cases. Also fix the printing of `ShallowExpression` to check for unwritable type immediates first to avoid assertion failures.
| if (curr->is<StructNew>() || curr->is<ArrayNew>() || | ||
| curr->is<ArrayNewData>() || curr->is<ArrayNewElem>() || | ||
| curr->is<ArrayNewFixed>() || curr->is<ContNew>() || | ||
| curr->is<ContBind>()) { |
There was a problem hiding this comment.
Can we possibly define these as a macro in wasm-delegations-fields.def too?
There was a problem hiding this comment.
We could possibly add a macro similar to the macros for fields, but not actually associated with a field. Do you think that would be better than this? (also cc @kripken for opinions)
There was a problem hiding this comment.
What I meant was, would it be possible and make sense to define a macro that means "This instruction's type printing depends on the instruction's type"?
There was a problem hiding this comment.
Yes, understood. The only weird part is that there would not be a field associated with that macro.
There was a problem hiding this comment.
Ok, I tried it this way, PTAL.
| } | ||
| if (!cast->desc->type.getHeapType().getDescribedType()) { | ||
| return true; | ||
| }; |
When an instruction has a type immediate that we cannot print because the expression it is supposed to come from has unreachable or null type, we instead print an unreachable block with a comment saying what instruction we failed to print. We previously handled this via different code paths for type immediates that come from child expressions that type immediates that come from the printed expression's own return type. Unify these code paths in the printer by improving
Properties::hasUnwritableTypeImmediateto handle both cases. Also fix the printing ofShallowExpressionto check for unwritable type immediates first to avoid assertion failures.