[llvm] [llvm-nm][WebAssembly] Print function symbol sizes (PR #81315)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 9 12:40:25 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-binary-utilities
Author: Derek Schuff (dschuff)
<details>
<summary>Changes</summary>
nm already prints sizes for data symbols. Do that for function symbols too.
---
Full diff: https://github.com/llvm/llvm-project/pull/81315.diff
3 Files Affected:
- (modified) llvm/test/tools/llvm-nm/wasm/linked.yaml (+5)
- (modified) llvm/test/tools/llvm-nm/wasm/print-size.test (+1-1)
- (modified) llvm/tools/llvm-nm/llvm-nm.cpp (+5)
``````````diff
diff --git a/llvm/test/tools/llvm-nm/wasm/linked.yaml b/llvm/test/tools/llvm-nm/wasm/linked.yaml
index 992c1811743b7a..6aee4b9fc184c4 100644
--- a/llvm/test/tools/llvm-nm/wasm/linked.yaml
+++ b/llvm/test/tools/llvm-nm/wasm/linked.yaml
@@ -1,10 +1,15 @@
# RUN: yaml2obj %s -o %t.wasm
# RUN: llvm-nm %t.wasm | FileCheck %s
+# RUN: llvm-nm -P %t.wasm | FileCheck %s --check-prefix=POSIX
# CHECK: 0000009f T my_func_export
# CHECK-NEXT: 0000002a D my_global_export
# CHECK-NEXT: 00000000 D my_table_export
+# POSIX: my_func_export T 9f 3
+# POSIX-NEXT: my_global_export D 2a 0
+# POSIX-NEXT: my_table_export D 0 0
+
--- !WASM
FileHeader:
Version: 0x1
diff --git a/llvm/test/tools/llvm-nm/wasm/print-size.test b/llvm/test/tools/llvm-nm/wasm/print-size.test
index c166edb4641c4b..610929b959b5f1 100644
--- a/llvm/test/tools/llvm-nm/wasm/print-size.test
+++ b/llvm/test/tools/llvm-nm/wasm/print-size.test
@@ -43,4 +43,4 @@ Sections:
Size: 32
# CHECK: 00000000 00000020 D a_data_symbol
-# CHECK: 00000001 00000000 T a_func
+# CHECK: 00000001 0000000d T a_func
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index da5998b70ea3f3..51f7e417306cf6 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -1858,6 +1858,11 @@ static bool getSymbolNamesFromObject(SymbolicFile &Obj,
const WasmSymbol &WasmSym = WasmObj->getWasmSymbol(Sym);
if (WasmSym.isTypeData() && !WasmSym.isUndefined())
S.Size = WasmSym.Info.DataRef.Size;
+ if (WasmSym.isTypeFunction() && !WasmSym.isUndefined())
+ S.Size = WasmObj
+ ->functions()[WasmSym.Info.ElementIndex -
+ WasmObj->getNumImportedFunctions()]
+ .Size;
}
if (PrintAddress && isa<ObjectFile>(Obj)) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/81315
More information about the llvm-commits
mailing list