This is an archive of the discontinued LLVM Phabricator instance.

[CSSPGO] Use preinliner decision by default when available
ClosedPublic

Authored by wenlei on Sep 1 2021, 4:31 PM.

Details

Summary

For CSSPGO, turn on sample-profile-use-preinliner by default. This simplifies the use of llvm-profgen preinliner as it's now simply driven by ContextShouldBeInlined flag for each context profile without needing extra compiler switch.

Note that llvm-profgen's preinliner is still off by default, under switch csspgo-preinliner.

Diff Detail

Event Timeline

wenlei created this revision.Sep 1 2021, 4:31 PM
wenlei requested review of this revision.Sep 1 2021, 4:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2021, 4:31 PM
hoy added inline comments.Sep 1 2021, 5:30 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
1303

Will non-inlined context be merged into the base profile by the preinliner? Wondering if we can have contexts without ContextShouldBeInlined in the profile after processed by the preinliner.

wenlei added inline comments.Sep 1 2021, 5:33 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
1303

Not inlined context will all be merged currently. See the comment I added above.

hoy added inline comments.Sep 1 2021, 5:38 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
1303

So we'll not see the context profile here? Can such context only be seen when the preinliner is off?

wenlei added inline comments.Sep 1 2021, 5:40 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
1303

Correct. When preinliner is on in llvm-profgen, we will only see context profile if preinliner decides to inline. When preinliner is off, we will see all context profiles.

hoy accepted this revision.Sep 1 2021, 5:43 PM
hoy added inline comments.
llvm/lib/Transforms/IPO/SampleProfile.cpp
1303

Thanks for the confirmation. Can you update the comment to reflect that?

This revision is now accepted and ready to land.Sep 1 2021, 5:43 PM
wenlei updated this revision to Diff 370127.Sep 1 2021, 5:55 PM

update test

wenlei added inline comments.Sep 1 2021, 6:01 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
1303

The comment mentions that:

Note that we don't need to handle negative decision from preinliner as context profile for not inlined calls are merged by preinliner already.

hoy added inline comments.Sep 1 2021, 6:30 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
1303

Oh, I actually meant to say there shouldn't be a negative decision from preinliner, since Candidate.CalleeSamples would be null in that case. I might misunderstand your comment.

wenlei added inline comments.Sep 1 2021, 8:29 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
1303

I actually meant to say there shouldn't be a negative decision from preinliner, since Candidate.CalleeSamples would be null in that case.

By decision from preinliner, it literally means inline decision made by preinliner in llvm-profgen. Preinliner would reject inlining for some calls, and these are the negative decision from preinliner.

Candidate.CalleeSamples will never be null. If preinliner makes a negative inline decision, the corresponding context profile won't exist, and we won't see the callee as inline candidate (see getInlineCandidate). That's why we don't need to handle negative decisions explicitly.

hoy added inline comments.Sep 1 2021, 9:51 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
1303

Sounds good.

This revision was automatically updated to reflect the committed changes.