[PATCH] D71793: [WebAssembly] Support wasm exports with zero-length names.
sunfishcode via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 26 16:53:01 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG66bfbedbdfb9: [WebAssembly] Support wasm exports with zero-length names. (authored by sunfishcode).
Changed prior to commit:
https://reviews.llvm.org/D71793?vs=234999&id=253017#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71793/new/
https://reviews.llvm.org/D71793
Files:
lld/test/wasm/export-name.ll
lld/wasm/InputChunks.h
lld/wasm/Writer.cpp
llvm/include/llvm/BinaryFormat/Wasm.h
Index: llvm/include/llvm/BinaryFormat/Wasm.h
===================================================================
--- llvm/include/llvm/BinaryFormat/Wasm.h
+++ llvm/include/llvm/BinaryFormat/Wasm.h
@@ -132,7 +132,7 @@
uint32_t CodeSectionOffset;
uint32_t Size;
uint32_t CodeOffset; // start of Locals and Body
- StringRef ExportName; // from the "export" section
+ Optional<StringRef> ExportName; // from the "export" section
StringRef SymbolName; // from the "linking" section
StringRef DebugName; // from the "name" section
uint32_t Comdat; // from the "comdat info" section
Index: lld/wasm/Writer.cpp
===================================================================
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -520,9 +520,8 @@
StringRef name = sym->getName();
WasmExport export_;
if (auto *f = dyn_cast<DefinedFunction>(sym)) {
- StringRef exportName = f->function->getExportName();
- if (!exportName.empty()) {
- name = exportName;
+ if (Optional<StringRef> exportName = f->function->getExportName()) {
+ name = *exportName;
}
export_ = {name, WASM_EXTERNAL_FUNCTION, f->getFunctionIndex()};
} else if (auto *g = dyn_cast<DefinedGlobal>(sym)) {
Index: lld/wasm/InputChunks.h
===================================================================
--- lld/wasm/InputChunks.h
+++ lld/wasm/InputChunks.h
@@ -130,8 +130,8 @@
void writeTo(uint8_t *sectionStart) const override;
StringRef getName() const override { return function->SymbolName; }
StringRef getDebugName() const override { return function->DebugName; }
- StringRef getExportName() const {
- return function ? function->ExportName : "";
+ llvm::Optional<StringRef> getExportName() const {
+ return function ? function->ExportName : llvm::Optional<StringRef>();
}
uint32_t getComdat() const override { return function->Comdat; }
uint32_t getFunctionInputOffset() const { return getInputSectionOffset(); }
Index: lld/test/wasm/export-name.ll
===================================================================
--- lld/test/wasm/export-name.ll
+++ lld/test/wasm/export-name.ll
@@ -8,6 +8,10 @@
ret void
}
+define void @qux() #1 {
+ ret void
+}
+
define void @_start() {
call void @foo()
ret void
@@ -15,6 +19,8 @@
attributes #0 = { "wasm-export-name"="bar" }
+attributes #1 = { "wasm-export-name"="" }
+
; CHECK: - Type: EXPORT
; CHECK-NEXT: Exports:
; CHECK-NEXT: - Name: memory
@@ -23,6 +29,9 @@
; CHECK-NEXT: - Name: bar
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 0
-; CHECK-NEXT: - Name: _start
+; CHECK-NEXT: - Name: ''
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 1
+; CHECK-NEXT: - Name: _start
+; CHECK-NEXT: Kind: FUNCTION
+; CHECK-NEXT: Index: 2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71793.253017.patch
Type: text/x-patch
Size: 2989 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200326/1e030bef/attachment.bin>
More information about the llvm-commits
mailing list