aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp
diff options
context:
space:
mode:
authorHiroshi Yamauchi <yamauchi@google.com>2020-02-03 12:22:03 -0800
committerHiroshi Yamauchi <yamauchi@google.com>2020-02-04 10:05:28 -0800
commit803dd6fe6bb493e34a8747dc286a88aa05f353e1 (patch)
treef24517a88b941da0a9c29226016dfbc585377091 /llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp
parentdc42ff6697db1847a6e2f154de07f6e1f3d97ae4 (diff)
downloadllvm-803dd6fe6bb493e34a8747dc286a88aa05f353e1.zip
llvm-803dd6fe6bb493e34a8747dc286a88aa05f353e1.tar.gz
llvm-803dd6fe6bb493e34a8747dc286a88aa05f353e1.tar.bz2
[BFI] Add a debug check for unknown block queries.
Summary: Add a debug check for frequency queries for unknown blocks (typically blocks that are created after BFI is computed but their frequencies are not communicated to BFI.) This is useful for detecting and debugging missed BFI updates. This is debug build only and disabled behind a flag. Reviewers: davidxl Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73920
Diffstat (limited to 'llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp')
-rw-r--r--llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp
index 0db6dd0..e4fda24 100644
--- a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp
+++ b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp
@@ -40,6 +40,12 @@ using namespace llvm::bfi_detail;
#define DEBUG_TYPE "block-freq"
+cl::opt<bool> CheckBFIUnknownBlockQueries(
+ "check-bfi-unknown-block-queries",
+ cl::init(false), cl::Hidden,
+ cl::desc("Check if block frequency is queried for an unknown block "
+ "for debugging missed BFI updates"));
+
ScaledNumber<uint64_t> BlockMass::toScaled() const {
if (isFull())
return ScaledNumber<uint64_t>(1, 0);
@@ -550,8 +556,17 @@ void BlockFrequencyInfoImplBase::finalizeMetrics() {
BlockFrequency
BlockFrequencyInfoImplBase::getBlockFreq(const BlockNode &Node) const {
- if (!Node.isValid())
+ if (!Node.isValid()) {
+#ifndef NDEBUG
+ if (CheckBFIUnknownBlockQueries) {
+ SmallString<256> Msg;
+ raw_svector_ostream OS(Msg);
+ OS << "*** Detected BFI query for unknown block " << getBlockName(Node);
+ report_fatal_error(OS.str());
+ }
+#endif
return 0;
+ }
return Freqs[Node.Index].Integer;
}