Index: wasm/Writer.cpp =================================================================== --- wasm/Writer.cpp +++ wasm/Writer.cpp @@ -891,7 +891,7 @@ } void Writer::assignIndexes() { - uint32_t FunctionIndex = NumImportedFunctions + InputFunctions.size(); + uint32_t FunctionIndex = NumImportedFunctions; auto AddDefinedFunction = [&](InputFunction *Func) { if (!Func->Live) return; @@ -940,7 +940,7 @@ HandleRelocs(P); } - uint32_t GlobalIndex = NumImportedGlobals + InputGlobals.size(); + uint32_t GlobalIndex = NumImportedGlobals; auto AddDefinedGlobal = [&](InputGlobal *Global) { if (Global->Live) { LLVM_DEBUG(dbgs() << "AddDefinedGlobal: " << GlobalIndex << "\n");