This is an archive of the discontinued LLVM Phabricator instance.

Separate the ICP total threshold and remaining threshold.
ClosedPublic

Authored by danielcdh on Jul 27 2017, 4:23 PM.

Details

Summary

In the current implementation, isPromotionProfitable only checks if the call count to a direct target is no less than a certain percentage threshold of the remaining call counts that have not been promoted. This causes code size problems when the target count is small but greater than a large portion of remaining counts. E.g. target1 takes 99.9%, while target2 takes 0.1%. Both targets will be promoted and inlined, makes the function size too large, which potentially prevents it from further inlining into its callers. This patch adds another percentage threshold against the total indirect call count. If the target count needs to be no less than both thresholds in order to be promoted speculatively.

Event Timeline

danielcdh created this revision.Jul 27 2017, 4:23 PM
tejohnson added inline comments.Jul 27 2017, 5:11 PM
lib/Analysis/IndirectCallPromotionAnalysis.cpp
47

In your 99.9% and 0.1% case, won't the 0.1% still get promoted since it is 100% of the remaining count after promoting the 99.9% target?

danielcdh added inline comments.Jul 27 2017, 5:20 PM
lib/Analysis/IndirectCallPromotionAnalysis.cpp
47

Before the patch, yes, but with the patch, the 0.1% will be lower than the 5% threshold, thus it will not be promoted.

tejohnson accepted this revision.Jul 27 2017, 5:46 PM

LGTM

lib/Analysis/IndirectCallPromotionAnalysis.cpp
47

Got it - I was thinking the remaining count check was the new one, but it is essentially the old one.

This revision is now accepted and ready to land.Jul 27 2017, 5:46 PM
danielcdh closed this revision.Jul 27 2017, 6:03 PM