[WebAssembly] Make starting indices calcaulation simpler (NFC)
Summary:
At the beginning of `assignIndexes() function, when `FunctionIndex` and
`GlobalIndex` variables are created, `InputFunctions` and `InputGlobals`
vectors are guaranteed to be empty, because those vectors are only
populated in `assignIndexes()` function. Current code looks like they
are nonempty, so this patch deletes them for better readability.
Reviewers: sbc100
Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D54687
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@347272 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/wasm/Writer.cpp b/wasm/Writer.cpp
index b5abb6b..a755a0d 100644
--- a/wasm/Writer.cpp
+++ b/wasm/Writer.cpp
@@ -891,7 +891,8 @@
}
void Writer::assignIndexes() {
- uint32_t FunctionIndex = NumImportedFunctions + InputFunctions.size();
+ assert(InputFunctions.empty());
+ uint32_t FunctionIndex = NumImportedFunctions;
auto AddDefinedFunction = [&](InputFunction *Func) {
if (!Func->Live)
return;
@@ -940,7 +941,8 @@
HandleRelocs(P);
}
- uint32_t GlobalIndex = NumImportedGlobals + InputGlobals.size();
+ assert(InputGlobals.empty());
+ uint32_t GlobalIndex = NumImportedGlobals;
auto AddDefinedGlobal = [&](InputGlobal *Global) {
if (Global->Live) {
LLVM_DEBUG(dbgs() << "AddDefinedGlobal: " << GlobalIndex << "\n");