diff options
Diffstat (limited to 'src/ir/module-utils.cpp')
-rw-r--r-- | src/ir/module-utils.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index 5044d303c..744f62682 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -40,6 +40,11 @@ struct Counts : public InsertOrderedMap<HeapType, size_t> { (*this)[type]; } } + void include(Type type) { + for (HeapType ht : type.getHeapTypeChildren()) { + include(ht); + } + } }; struct CodeScanner @@ -73,13 +78,20 @@ struct CodeScanner } } else if (auto* get = curr->dynCast<StructGet>()) { counts.note(get->ref->type); + // If the type we read is a reference type then we must include it. It is + // not written in the binary format, so it doesn't need to be counted, but + // it does need to be taken into account in the IR (this may be the only + // place this type appears in the entire binary, and we must scan all + // types as the analyses that use us depend on that). + counts.include(get->type); } else if (auto* set = curr->dynCast<StructSet>()) { counts.note(set->ref->type); } else if (auto* get = curr->dynCast<ArrayGet>()) { counts.note(get->ref->type); + // See note on StructGet above. + counts.include(get->type); } else if (auto* set = curr->dynCast<ArraySet>()) { counts.note(set->ref->type); - } else if (Properties::isControlFlowStructure(curr)) { if (curr->type.isTuple()) { // TODO: Allow control flow to have input types as well |