Skip to content

Commit

Permalink
[WebAssembly] Move direct call tracking from member to local. NFC.
Browse files Browse the repository at this point in the history
This data structure is only needed temporarily while symbols are being
created.

This is a followup on rL361678.

Differential Revision: https://reviews.llvm.org/D62548

llvm-svn: 361977
  • Loading branch information
sbc100 committed May 29, 2019
1 parent 9ce3746 commit 56e970d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
13 changes: 10 additions & 3 deletions lld/wasm/InputFiles.cpp
Expand Up @@ -272,7 +272,14 @@ void ObjFile::parse(bool IgnoreComdats) {
}

uint32_t SectionIndex = 0;
SymbolIsCalledDirectly.resize(WasmObj->getNumberOfSymbols(), false);

// Bool for each symbol, true if called directly. This allows us to implement
// a weaker form of signature checking where undefined functions that are not
// called directly (i.e. only address taken) don't have to match the defined
// function's signature. We cannot do this for directly called functions
// because those signatures are checked at validation times.
// See https://bugs.llvm.org/show_bug.cgi?id=40412
std::vector<bool> IsCalledDirectly(WasmObj->getNumberOfSymbols(), false);
for (const SectionRef &Sec : WasmObj->sections()) {
const WasmSection &Section = WasmObj->getWasmSection(Sec);
// Wasm objects can have at most one code and one data section.
Expand All @@ -292,7 +299,7 @@ void ObjFile::parse(bool IgnoreComdats) {
// directly
for (const WasmRelocation &Reloc : Section.Relocations)
if (Reloc.Type == R_WASM_FUNCTION_INDEX_LEB)
SymbolIsCalledDirectly[Reloc.Index] = true;
IsCalledDirectly[Reloc.Index] = true;
}

TypeMap.resize(getWasmObj()->types().size());
Expand Down Expand Up @@ -342,7 +349,7 @@ void ObjFile::parse(bool IgnoreComdats) {
}
}
size_t Idx = Symbols.size();
Symbols.push_back(createUndefined(WasmSym, SymbolIsCalledDirectly[Idx]));
Symbols.push_back(createUndefined(WasmSym, IsCalledDirectly[Idx]));
}
}

Expand Down
7 changes: 0 additions & 7 deletions lld/wasm/InputFiles.h
Expand Up @@ -69,13 +69,6 @@ class InputFile {

// List of all symbols referenced or defined by this file.
std::vector<Symbol *> Symbols;
// Bool for each symbol, true if called directly. This allows us to implement
// a weaker form of signature checking where undefined functions that are not
// called directly (i.e. only address taken) don't have to match the defined
// function's signature. We cannot do this for directly called functions
// because those signatures are checked at validation times.
// See https://bugs.llvm.org/show_bug.cgi?id=40412
std::vector<bool> SymbolIsCalledDirectly;

private:
const Kind FileKind;
Expand Down

0 comments on commit 56e970d

Please sign in to comment.