diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-30 16:33:32 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-30 16:33:32 +0000 |
commit | 51315c45ff5643a27f9c84b816db54ee870ba29b (patch) | |
tree | 1d87443fa0e53d3e6b315ce25787e64be0906bf7 /contrib/llvm/lib/CodeGen/XRayInstrumentation.cpp | |
parent | 6dfd050075216be8538ae375a22d30db72916f7e (diff) | |
parent | eb11fae6d08f479c0799db45860a98af528fa6e7 (diff) |
Notes
Diffstat (limited to 'contrib/llvm/lib/CodeGen/XRayInstrumentation.cpp')
-rw-r--r-- | contrib/llvm/lib/CodeGen/XRayInstrumentation.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/contrib/llvm/lib/CodeGen/XRayInstrumentation.cpp b/contrib/llvm/lib/CodeGen/XRayInstrumentation.cpp index 3d83afcf1fc5..32a7457c2060 100644 --- a/contrib/llvm/lib/CodeGen/XRayInstrumentation.cpp +++ b/contrib/llvm/lib/CodeGen/XRayInstrumentation.cpp @@ -52,7 +52,6 @@ struct XRayInstrumentation : public MachineFunctionPass { void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesCFG(); - AU.addRequired<MachineLoopInfo>(); AU.addPreserved<MachineLoopInfo>(); AU.addPreserved<MachineDominatorTree>(); MachineFunctionPass::getAnalysisUsage(AU); @@ -160,11 +159,26 @@ bool XRayInstrumentation::runOnMachineFunction(MachineFunction &MF) { for (const auto &MBB : MF) MICount += MBB.size(); + // Get MachineDominatorTree or compute it on the fly if it's unavailable + auto *MDT = getAnalysisIfAvailable<MachineDominatorTree>(); + MachineDominatorTree ComputedMDT; + if (!MDT) { + ComputedMDT.getBase().recalculate(MF); + MDT = &ComputedMDT; + } + + // Get MachineLoopInfo or compute it on the fly if it's unavailable + auto *MLI = getAnalysisIfAvailable<MachineLoopInfo>(); + MachineLoopInfo ComputedMLI; + if (!MLI) { + ComputedMLI.getBase().analyze(MDT->getBase()); + MLI = &ComputedMLI; + } + // 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() && MICount < XRayThreshold) + if (MLI->empty() && MICount < XRayThreshold) return false; // Function is too small and has no loops. } |