[PATCH] D57373: [WebAssembly] Ensure BasicSymbolRef.getRawDataRefImpl().p is non-null
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 29 12:56:41 PST 2019
sbc100 updated this revision to Diff 184159.
sbc100 added a comment.
- fix comment
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57373/new/
https://reviews.llvm.org/D57373
Files:
lib/Object/WasmObjectFile.cpp
test/tools/llvm-nm/wasm/extern-only.ll
Index: test/tools/llvm-nm/wasm/extern-only.ll
===================================================================
--- /dev/null
+++ test/tools/llvm-nm/wasm/extern-only.ll
@@ -0,0 +1,9 @@
+; RUN: llc -filetype=obj -mtriple=wasm32-unknown-unknown -o %t.o %s
+; RUN: llvm-nm --extern-only %t.o | FileCheck %s
+
+define hidden i32 @foo() {
+entry:
+ ret i32 42
+}
+
+; CHECK: 00000001 T foo
Index: lib/Object/WasmObjectFile.cpp
===================================================================
--- lib/Object/WasmObjectFile.cpp
+++ lib/Object/WasmObjectFile.cpp
@@ -1181,7 +1181,7 @@
return Header;
}
-void WasmObjectFile::moveSymbolNext(DataRefImpl &Symb) const { Symb.d.a++; }
+void WasmObjectFile::moveSymbolNext(DataRefImpl &Symb) const { Symb.d.b++; }
uint32_t WasmObjectFile::getSymbolFlags(DataRefImpl Symb) const {
uint32_t Result = SymbolRef::SF_None;
@@ -1203,18 +1203,20 @@
basic_symbol_iterator WasmObjectFile::symbol_begin() const {
DataRefImpl Ref;
- Ref.d.a = 0;
+ Ref.d.a = 1; // Arbitrary non-zero value so that Ref.p is non-null
+ Ref.d.b = 0; // Symbol index
return BasicSymbolRef(Ref, this);
}
basic_symbol_iterator WasmObjectFile::symbol_end() const {
DataRefImpl Ref;
- Ref.d.a = Symbols.size();
+ Ref.d.a = 1; // Arbitrary non-zero value so that Ref.p is non-null
+ Ref.d.b = Symbols.size(); // Symbol index
return BasicSymbolRef(Ref, this);
}
const WasmSymbol &WasmObjectFile::getWasmSymbol(const DataRefImpl &Symb) const {
- return Symbols[Symb.d.a];
+ return Symbols[Symb.d.b];
}
const WasmSymbol &WasmObjectFile::getWasmSymbol(const SymbolRef &Symb) const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57373.184159.patch
Type: text/x-patch
Size: 1631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190129/a069ebe8/attachment.bin>
More information about the llvm-commits
mailing list