This is an archive of the discontinued LLVM Phabricator instance.

Propagate branch metadata when some branch probability is missing.
ClosedPublic

Authored by danielcdh on May 4 2016, 5:25 PM.

Details

Summary

In sample profile, some branches may have profile missing due to profile inaccuracy. We want existing branch probability still valid after propagation.

Diff Detail

Event Timeline

danielcdh updated this revision to Diff 56227.May 4 2016, 5:25 PM
danielcdh retitled this revision from to Propagate branch metadata when some branch probability is missing..
danielcdh updated this object.
danielcdh added reviewers: davidxl, spatel, hfinkel.
danielcdh added a subscriber: llvm-commits.
spatel edited edge metadata.May 5 2016, 11:59 AM

Note that this patch is dependent on D19674 which was reverted at rL268577.

I've been trying to locate the msan failure that caused the revert, but no luck so far: I don't see any problems running under valgrind. Trying to repro using msan directly now. If anyone can help spot the bug, I'd appreciate it.

I changed D19674 in order to avoid the msan bot failure; it seems unnecessarily ugly to me, but it's passing on that bot now. There's still an Apple internal bot issue that seems to be triggered by rL268767 , so it may need some other change.

For this patch, I'm wondering if we should be doing a one-off correction for a missing weight. Wouldn't it be better to fill in all of the missing info before we reach SimplifyCFG?

I changed D19674 in order to avoid the msan bot failure; it seems unnecessarily ugly to me, but it's passing on that bot now. There's still an Apple internal bot issue that seems to be triggered by rL268767 , so it may need some other change.

For this patch, I'm wondering if we should be doing a one-off correction for a missing weight. Wouldn't it be better to fill in all of the missing info before we reach SimplifyCFG?

In sample profiler, we only annotate weights if we have profile for the branch. Yes, we can filling in missing weights like we do here, but those weights seem useless to other optimizations and it will unnecessarily increase IR size. Additionally, for case like this, if we assume that two branches should both (or none) have weights, we probably better assert instead of checking with "&&" condition, otherwise we may lose optimization opportunity without being notified.

spatel added a comment.May 9 2016, 3:11 PM

For this patch, I'm wondering if we should be doing a one-off correction for a missing weight. Wouldn't it be better to fill in all of the missing info before we reach SimplifyCFG?

In sample profiler, we only annotate weights if we have profile for the branch. Yes, we can filling in missing weights like we do here, but those weights seem useless to other optimizations and it will unnecessarily increase IR size. Additionally, for case like this, if we assume that two branches should both (or none) have weights, we probably better assert instead of checking with "&&" condition, otherwise we may lose optimization opportunity without being notified.

I'll defer to David or Hal's better judgment on this. I don't know what the correct solution is.

davidxl accepted this revision.May 9 2016, 10:19 PM
davidxl edited edge metadata.

please add some comments to the code.

lgtm.

This revision is now accepted and ready to land.May 9 2016, 10:19 PM
danielcdh updated this revision to Diff 56772.May 10 2016, 11:50 AM
danielcdh edited edge metadata.

Rebase the patch to resolve conflicts. Now this patch does not depend on http://reviews.llvm.org/D19674

danielcdh closed this revision.May 10 2016, 4:13 PM