diff options
-rw-r--r-- | src/ir/possible-contents.cpp | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp index d388d281c..5170d8fa3 100644 --- a/src/ir/possible-contents.cpp +++ b/src/ir/possible-contents.cpp @@ -655,9 +655,7 @@ struct InfoCollector addRoot(curr); } - void visitRefCast(RefCast* curr) { - addChildParentLink(curr->ref, curr); - } + void visitRefCast(RefCast* curr) { receiveChildValue(curr->ref, curr); } void visitRefTest(RefTest* curr) { addRoot(curr); } void visitBrOn(BrOn* curr) { // TODO: optimize when possible @@ -812,7 +810,7 @@ struct InfoCollector // We can't see where this goes. We must be pessimistic and assume it // can call anything of the proper type, the same as a CallRef. (We could // look at the possible contents of |target| during the flow, but that - // would require special logic like we have for RefCast etc., and the + // would require special logic like we have for StructGet etc., and the // intrinsics will be lowered away anyhow, so just running after that is // a workaround.) handleIndirectCall(curr, target->type); @@ -1408,10 +1406,6 @@ private: // Similar to readFromData, but does a write for a struct.set or array.set. void writeToData(Expression* ref, Expression* value, Index fieldIndex); - // Special handling for RefCast during the flow: RefCast only admits valid - // values to flow through it. - void flowRefCast(const PossibleContents& contents, RefCast* cast); - // We will need subtypes during the flow, so compute them once ahead of time. std::unique_ptr<SubTypes> subTypes; @@ -1703,9 +1697,8 @@ bool Flower::updateContents(LocationIndex locationIndex, bool filtered = false; if (auto* exprLoc = std::get_if<ExpressionLocation>(&location)) { // TODO: Replace this with specific filterFoo or flowBar methods like we - // have for flowRefCast and filterGlobalContents. That could save a - // little wasted work here. Might be best to do that after the spec is - // fully stable. + // have for filterGlobalContents. That could save a little wasted work + // here. Might be best to do that after the spec is fully stable. filterExpressionContents(contents, *exprLoc, worthSendingMore); filtered = true; } else if (auto* globalLoc = std::get_if<GlobalLocation>(&location)) { @@ -1798,9 +1791,6 @@ void Flower::flowAfterUpdate(LocationIndex locationIndex) { } else if (auto* set = parent->dynCast<ArraySet>()) { assert(set->ref == child || set->value == child); writeToData(set->ref, set->value, 0); - } else if (auto* cast = parent->dynCast<RefCast>()) { - assert(cast->ref == child); - flowRefCast(contents, cast); } else { // TODO: ref.test and all other casts can be optimized (see the cast // helper code used in OptimizeInstructions and RemoveUnusedBrs) @@ -2095,25 +2085,6 @@ void Flower::writeToData(Expression* ref, Expression* value, Index fieldIndex) { }); } -void Flower::flowRefCast(const PossibleContents& contents, RefCast* cast) { - // RefCast only allows valid values to go through: nulls and things of the - // cast type. Filter anything else out. - // TODO: Remove this method, as it just filters by the type, which we do - // automatically now in filterExpressionContents. - auto intendedCone = - PossibleContents::fullConeType(Type(cast->intendedType, Nullable)); - PossibleContents filtered = contents; - filtered.intersectWithFullCone(intendedCone); - if (!filtered.isNone()) { -#if defined(POSSIBLE_CONTENTS_DEBUG) && POSSIBLE_CONTENTS_DEBUG >= 2 - std::cout << " ref.cast passing through\n"; - filtered.dump(std::cout); - std::cout << '\n'; -#endif - updateContents(ExpressionLocation{cast, 0}, filtered); - } -} - #if defined(POSSIBLE_CONTENTS_DEBUG) && POSSIBLE_CONTENTS_DEBUG >= 2 void Flower::dump(Location location) { if (auto* loc = std::get_if<ExpressionLocation>(&location)) { |