diff options
author | Bill Wendling <isanbard@gmail.com> | 2020-02-18 17:13:21 -0800 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2020-02-19 11:33:48 -0800 |
commit | 129c911efaa492790c251b3eb18e4db36b55cbc5 (patch) | |
tree | 7b998cec77842aaaef540d9080dcea769d68749c /llvm/lib/CodeGen/MachineLoopInfo.cpp | |
parent | 076475713c236081a3247a53e9dbab9043c3eac2 (diff) | |
download | llvm-129c911efaa492790c251b3eb18e4db36b55cbc5.zip llvm-129c911efaa492790c251b3eb18e4db36b55cbc5.tar.gz llvm-129c911efaa492790c251b3eb18e4db36b55cbc5.tar.bz2 |
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
Diffstat (limited to 'llvm/lib/CodeGen/MachineLoopInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineLoopInfo.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
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 { |