diff options
author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2019-01-10 13:59:13 +0000 |
---|---|---|
committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2019-01-10 13:59:13 +0000 |
commit | 97ed076dd1bc1e3fd674d50b925b2a4a6eba5c79 (patch) | |
tree | e6a0241555dc410e6e6ceb01fcde5f0ea0a0b2db /llvm/lib/MCA/Support.cpp | |
parent | 73af3d4060463e3222c56fb1cedb166c05771402 (diff) | |
download | bcm5719-llvm-97ed076dd1bc1e3fd674d50b925b2a4a6eba5c79.tar.gz bcm5719-llvm-97ed076dd1bc1e3fd674d50b925b2a4a6eba5c79.zip |
[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
Diffstat (limited to 'llvm/lib/MCA/Support.cpp')
-rw-r--r-- | llvm/lib/MCA/Support.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
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<uint64_t> &Masks) { + MutableArrayRef<uint64_t> 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, |