|
23 | 23 |
|
24 | 24 | #include "ir/effects.h" |
25 | 25 | #include "ir/module-utils.h" |
| 26 | +#include "ir/subtypes.h" |
26 | 27 | #include "pass.h" |
27 | 28 | #include "support/unique_deferring_queue.h" |
28 | 29 | #include "wasm.h" |
@@ -117,8 +118,15 @@ std::unordered_map<HeapType, std::unordered_set<Name>> |
117 | 118 | typeToFunctionNames(const Module& module) { |
118 | 119 | std::unordered_map<HeapType, std::unordered_set<Name>> ret; |
119 | 120 |
|
| 121 | + // TODO |
| 122 | + SubTypes s(*const_cast<Module*>(&module)); |
| 123 | + |
120 | 124 | for (const auto& func : module.functions) { |
121 | | - ret[func->type.getHeapType()].insert(func->name); |
| 125 | + s.iterSubTypes(func->type.getHeapType(), [&ret, &func](HeapType type, int _) { |
| 126 | + std::cout<<"subtype "<< func->type.getHeapType() << " " << type<< "\n"; |
| 127 | + ret[type].insert(func->name); |
| 128 | + }); |
| 129 | + // ret[func->type.getHeapType()].insert(func->name); |
122 | 130 | } |
123 | 131 |
|
124 | 132 | return ret; |
@@ -166,13 +174,6 @@ transitiveClosure(const Module& module, |
166 | 174 | // caller => called => called by called |
167 | 175 | // |
168 | 176 | auto it = funcInfos.find(module.getFunction(called)); |
169 | | - |
170 | | - // TODO: this should never be missing? |
171 | | - if (it == funcInfos.end()) { |
172 | | - std::cout << "missing key " << called << "\n"; |
173 | | - throw(1); |
174 | | - // assert(false && ("missing key " + called)); |
175 | | - } |
176 | 177 | auto& calledInfo = it->second; |
177 | 178 | // auto& calledInfo = funcInfos.at(module.getFunction(called)); |
178 | 179 | for (auto calledByCalled : calledInfo.calledFunctions) { |
@@ -225,11 +226,6 @@ struct GenerateGlobalEffects : public Pass { |
225 | 226 | for (auto& [func, info] : funcInfos) { |
226 | 227 | indirectCallersNonTransitive[func->name]; |
227 | 228 | for (auto& calledType : info.indirectCalledTypes) { |
228 | | - // auto asdf = functionsWithType.at(calledType); |
229 | | - // auto foo = indirectCallersNonTransitive[func->name]; |
230 | | - // asdf.merge(foo); |
231 | | - // foo.merge(asdf); |
232 | | - |
233 | 229 | if (auto it = functionsWithType.find(calledType); |
234 | 230 | it != functionsWithType.end()) { |
235 | 231 | indirectCallersNonTransitive[func->name].insert(it->second.begin(), |
|
0 commit comments