diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp index 24e42cf1c42..f07a42acf97 100644 --- a/src/ir/possible-contents.cpp +++ b/src/ir/possible-contents.cpp @@ -2243,7 +2243,11 @@ struct Flower { // For a non-full cone, we also reduce the depth as much as possible, so it is // equal to the maximum depth of an existing subtype. Index getNormalizedConeDepth(Type type, Index depth) { - return std::min(depth, maxDepths[type.getHeapType()]); + auto iter = maxDepths.find(type.getHeapType()); + // A max depth must be in the map (otherwise we would use the default 0, + // making it exact, almost certainly incorrectly). + assert(iter != maxDepths.end()); + return std::min(depth, iter->second); } void normalizeConeType(PossibleContents& cone) { @@ -2639,6 +2643,12 @@ bool Flower::updateContents(LocationIndex locationIndex, // more later (we compute that at the end), so use a temp out var for that. bool worthSendingMoreTemp = true; filterExpressionContents(newContents, *exprLoc, worthSendingMoreTemp); + +#if defined(POSSIBLE_CONTENTS_DEBUG) && POSSIBLE_CONTENTS_DEBUG >= 2 + std::cout << " post-filtered exprLoc:\n"; + newContents.dump(std::cout, &wasm); + std::cout << '\n'; +#endif } else if (auto* globalLoc = std::get_if(&location)) { // Generic filtering. We do this both before and after. filterGlobalContents(newContents, *globalLoc); diff --git a/src/ir/subtypes.h b/src/ir/subtypes.h index 5c654ceb7be..fa949e992c2 100644 --- a/src/ir/subtypes.h +++ b/src/ir/subtypes.h @@ -135,6 +135,7 @@ struct SubTypes { basicDepth = std::max(basicDepth, depths[type] + 1); } + // Fill in the other basic types. for (auto share : {Unshared, Shared}) { depths[HeapTypes::eq.getBasic(share)] = std::max(depths[HeapTypes::struct_.getBasic(share)], @@ -142,6 +143,19 @@ struct SubTypes { 1; depths[HeapTypes::any.getBasic(share)] = depths[HeapTypes::eq.getBasic(share)] + 1; + + depths[HeapTypes::i31.getBasic(share)] = 0; + depths[HeapTypes::exn.getBasic(share)] = 0; + + // Extern has string as a subtype. + depths[HeapTypes::ext.getBasic(share)] = 1; + depths[HeapTypes::string.getBasic(share)] = 0; + + depths[HeapTypes::none.getBasic(share)] = 0; + depths[HeapTypes::noext.getBasic(share)] = 0; + depths[HeapTypes::nofunc.getBasic(share)] = 0; + depths[HeapTypes::nocont.getBasic(share)] = 0; + depths[HeapTypes::noexn.getBasic(share)] = 0; } return depths; diff --git a/test/gtest/type-builder.cpp b/test/gtest/type-builder.cpp index da7f4c60f7c..d7ad960b185 100644 --- a/test/gtest/type-builder.cpp +++ b/test/gtest/type-builder.cpp @@ -1604,6 +1604,15 @@ TEST_F(TypeTest, TestMaxStructDepths) { EXPECT_EQ(maxDepths[HeapType::struct_], Index(2)); EXPECT_EQ(maxDepths[HeapType::eq], Index(3)); EXPECT_EQ(maxDepths[HeapType::any], Index(4)); + EXPECT_EQ(maxDepths[HeapType::i31], Index(0)); + EXPECT_EQ(maxDepths[HeapType::exn], Index(0)); + EXPECT_EQ(maxDepths[HeapType::ext], Index(1)); + EXPECT_EQ(maxDepths[HeapType::string], Index(0)); + EXPECT_EQ(maxDepths[HeapType::none], Index(0)); + EXPECT_EQ(maxDepths[HeapType::noext], Index(0)); + EXPECT_EQ(maxDepths[HeapType::nofunc], Index(0)); + EXPECT_EQ(maxDepths[HeapType::nocont], Index(0)); + EXPECT_EQ(maxDepths[HeapType::noexn], Index(0)); } TEST_F(TypeTest, TestMaxArrayDepths) {