[llvm] r352551 - [WebAssembly] Ensure BasicSymbolRef.getRawDataRefImpl().p is non-null
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 29 14:22:33 PST 2019
Author: sbc
Date: Tue Jan 29 14:22:32 2019
New Revision: 352551
URL: http://llvm.org/viewvc/llvm-project?rev=352551&view=rev
Log:
[WebAssembly] Ensure BasicSymbolRef.getRawDataRefImpl().p is non-null
Store a non-zero value to ref.d.a and use ref.d.b to store the symbol
index. This means that ref.p is never null, which was confusing
llvm-nm.
Fixes PR40497
Differential Revision: https://reviews.llvm.org/D57373
Added:
llvm/trunk/test/tools/llvm-nm/wasm/extern-only.ll
Modified:
llvm/trunk/lib/Object/WasmObjectFile.cpp
llvm/trunk/test/tools/llvm-nm/lit.local.cfg
Modified: llvm/trunk/lib/Object/WasmObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/WasmObjectFile.cpp?rev=352551&r1=352550&r2=352551&view=diff
==============================================================================
--- llvm/trunk/lib/Object/WasmObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/WasmObjectFile.cpp Tue Jan 29 14:22:32 2019
@@ -1181,7 +1181,7 @@ const wasm::WasmObjectHeader &WasmObject
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 @@ uint32_t WasmObjectFile::getSymbolFlags(
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 {
Modified: llvm/trunk/test/tools/llvm-nm/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/lit.local.cfg?rev=352551&r1=352550&r2=352551&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-nm/lit.local.cfg (original)
+++ llvm/trunk/test/tools/llvm-nm/lit.local.cfg Tue Jan 29 14:22:32 2019
@@ -1,4 +1,4 @@
if not 'X86' in config.root.targets:
config.unsupported = True
-config.suffixes = ['.s', '.test', '.yaml']
+config.suffixes = ['.ll', '.s', '.test', '.yaml']
Added: llvm/trunk/test/tools/llvm-nm/wasm/extern-only.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/wasm/extern-only.ll?rev=352551&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-nm/wasm/extern-only.ll (added)
+++ llvm/trunk/test/tools/llvm-nm/wasm/extern-only.ll Tue Jan 29 14:22:32 2019
@@ -0,0 +1,23 @@
+; RUN: llc -filetype=obj -mtriple=wasm32-unknown-unknown -o %t.o %s
+; RUN: llvm-nm --extern-only %t.o | FileCheck %s
+
+; Verity that hidden symbols are listed even when --extern-only is passed
+
+define hidden i32 @foo() {
+entry:
+ ret i32 42
+}
+
+define i32 @bar() {
+entry:
+ ret i32 43
+}
+
+define internal i32 @baz() {
+entry:
+ ret i32 44
+}
+
+; CHECK: 00000006 T bar
+; CHECK-NOT: baz
+; CHECK: 00000001 T foo
More information about the llvm-commits
mailing list