[llvm] [BOLT] Fix double conversion in CacheMetrics (PR #75253)

via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 13 07:54:04 PST 2023


================
@@ -14,22 +14,18 @@
 #include "bolt/Passes/CacheMetrics.h"
 #include "bolt/Core/BinaryBasicBlock.h"
 #include "bolt/Core/BinaryFunction.h"
-#include "llvm/Support/CommandLine.h"
 #include <unordered_map>
 
 using namespace llvm;
 using namespace bolt;
 
-namespace opts {
-
-extern cl::OptionCategory BoltOptCategory;
+namespace {
 
-extern cl::opt<unsigned> ITLBPageSize;
-extern cl::opt<unsigned> ITLBEntries;
+/// The size of an i-tlb cache page.
+constexpr unsigned ITLBPageSize = 4096;
 
-} // namespace opts
-
-namespace {
+/// The number of entries in the i-tlb cache.
+constexpr unsigned ITLBEntries = 16;
----------------
spupyrev wrote:

Good question. IIRC this is a proxy to estimate "the number of i-TLB misses" (whatever it means, given that there are multiple cache levels) using only the profile counts and CFGs. Empirically we observed that "16" yields the highest correlation with the perf measurement in that experiment.
I have a WIP diff to re-implement the computation of layout-related stats, using fewer magic constants, and make the results more interpretable. Perhaps one day I'll complete the diff.

(This particular diff simply fixes an arithmetic bug caused by a double/int conversion, which i think worth fixing any way)

https://github.com/llvm/llvm-project/pull/75253


More information about the llvm-commits mailing list