This is an archive of the discontinued LLVM Phabricator instance.

[PGO] More fix to infinite loop profiling
ClosedPublic

Authored by davidxl on Nov 30 2017, 11:00 PM.

Details

Summary

The IR instrumentation uses MST to decide instrumentation points. It relies adding a fake edge from the function exit block (with no successors) to the fake node. Otherwise edges needed to be instrumented may end up in MST (and therefore not instrumented).

With infinite loop, the exit block may not exist thus the instrumentation will be wrong. Without the fix, the runtime test case added in r319463 will have zero entry count for main (or any parent function of an infinite loop).

After this is fix, there will be more fixes needed in BFI to avoid the body count from being dropped.

Diff Detail

Repository
rL LLVM

Event Timeline

davidxl created this revision.Nov 30 2017, 11:00 PM
vsk edited edge metadata.Dec 4 2017, 11:58 AM

This fix lgtm, but I've never touched this code, so it'd be worth getting another +1.

lib/Transforms/Instrumentation/CFGMST.h
144 ↗(On Diff #125079)

Nit: it might be nice to add a hasExitingBlocks() predicate to LoopInfo, since it wouldn't do lower-bound(# ExitingBlocks) work.

xur accepted this revision.Dec 4 2017, 1:56 PM

Looks good to me.

This revision is now accepted and ready to land.Dec 4 2017, 1:56 PM
This revision was automatically updated to reflect the committed changes.