This is an archive of the discontinued LLVM Phabricator instance.

[llvm-nm][WebAssembly] Report the size of data symbols
ClosedPublic

Authored by sbc100 on Aug 24 2023, 5:06 PM.

Diff Detail

Event Timeline

sbc100 created this revision.Aug 24 2023, 5:06 PM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added subscribers: pmatos, asb, wingo and 4 others. · View Herald Transcript
sbc100 requested review of this revision.Aug 24 2023, 5:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2023, 5:06 PM
sbc100 updated this revision to Diff 553309.Aug 24 2023, 5:07 PM
  • add test

Makes sense to me, but perhaps one additional test case needed. I'll leave @dschuff to give final approval though.

llvm/test/tools/llvm-nm/wasm/print-size.test
29

Perhaps worth showing that a symbol that isn't in the data segment doesn't have a size printed too?

llvm/tools/llvm-nm/llvm-nm.cpp
1822

Nit: not clang-formatted.

Otherwise this looks good.

llvm/test/tools/llvm-nm/wasm/print-size.test
29

+1, showing other symbol kinds seems like a good idea as long as we're creating this test. Maybe get one BSS and a function symbol?

sbc100 updated this revision to Diff 553650.Aug 25 2023, 3:35 PM
  • Add a function symbol, demonstrating that function symbols are unsized

Otherwise this looks good.

I added a function symbol.

I'm not sure its worth adding a BSS symbol. They are only distinguished by the segment in which they live (name starting with .bss... otherwise there is nothing special about them. )

Otherwise this looks good.

I added a function symbol.

I'm not sure its worth adding a BSS symbol. They are only distinguished by the segment in which they live (name starting with .bss... otherwise there is nothing special about them. )

Do they have a size?
Actually, what is the size supposed to represent? The size in the file or the initialized size in wasm memory? I guess in other platforms its the virtual memory size, right?

Otherwise this looks good.

I added a function symbol.

I'm not sure its worth adding a BSS symbol. They are only distinguished by the segment in which they live (name starting with .bss... otherwise there is nothing special about them. )

Do they have a size?
Actually, what is the size supposed to represent? The size in the file or the initialized size in wasm memory? I guess in other platforms its the virtual memory size, right?

yes they have a size just like any other data symbol.

sbc100 updated this revision to Diff 553660.Aug 25 2023, 4:09 PM
  • clang-format

actually, what about globals, e.g. __stack_pointer? Do they also have a size?

actually, what about globals, e.g. __stack_pointer? Do they also have a size?

No, they are of a different type. WASM_SYMBOL_TYPE_GLOBAL vs WASM_SYMBOL_TYPE_DATA.

actually, what about globals, e.g. __stack_pointer? Do they also have a size?

No, they are of a different type. WASM_SYMBOL_TYPE_GLOBAL vs WASM_SYMBOL_TYPE_DATA.

So in the context of this patch they would return false in the WasmSym.isTypeData() check.

dschuff accepted this revision.Aug 25 2023, 4:36 PM

Ah, got it, makes sense.

This revision is now accepted and ready to land.Aug 25 2023, 4:36 PM
This revision was landed with ongoing or failed builds.Aug 25 2023, 4:48 PM
This revision was automatically updated to reflect the committed changes.