This is an archive of the discontinued LLVM Phabricator instance.

[llvm-profgen] Support symbol list for accurate profile
ClosedPublic

Authored by wlei on Sep 30 2021, 10:43 AM.

Details

Summary

Support symbol list in profile generation along with extended binary format.

Diff Detail

Event Timeline

wlei created this revision.Sep 30 2021, 10:43 AM
wlei requested review of this revision.Sep 30 2021, 10:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 30 2021, 10:43 AM
hoy added a comment.Oct 1 2021, 12:07 PM

Thanks for bringing this up. Can you make this optional under a switch? Should be on by default. Currently without a switch we have to go a round trip (ext->txt->ext) to get rid of the symbol list in an extbinary profile.

llvm/tools/llvm-profgen/ProfileGenerator.cpp
128

Move this into the if block above?

wlei updated this revision to Diff 376649.Oct 1 2021, 4:09 PM

add a switch

wlei added a comment.Oct 1 2021, 4:10 PM

Thanks for bringing this up. Can you make this optional under a switch? Should be on by default. Currently without a switch we have to go a round trip (ext->txt->ext) to get rid of the symbol list in an extbinary profile.

I see, thanks for pointing out, switch added.

llvm/tools/llvm-profgen/ProfileGenerator.cpp
128

Fixed!

hoy accepted this revision.Oct 1 2021, 5:25 PM

LGTM. We probably need this for CS profile too.

llvm/tools/llvm-profgen/ProfileGenerator.cpp
121

This can be moved into the if block too.

This revision is now accepted and ready to land.Oct 1 2021, 5:25 PM
wlei added inline comments.Oct 1 2021, 5:29 PM
llvm/tools/llvm-profgen/ProfileGenerator.cpp
121

SymbolList is used inside Writer.write(ProfileMap) as a pointer, moving it into if block will causing the dangling pointer issue.

hoy added inline comments.Oct 1 2021, 5:31 PM
llvm/tools/llvm-profgen/ProfileGenerator.cpp
121

I see. Good point.

wenlei added inline comments.Oct 4 2021, 10:24 AM
llvm/tools/llvm-profgen/ProfileGenerator.cpp
117

Looking at the implementation, seems it should work for CS profile too? Profile.getName() only gets the leaf name instead of full context name, we just need to deduplicate the leaf name for CS profile. So I'm wondering if we can move it to ProfileGeneratorBase::write so it covers both CS and non-CS profile?

wlei updated this revision to Diff 377396.Oct 5 2021, 5:27 PM
wlei edited the summary of this revision. (Show Details)

add support for CS profile generation

wlei added inline comments.Oct 5 2021, 5:28 PM
llvm/tools/llvm-profgen/ProfileGenerator.cpp
117

Sounds good, added to support CS profile.

hoy added inline comments.Oct 5 2021, 6:26 PM
llvm/tools/llvm-profgen/ProfileGenerator.cpp
35

On the second thought, do we want the default value of PopulateProfileSymbolList to be true or false? We probably do not want the list for either CS or non-CS in practice for now.

101

Use const FunctionSamples& ?

wlei updated this revision to Diff 377420.Oct 5 2021, 9:15 PM

addressing feedback

wlei added inline comments.Oct 5 2021, 9:18 PM
llvm/tools/llvm-profgen/ProfileGenerator.cpp
35

I checked that our internal tools make it on by default for non-CS. But we haven't tested for CS profile.

Or we can make it off for CS util we tested it and then we can turn on?

101

Good catch, thanks!

wenlei added inline comments.Oct 5 2021, 10:45 PM
llvm/tools/llvm-profgen/ProfileGenerator.cpp
35

Leave it default on, but turn it off for CS profile unless explicitly specified sounds good to me.

wlei updated this revision to Diff 377438.Oct 5 2021, 11:09 PM

made it off for CS profile.

wenlei accepted this revision.Oct 5 2021, 11:27 PM

lgtm, thanks.

hoy accepted this revision.Oct 6 2021, 8:45 AM

lgtm.

This revision was automatically updated to reflect the committed changes.