[PATCH] D42753: [WebAssembly] Add LLD support for defined globals
Nicholas Wilson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 31 11:22:20 PST 2018
ncw created this revision.
ncw added a reviewer: sbc100.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff, jfb.
Makes use of the new constants added in https://reviews.llvm.org/D42752. Comes after https://reviews.llvm.org/D42585.
Probably should be updated with an extra test - but I'm pretty sure it is working.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D42753
Files:
wasm/InputChunks.h
wasm/InputFiles.cpp
wasm/Writer.cpp
Index: wasm/Writer.cpp
===================================================================
--- wasm/Writer.cpp
+++ wasm/Writer.cpp
@@ -462,6 +462,12 @@
Comdats[Comdat].emplace_back(
ComdatEntry{WASM_COMDAT_FUNCTION, F->getOutputIndex()});
}
+ for (const InputGlobal *G : DefinedGlobals) {
+ StringRef Comdat = G->getComdat();
+ if (!Comdat.empty())
+ Comdats[Comdat].emplace_back(
+ ComdatEntry{WASM_COMDAT_GLOBAL, G->getOutputIndex()});
+ }
for (uint32_t I = 0; I < Segments.size(); ++I) {
const auto &InputSegments = Segments[I]->InputSegments;
if (InputSegments.empty())
Index: wasm/InputFiles.cpp
===================================================================
--- wasm/InputFiles.cpp
+++ wasm/InputFiles.cpp
@@ -296,8 +296,13 @@
case WasmSymbol::SymbolType::GLOBAL:
if (WasmSym.WasmIndex >= NumGlobalImports) {
InputGlobal *Global = getGlobal(WasmSym);
- S = createDefined(WasmSym, Symbol::Kind::DefinedGlobalKind, Global);
- break;
+ if (!isExcludedByComdat(Global)) {
+ S = createDefined(WasmSym, Symbol::Kind::DefinedGlobalKind, Global);
+ break;
+ } else {
+ Global->Discarded = true;
+ // Exclude global, and add the symbol as undefined
+ }
}
S = createUndefined(WasmSym, Symbol::Kind::UndefinedGlobalKind);
break;
Index: wasm/InputChunks.h
===================================================================
--- wasm/InputChunks.h
+++ wasm/InputChunks.h
@@ -194,7 +194,7 @@
}
virtual const WasmInitExpr &initExpr() const { return Global->InitExpr; }
- StringRef getComdat() const override { return StringRef(); }
+ StringRef getComdat() const override { return Global->Comdat; }
uint32_t getOutputIndex() const override { return OutputIndex.getValue(); }
bool hasOutputIndex() const override { return OutputIndex.hasValue(); }
void setOutputIndex(uint32_t Index);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42753.132227.patch
Type: text/x-patch
Size: 1967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180131/11a9ef5f/attachment.bin>
More information about the llvm-commits
mailing list