From bd52495518808bdbf24f4d8e9e20774d6d2e3333 Mon Sep 17 00:00:00 2001 From: Hongtao Yu Date: Thu, 17 Jun 2021 11:09:13 -0700 Subject: [CSSPGO] Undoing the concept of dangling pseudo probe As a follow-up to https://reviews.llvm.org/D104129, I'm cleaning up the danling probe related code in both the compiler and llvm-profgen. I'm seeing a 5% size win for the pseudo_probe section for SPEC2017 and 10% for Ciner. Certain benchmark such as 602.gcc has a 20% size win. No obvious difference seen on build time for SPEC2017 and Cinder. Reviewed By: wenlei Differential Revision: https://reviews.llvm.org/D104477 --- llvm/lib/CodeGen/MachineBasicBlock.cpp | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp') diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 1011f52476d2..c6914dcd0e54 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -901,32 +901,6 @@ MachineBasicBlock::transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB) { normalizeSuccProbs(); } -/// A block emptied (i.e., with all instructions moved out of it) won't be -/// sampled at run time. In such cases, AutoFDO will be informed of zero samples -/// collected for the block. This is not accurate and could lead to misleading -/// weights assigned for the block. A way to mitigate that is to treat such -/// block as having unknown counts in the AutoFDO profile loader and allow the -/// counts inference tool a chance to calculate a relatively reasonable weight -/// for it. This can be done by moving all pseudo probes in the emptied block -/// i.e, /c this, to before /c ToMBB and tag them dangling. Note that this is -/// not needed for dead blocks which really have a zero weight. It's per -/// transforms to decide whether to call this function or not. -void MachineBasicBlock::moveAndDanglePseudoProbes(MachineBasicBlock *ToMBB) { - SmallVector ToBeMoved; - for (MachineInstr &MI : instrs()) { - if (MI.isPseudoProbe()) { - MI.addPseudoProbeAttribute(PseudoProbeAttributes::Dangling); - ToBeMoved.push_back(&MI); - } - } - - MachineBasicBlock::iterator I = ToMBB->getFirstTerminator(); - for (MachineInstr *MI : ToBeMoved) { - MI->removeFromParent(); - ToMBB->insert(I, MI); - } -} - bool MachineBasicBlock::isPredecessor(const MachineBasicBlock *MBB) const { return is_contained(predecessors(), MBB); } -- cgit v1.2.3