summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-03-08 08:10:37 -0800
committerGitHub <noreply@github.com>2024-03-08 08:10:37 -0800
commit7af0b474304c30134ef875567668bb6cd36e21aa (patch)
treeeb7aeba1ef0f84e172afe720c138db5f513bd6e4 /src/passes/Print.cpp
parentd6c5e4ab15df271521df7b35665c7463b2c490ca (diff)
downloadbinaryen-7af0b474304c30134ef875567668bb6cd36e21aa.tar.gz
binaryen-7af0b474304c30134ef875567668bb6cd36e21aa.tar.bz2
binaryen-7af0b474304c30134ef875567668bb6cd36e21aa.zip
Fix printing of bulk array ops (#6387)
When the bulk array ops had unreachable or null array types, they were replaced with blocks, but not using the correct code that also prints all their children as dropped followed by an unreachable. This meant that the text output in those cases did not parse as a valid module. Fix the bug. A follow-up PR will simplify the code to prevent similar bugs from occurring in the future.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index b0c83c437..af91a3194 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -289,6 +289,25 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
void visitArrayGet(ArrayGet* curr) {
maybePrintUnreachableOrNullReplacement(curr, curr->ref->type);
}
+ void visitArrayCopy(ArrayCopy* curr) {
+ if (curr->srcRef->type == Type::unreachable ||
+ curr->destRef->type == Type::unreachable ||
+ curr->srcRef->type.isNull() || curr->destRef->type.isNull()) {
+ maybePrintUnreachableOrNullReplacement(curr, Type::unreachable);
+ return;
+ }
+ visitExpression(curr);
+ }
+ void visitArrayFill(ArrayFill* curr) {
+ maybePrintUnreachableOrNullReplacement(curr, curr->ref->type);
+ }
+ void visitArrayInitData(ArrayInitData* curr) {
+ maybePrintUnreachableOrNullReplacement(curr, curr->ref->type);
+ }
+ void visitArrayInitElem(ArrayInitElem* curr) {
+ maybePrintUnreachableOrNullReplacement(curr, curr->ref->type);
+ }
+
// Module-level visitors
void handleSignature(HeapType curr, Name name = Name());
void visitExport(Export* curr);