From 9b647fe167d96de3f6981b7538d3464d2839e733 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Sat, 10 Apr 2021 09:16:15 -0700 Subject: [PATCH] Update logic around BB_MAX_WEIGHT (#51027) Consider any weight greater or equal to be a max weight. Rule of thumb is that you can assign BB_MAX_WEIGHT but for comparsions one should always use an inequality or call the helper method. Fixes #50808. --- src/coreclr/jit/block.h | 4 ++-- src/coreclr/jit/importer.cpp | 2 +- src/coreclr/jit/utils.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreclr/jit/block.h b/src/coreclr/jit/block.h index aa15fa4f311..4a394126efd 100644 --- a/src/coreclr/jit/block.h +++ b/src/coreclr/jit/block.h @@ -647,9 +647,9 @@ struct BasicBlock : private LIR::Range } } - bool isMaxBBWeight() + bool isMaxBBWeight() const { - return (bbWeight == BB_MAX_WEIGHT); + return (bbWeight >= BB_MAX_WEIGHT); } // Returns "true" if the block is empty. Empty here means there are no statement diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index 84db11d2788..56a341b3fdd 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -19057,7 +19057,7 @@ void Compiler::impMakeDiscretionaryInlineObservations(InlineInfo* pInlineInfo, I InlineCallsiteFrequency frequency = InlineCallsiteFrequency::UNUSED; // If this is a prejit root, or a maximally hot block... - if ((pInlineInfo == nullptr) || (pInlineInfo->iciBlock->bbWeight >= BB_MAX_WEIGHT)) + if ((pInlineInfo == nullptr) || (pInlineInfo->iciBlock->isMaxBBWeight())) { frequency = InlineCallsiteFrequency::HOT; } diff --git a/src/coreclr/jit/utils.cpp b/src/coreclr/jit/utils.cpp index 26914f10112..1afb1e78fb0 100644 --- a/src/coreclr/jit/utils.cpp +++ b/src/coreclr/jit/utils.cpp @@ -657,7 +657,7 @@ const char* refCntWtd2str(BasicBlock::weight_t refCntWtd) nump = (nump == num1) ? num2 : num1; - if (refCntWtd == BB_MAX_WEIGHT) + if (refCntWtd >= BB_MAX_WEIGHT) { sprintf_s(temp, bufSize, "MAX "); } -- GitLab