[XRay] Detect loops in functions being lowered
authorDean Michael Berris <dberris@google.com>
Thu, 4 May 2017 01:24:26 +0000 (01:24 +0000)
committerDean Michael Berris <dberris@google.com>
Thu, 4 May 2017 01:24:26 +0000 (01:24 +0000)
commit22f2bcf4b929732b091a683ea01413072a424d3b
tree17fb935a132afd15abf79885a21a5944c4c2326e
parentbdde34828b62893a9018e2d9e8ec2b705fd6632c
[XRay] Detect loops in functions being lowered

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.

Reviewers: chandlerc, rnk, pelikan

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D32274

llvm-svn: 302103
llvm/lib/CodeGen/XRayInstrumentation.cpp
llvm/test/CodeGen/X86/xray-loop-detection.ll [new file with mode: 0644]