From 97ed076dd1bc1e3fd674d50b925b2a4a6eba5c79 Mon Sep 17 00:00:00 2001 From: Andrea Di Biagio Date: Thu, 10 Jan 2019 13:59:13 +0000 Subject: [MCA] Fix wrong definition of ResourceUnitMask in DefaultResourceStrategy. Field ResourceUnitMask was incorrectly defined as a 'const unsigned' mask. It should have been a 64 bit quantity instead. That means, ResourceUnitMask was always implicitly truncated to a 32 bit quantity. This issue has been found by inspection. Surprisingly, that bug was latent, and it never negatively affected any existing upstream targets. This patch fixes the wrong definition of ResourceUnitMask, and adds a bunch of extra debug prints to help debugging potential issues related to invalid processor resource masks. llvm-svn: 350820 --- llvm/lib/MCA/Support.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'llvm/lib/MCA/Support.cpp') diff --git a/llvm/lib/MCA/Support.cpp b/llvm/lib/MCA/Support.cpp index 3271bc6bf5b..335953e1048 100644 --- a/llvm/lib/MCA/Support.cpp +++ b/llvm/lib/MCA/Support.cpp @@ -19,13 +19,18 @@ namespace llvm { namespace mca { +#define DEBUG_TYPE "llvm-mca" + void computeProcResourceMasks(const MCSchedModel &SM, - SmallVectorImpl &Masks) { + MutableArrayRef Masks) { unsigned ProcResourceID = 0; + assert(Masks.size() == SM.getNumProcResourceKinds() && + "Invalid number of elements"); + // Resource at index 0 is the 'InvalidUnit'. Set an invalid mask for it. + Masks[0] = 0; + // Create a unique bitmask for every processor resource unit. - // Skip resource at index 0, since it always references 'InvalidUnit'. - Masks.resize(SM.getNumProcResourceKinds()); for (unsigned I = 1, E = SM.getNumProcResourceKinds(); I < E; ++I) { const MCProcResourceDesc &Desc = *SM.getProcResource(I); if (Desc.SubUnitsIdxBegin) @@ -46,6 +51,16 @@ void computeProcResourceMasks(const MCSchedModel &SM, } ProcResourceID++; } + +#ifndef NDEBUG + LLVM_DEBUG(dbgs() << "\nProcessor resource masks:" + << "\n"); + for (unsigned I = 0, E = SM.getNumProcResourceKinds(); I < E; ++I) { + const MCProcResourceDesc &Desc = *SM.getProcResource(I); + LLVM_DEBUG(dbgs() << '[' << I << "] " << Desc.Name << " - " << Masks[I] + << '\n'); + } +#endif } double computeBlockRThroughput(const MCSchedModel &SM, unsigned DispatchWidth, -- cgit v1.2.3