Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

wasm: Implement comdat nodeduplicate #49501

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR50531
Status NEW
Importance P enhancement
Reported by Fangrui Song (i@maskray.me)
Reported on 2021-05-29 22:21:39 -0700
Last modified on 2021-07-20 22:50:37 -0700
Version trunk
Hardware PC Linux
CC dschuff@google.com, llvm-bugs@lists.llvm.org, sbc@chromium.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

Regular comdat any performs deduplication with the symbol name as the key.

comdat noduplicates is useful to express that a group of sections should be retained or discarded as a unit. This is currently unimplemented for wasm.

This feature is useful for certain metadata sections. In the simplest non-value-profiling PGO/coverage case. A function needs two metadata sections: llvm_prf_cnts, llvm_prf_data. The code references llvm_prf_cnts but llvm_prf_data is unreferenced. We can place the pair of cnts/data in a comdat noduplicates to let the liveness of cnts retain data.

Quuxplusone commented 3 years ago

The IR comdat name lowers to (ELF) a signature symbol and (PE-COFF) a leader symbol. For comdat noduplicates, the group name has no significance to the linker.

Quuxplusone commented 3 years ago

We have comdat groups (where a group of e.g. a data and a code section and a debuginfo section can be retained or discarded as a group) at the MC level today. I guess this bug is for hooking up comdat noduplicates at the IR level to that feature?

Quuxplusone commented 3 years ago

I not heard of ELF signature symbols, and I can't seem to find any information on them in the docs.

Thanks for providing PGO as an example of comdat noduplicates in action. Hopefully we can use that as motivating example to implement this.

Does every single function get its own llvm_prf_cnts and llvm_prf_data? Could the comdat noduplicates be implemented as symbol with local binding (in which case its name would not matter)?