5050
5151#include " ir/find_all.h"
5252#include " ir/module-utils.h"
53- #include " ir/properties .h"
53+ #include " ir/possible-constant .h"
5454#include " ir/subtypes.h"
5555#include " ir/utils.h"
5656#include " pass.h"
@@ -300,24 +300,23 @@ struct GlobalStructInference : public Pass {
300300
301301 // Find the constant values and which globals correspond to them.
302302 // TODO: SmallVectors?
303- std::vector<Literal > values;
303+ std::vector<PossibleConstantValues > values;
304304 std::vector<std::vector<Name>> globalsForValue;
305305
306306 // Check if the relevant fields contain constants.
307307 auto fieldType = field.type ;
308308 for (Index i = 0 ; i < globals.size (); i++) {
309309 Name global = globals[i];
310310 auto * structNew = wasm.getGlobal (global)->init ->cast <StructNew>();
311- Literal value;
311+ PossibleConstantValues value;
312312 if (structNew->isWithDefault ()) {
313- value = Literal::makeZero (fieldType);
313+ value. note ( Literal::makeZero (fieldType) );
314314 } else {
315- auto * init = structNew->operands [fieldIndex];
316- if (!Properties::isConstantExpression (init )) {
317- // Non-constant; give up entirely.
315+ value. note ( structNew->operands [fieldIndex], wasm) ;
316+ if (!value. isConstant ( )) {
317+ // Give up entirely.
318318 return ;
319319 }
320- value = Properties::getLiteral (init);
321320 }
322321
323322 // Process the current value, comparing it against the previous.
@@ -346,7 +345,7 @@ struct GlobalStructInference : public Pass {
346345 // otherwise return the value.
347346 replaceCurrent (builder.makeSequence (
348347 builder.makeDrop (builder.makeRefAs (RefAsNonNull, curr->ref )),
349- builder. makeConstantExpression ( values[0 ])));
348+ values[0 ]. makeExpression (wasm )));
350349 return ;
351350 }
352351 assert (values.size () == 2 );
@@ -373,8 +372,8 @@ struct GlobalStructInference : public Pass {
373372 builder.makeRefEq (builder.makeRefAs (RefAsNonNull, curr->ref ),
374373 builder.makeGlobalGet (
375374 checkGlobal, wasm.getGlobal (checkGlobal)->type )),
376- builder. makeConstantExpression ( values[0 ]),
377- builder. makeConstantExpression ( values[1 ])));
375+ values[0 ]. makeExpression (wasm ),
376+ values[1 ]. makeExpression (wasm )));
378377 }
379378
380379 void visitFunction (Function* func) {
0 commit comments