summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/XRayInstrumentation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/XRayInstrumentation.cpp')
-rw-r--r--llvm/lib/CodeGen/XRayInstrumentation.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/XRayInstrumentation.cpp b/llvm/lib/CodeGen/XRayInstrumentation.cpp
index 0ca11c0992d..1a8d5a4f45d 100644
--- a/llvm/lib/CodeGen/XRayInstrumentation.cpp
+++ b/llvm/lib/CodeGen/XRayInstrumentation.cpp
@@ -141,11 +141,16 @@ bool XRayInstrumentation::runOnMachineFunction(MachineFunction &MF) {
if (Attr.getValueAsString().getAsInteger(10, XRayThreshold))
return false; // Invalid value for threshold.
+ // Count the number of MachineInstr`s in MachineFunction
+ int64_t MICount = 0;
+ for (const auto& MBB : MF)
+ MICount += MBB.size();
+
// Check if we have a loop.
// FIXME: Maybe make this smarter, and see whether the loops are dependent
// on inputs or side-effects?
MachineLoopInfo &MLI = getAnalysis<MachineLoopInfo>();
- if (MLI.empty() && F.size() < XRayThreshold)
+ if (MLI.empty() && MICount < XRayThreshold)
return false; // Function is too small and has no loops.
}
OpenPOWER on IntegriCloud