This is an archive of the discontinued LLVM Phabricator instance.

[PseudoProbe] Disgard probes for dead functions.
AbandonedPublic

Authored by hoy on Jun 9 2023, 4:42 PM.

Details

Reviewers
wenlei
wlei
Summary

Probes of dead functions may be left over in the final binary for some reason, and they should be disgarded during decoding. The llvm-profgen profile generation path should already disgarded them due to its on-demand style decoding. I'm fixing for the --show-disassembly path which unconditionally decodes all probes.

Diff Detail

Event Timeline

hoy created this revision.Jun 9 2023, 4:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 4:42 PM
hoy requested review of this revision.Jun 9 2023, 4:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 4:42 PM
wenlei added a comment.Jun 9 2023, 6:00 PM

Probes of dead functions may be left over in the final binary for some reason,

How many probes (in terms of % size) belong to dead functions? Can we avoid emitting these probes in the first place?

hoy added a comment.Jun 12 2023, 9:33 AM

Probes of dead functions may be left over in the final binary for some reason,

How many probes (in terms of % size) belong to dead functions? Can we avoid emitting these probes in the first place?

Very little. Currently probes are emitted along with the binary code for functions and the linker is responsible for removing dead code. For probes, the linker can also remove them with the implementation D146853: [Pseudo Probe] Placing .pseudoprobe section in the same comdat group with .text. However, since dead probes are very little, probably due to the thinLTO compiler backend doing a good job removing dead functions already, I'm switching to the implementation D152546: [Pseudo Probe] Placing .pseudoprobe section in a comdat group, which doesn't enable the linker to remove dead probes but has other benefits.

Currently probes are emitted along with the binary code for functions and the linker is responsible for removing dead code. For probes, the linker can also remove them with the implementation

why do we still have probe for dead functions with this current implementation though?

Very little.

How much in terms .pseudo_probe section size?

I'm switching to the implementation D152546: [Pseudo Probe] Placing .pseudoprobe section in a comdat group, which doesn't enable the linker to remove dead probes but has other benefits.

It looks the trade off with the new implementation is that, we would allow ICF for probe section, but would also disable REF when its associated code is being removed?

hoy added a comment.Jun 13 2023, 9:19 AM

Currently probes are emitted along with the binary code for functions and the linker is responsible for removing dead code. For probes, the linker can also remove them with the implementation

why do we still have probe for dead functions with this current implementation though?

The current implementation doesn't place pseudo probes in the same comdat group with the text section, so a probe section won't be removed when the corresponding text section is dead removed by the linker. This is what D146853 is supposed to fix.

Dead probes can be completed removed by the thinLTO backend only. The only ones survive are for the functions removed by the native linker.

Very little.

How much in terms .pseudo_probe section size?

Less than 1% savings when I enabled D146853.

I'm switching to the implementation D152546: [Pseudo Probe] Placing .pseudoprobe section in a comdat group, which doesn't enable the linker to remove dead probes but has other benefits.

It looks the trade off with the new implementation is that, we would allow ICF for probe section, but would also disable REF when its associated code is being removed?

Right, there is no connection between probes and code with the new implementation. It has a benefit of fully deduplicating probes even for static functions injected by the compiler which does not have unique linkage name.

hoy abandoned this revision.EditedJun 16 2023, 9:25 AM