From 129c911efaa492790c251b3eb18e4db36b55cbc5 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 18 Feb 2020 17:13:21 -0800 Subject: Include static prof data when collecting loop BBs Summary: If the programmer adds static profile data to a branch---i.e. uses "__builtin_expect()" or similar---then we should honor it. Otherwise, "__builtin_expect()" is ignored in crucial situations. So we trust that the programmer knows what they're doing until proven wrong. Subscribers: hiraditya, JDevlieghere, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D74809 --- llvm/lib/CodeGen/MachineLoopInfo.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'llvm/lib/CodeGen/MachineLoopInfo.cpp') diff --git a/llvm/lib/CodeGen/MachineLoopInfo.cpp b/llvm/lib/CodeGen/MachineLoopInfo.cpp index 0c1439d..67916fb 100644 --- a/llvm/lib/CodeGen/MachineLoopInfo.cpp +++ b/llvm/lib/CodeGen/MachineLoopInfo.cpp @@ -111,6 +111,13 @@ DebugLoc MachineLoop::getStartLoc() const { return DebugLoc(); } +bool MachineLoop::hasStaticProfInfo() const { + return llvm::any_of(blocks(), [](const MachineBasicBlock *MBB){ + const BasicBlock *BB = MBB->getBasicBlock(); + return BB && BB->getTerminator()->hasMetadata(LLVMContext::MD_prof); + }); +} + MachineBasicBlock * MachineLoopInfo::findLoopPreheader(MachineLoop *L, bool SpeculativePreheader) const { -- cgit v1.1