This is an archive of the discontinued LLVM Phabricator instance.

Disable loop unrolling and icp in SamplePGO ThinLTO compile phase
ClosedPublic

Authored by danielcdh on Mar 21 2017, 2:55 PM.

Details

Summary

loop unrolling and icp will make the sample profile annotation much harder in the backend. So disable these 2 optimization in the ThinLTO compile phase.
Will add a test in cfe in a separate patch.

Event Timeline

danielcdh created this revision.Mar 21 2017, 2:55 PM
mehdi_amini added inline comments.Mar 21 2017, 3:01 PM
lib/Transforms/IPO/PassManagerBuilder.cpp
464

That makes me worried in some way: we're not expecting ICP and SamplePGO to be complementary from each other?

danielcdh added inline comments.Mar 21 2017, 3:17 PM
lib/Transforms/IPO/PassManagerBuilder.cpp
464

Let me try to clarify here.

  • ICP is invoked twice in thinlto: once in compile phase to cover intra-module promotion, another in backend to handle inter-module promotion. The first icp is aiming at reduce callgraph size thus reduce the thinlink burden, but it's not required.
  • SamplePGO do interacts a lot with ICP. If an indirect call is inlined in the profile, then before annotation, we need to promote it and inline it as well. This is done before the profile annotation. But after the profile annotation, when we find more ICP opportunities, it will simply use the legacy ICP pass.

So in this patch, instead of invoking legacy ICP pass twice, we only invoke it once in backend if it is samplepgo+thinlto build.

mehdi_amini added inline comments.Mar 21 2017, 3:20 PM
lib/Transforms/IPO/PassManagerBuilder.cpp
464

Oh OK I missed that it was just the early ICP. Nevermind then.

tejohnson accepted this revision.Mar 23 2017, 2:22 PM

LGTM with one suggestion

lib/Transforms/IPO/PassManagerBuilder.cpp
465

All the "!" make this a little difficult to parse. Since you are doing the same check a couple places anyway, I suggest adding a boolean up above like:
bool PrepareForThinLTOUsingPGOSampleProfile = PrepareForThinLTO && !PGOSampleUse.empty();

It's a mouthful, but hopefully clearer.

This revision is now accepted and ready to land.Mar 23 2017, 2:22 PM
danielcdh closed this revision.Mar 23 2017, 2:32 PM