This is an archive of the discontinued LLVM Phabricator instance.

[PseudoProbe] Decode offset based pseudo probe.
ClosedPublic

Authored by hoy on Oct 13 2022, 1:46 PM.

Details

Reviewers
wenlei
wlei
Summary

This is the corresponding decoding change to D135912: [PseudoProbe] Replace relocation with offset for entry probe.. The change is downwards compatible as long as there's no mixed use of the old encoding and the new encoding.

Diff Detail

Event Timeline

hoy created this revision.Oct 13 2022, 1:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 13 2022, 1:46 PM
hoy requested review of this revision.Oct 13 2022, 1:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 13 2022, 1:46 PM
hoy updated this revision to Diff 468268.Oct 17 2022, 11:21 AM

Updating D135914: [PseudoProbe] Decode offset based pseudo probe.

hoy updated this revision to Diff 468315.Oct 17 2022, 2:08 PM
hoy edited the summary of this revision. (Show Details)

Updating D135914: [PseudoProbe] Decode offset based pseudo probe.

maksfb added a subscriber: maksfb.Oct 20 2022, 5:06 PM
maksfb added inline comments.
llvm/include/llvm/MC/MCPseudoProbe.h
349
374–375

You probably want to use DenseSet and DenseMap for these and then use type aliases for the interface.

hoy updated this revision to Diff 469653.Oct 21 2022, 9:21 AM

Addressing comments.

llvm/include/llvm/MC/MCPseudoProbe.h
349

Good catch, thanks.

374–375

Sounds good, fixed.

There are a couple more uses of std::*map<> left that could be converted to maps from LLVM's ADT.

hoy added a comment.Oct 21 2022, 2:59 PM

There are a couple more uses of std::*map<> left that could be converted to maps from LLVM's ADT.

Yes, std::map is used everywhere in llvm-profgen. Do you think ADT performs better than it? I can do a separate refactoring if you don't mind.

Yes, std::map is used everywhere in llvm-profgen. Do you think ADT performs better than it? I can do a separate refactoring if you don't mind.

I had this diff in mind, but the refactoring sounds good too. ADT avoids malloc, more details at: https://llvm.org/docs/ProgrammersManual.html#map-like-containers-std-map-densemap-etc

hoy added a comment.Oct 21 2022, 3:12 PM

Yes, std::map is used everywhere in llvm-profgen. Do you think ADT performs better than it? I can do a separate refactoring if you don't mind.

I had this diff in mind, but the refactoring sounds good too. ADT avoids malloc, more details at: https://llvm.org/docs/ProgrammersManual.html#map-like-containers-std-map-densemap-etc

I see. Looks like it's great for small keys and values. I'll go through the code base and adjust existing std::map usage (not only for the ones introduced here). Will make a separate change.

Sounds good.

hoy added a comment.Oct 21 2022, 3:36 PM

Sounds good.

Actually let me change the std::unordered_map introduced by this change to DenseMap. The refactoring will likely to take a bit longer.

hoy updated this revision to Diff 469804.Oct 21 2022, 3:37 PM

Replacing std::unodered_map with DenseMap.

hoy updated this revision to Diff 469809.Oct 21 2022, 3:48 PM

Renaming uint64_set to Uint64Set

Sentinel probe case isn't covered for both encoding and decoding in any test cases, would be good to have some coverage.

llvm/lib/MC/MCPseudoProbe.cpp
430

nit: Cur == &DummyInlineRoot -> IsTopLevelFunc

488

Maybe I'm asking the same question as the one on previous patch, but why do we still have cases with absolute address encoded? I thought for main function body we have GUID -> symbol (reverse lookup) -> address; and we have similar way to get address for sentinel for split binary function. The rest should all be offset/delta.

hoy added a comment.Oct 25 2022, 9:34 AM

Sentinel probe case isn't covered for both encoding and decoding in any test cases, would be good to have some coverage.

Forgot to mention that the updated binary, i.e, inline-cs-pseudoprobe.perfbin, is built with the new encoding. The binary supports a dozen llvm-profgen tests and they all pass with the current decoding changes.

llvm/lib/MC/MCPseudoProbe.cpp
430

Done.

488

This is mainly for downwards-compatibility, i.e. to have new llvm-profgen handle old binaries.

hoy updated this revision to Diff 470534.Oct 25 2022, 9:35 AM

Addressing feedbacks.

Sentinel probe case isn't covered for both encoding and decoding in any test cases, would be good to have some coverage.

Forgot to mention that the updated binary, i.e, inline-cs-pseudoprobe.perfbin, is built with the new encoding. The binary supports a dozen llvm-profgen tests and they all pass with the current decoding changes.

Do we have a split function case in the existing tests? I thought we don't, but if we have, that'd be good enough.

llvm/lib/MC/MCPseudoProbe.cpp
488

Ok, makes sense. Like I mentioned in the other patch, add a comment explaining this is for backward compatibility and a todo for removal?

hoy added a comment.Oct 25 2022, 3:05 PM

Sentinel probe case isn't covered for both encoding and decoding in any test cases, would be good to have some coverage.

Forgot to mention that the updated binary, i.e, inline-cs-pseudoprobe.perfbin, is built with the new encoding. The binary supports a dozen llvm-profgen tests and they all pass with the current decoding changes.

Do we have a split function case in the existing tests? I thought we don't, but if we have, that'd be good enough.

Good point. The test binary func-split.perfbin is updated.

llvm/lib/MC/MCPseudoProbe.cpp
488

Done.

hoy updated this revision to Diff 470620.Oct 25 2022, 3:05 PM

Updating D135914: [PseudoProbe] Decode offset based pseudo probe.

wenlei accepted this revision.Oct 26 2022, 10:40 AM

lgtm, with a nit on naming.

llvm/lib/MC/MCPseudoProbe.cpp
482

nit: binary function -> split function

This revision is now accepted and ready to land.Oct 26 2022, 10:40 AM
hoy updated this revision to Diff 470877.Oct 26 2022, 11:08 AM

Updating D135914: [PseudoProbe] Decode offset based pseudo probe.

hoy closed this revision.Oct 27 2022, 2:33 PM

Closed by commit rGd5a963ab8b40