This is an archive of the discontinued LLVM Phabricator instance.

[XRay] Detect loops in functions being lowered
ClosedPublic

Authored by dberris on Apr 20 2017, 12:38 AM.

Details

Summary

This is an implementation of the loop detection logic that XRay needs to
determine whether a function might take time at runtime. Without this
heuristic, XRay will tend to not instrument short functions that have
loops that might have runtime dependent on inputs or external values.

While this implementation doesn't do any further analysis than just
figuring out whether there is a loop in the MachineFunction being
code-gen'ed, we're paving the way for being able to perform more
sophisticated analysis of the function in the future (for example to
determine whether the trip count for the loop might be constant, and
make a decision on that instead). This enables us to cover more
functions with the default heuristics, and potentially identify ones
that have variable runtime latency just by looking for the presence of
loops.

Diff Detail

Repository
rL LLVM

Event Timeline

dberris created this revision.Apr 20 2017, 12:38 AM

ping

@chandlerc -- specifically looking for advice on whether the preservation logic is correct in the analysis/transformation dependencies.

rnk accepted this revision.May 3 2017, 4:03 PM

Looks good with a small suggestion

lib/CodeGen/XRayInstrumentation.cpp
40 ↗(On Diff #95899)

This pass at least preserves MachineDomTree, so let's add that too. It seems consistent with other MI passes.

This revision is now accepted and ready to land.May 3 2017, 4:03 PM
This revision was automatically updated to reflect the committed changes.
dberris marked an inline comment as done.