diff options
Diffstat (limited to 'src/passes')
-rw-r--r-- | src/passes/OptimizeCasts.cpp | 6 | ||||
-rw-r--r-- | src/passes/OptimizeInstructions.cpp | 14 | ||||
-rw-r--r-- | src/passes/Print.cpp | 10 | ||||
-rw-r--r-- | src/passes/RemoveUnusedBrs.cpp | 3 |
4 files changed, 12 insertions, 21 deletions
diff --git a/src/passes/OptimizeCasts.cpp b/src/passes/OptimizeCasts.cpp index 599e403ff..7877bea9f 100644 --- a/src/passes/OptimizeCasts.cpp +++ b/src/passes/OptimizeCasts.cpp @@ -385,10 +385,8 @@ struct EarlyCastApplier : public PostWalker<EarlyCastApplier> { auto refCastIter = finder.refCastToApply.find(curr); if (refCastIter != finder.refCastToApply.end()) { - currPtr = replaceCurrent(Builder(*getModule()) - .makeRefCast(currPtr, - refCastIter->second->type, - refCastIter->second->safety)); + currPtr = replaceCurrent( + Builder(*getModule()).makeRefCast(currPtr, refCastIter->second->type)); } auto refAsIter = finder.refAsToApply.find(curr); diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index 44078545b..965f8b2d8 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -1406,13 +1406,13 @@ struct OptimizeInstructions // skipCast do): removing a cast is potentially dangerous, as it removes // information from the IR. For example: // - // (ref.is_func - // (ref.as_func + // (ref.test (ref i31) + // (ref.cast (ref i31) // (local.get $anyref))) // // The local has no useful type info here (it is anyref). The cast forces it - // to be a function, so we know that if we do not trap then the ref.is will - // definitely be 1. But if we removed the ref.as first (which we can do in + // to be an i31, so we know that if we do not trap then the ref.test will + // definitely be 1. But if we removed the ref.cast first (which we can do in // traps-never-happen mode) then we'd not have the type info we need to // optimize that way. // @@ -1420,12 +1420,12 @@ struct OptimizeInstructions // // * Before removing a cast we should use its type information in the best // way we can. Only after doing so should a cast be removed. In the exmaple - // above, that means first seeing that the ref.is must return 1, and only - // then possibly removing the ref.as. + // above, that means first seeing that the ref.test must return 1, and only + // then possibly removing the ref.cast. // * Do not remove a cast if removing it might remove useful information for // others. For example, // - // (ref.cast $A + // (ref.cast (ref null $A) // (ref.as_non_null ..)) // // If we remove the inner cast then the outer cast becomes nullable. That diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 6740bc8ed..dee23d67d 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2102,14 +2102,10 @@ struct PrintExpressionContents if (printUnreachableReplacement(curr)) { return; } - if (curr->safety == RefCast::Unsafe) { - printMedium(o, "ref.cast_nop "); + if (curr->type.isNullable()) { + printMedium(o, "ref.cast null "); } else { - if (curr->type.isNullable()) { - printMedium(o, "ref.cast null "); - } else { - printMedium(o, "ref.cast "); - } + printMedium(o, "ref.cast "); } printHeapType(o, curr->type.getHeapType(), wasm); } diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index 197126f5e..dc7741c0e 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -714,9 +714,6 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { // First, check for a possible null which would prevent optimizations on // null checks. - // TODO: Look into using BrOnNonNull here, to replace a br_on_func whose - // input is (ref null func) with br_on_non_null (as only the null check - // would be needed). // TODO: Use the fallthrough to determine in more cases that we // definitely have a null. auto refType = curr->ref->type; |