From: Evandro Menezes Date: Tue, 8 Jan 2019 22:29:38 +0000 (+0000) Subject: [llvm-mca] Improve debugging (NFC) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6fbbd583d598196a2d1a50209d49330b12bdf522;p=llvm [llvm-mca] Improve debugging (NFC) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350661 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/MCA/Instruction.h b/include/llvm/MCA/Instruction.h index 01d08c1916a..38c7ff4e6b3 100644 --- a/include/llvm/MCA/Instruction.h +++ b/include/llvm/MCA/Instruction.h @@ -28,6 +28,7 @@ #include namespace llvm { + namespace mca { constexpr int UNKNOWN_CYCLES = -512; @@ -347,6 +348,11 @@ struct InstrDesc { InstrDesc() = default; InstrDesc(const InstrDesc &Other) = delete; InstrDesc &operator=(const InstrDesc &Other) = delete; + +#ifndef NDEBUG + // Original instruction name for debugging purposes. + StringRef Name; +#endif }; /// Base class for instructions consumed by the simulation pipeline. diff --git a/lib/MCA/HardwareUnits/ResourceManager.cpp b/lib/MCA/HardwareUnits/ResourceManager.cpp index b68e996ff9e..e3a0da2dafe 100644 --- a/lib/MCA/HardwareUnits/ResourceManager.cpp +++ b/lib/MCA/HardwareUnits/ResourceManager.cpp @@ -169,6 +169,7 @@ unsigned ResourceManager::getNumUnits(uint64_t ResourceID) const { // Second, is the specific sub-resource ID. ResourceRef ResourceManager::selectPipe(uint64_t ResourceID) { unsigned Index = getResourceStateIndex(ResourceID); + assert(Index < Resources.size() && "Invalid resource use!"); ResourceState &RS = *Resources[Index]; assert(RS.isReady() && "No available units to select!"); diff --git a/lib/MCA/InstrBuilder.cpp b/lib/MCA/InstrBuilder.cpp index d8309b6868e..76881b0982f 100644 --- a/lib/MCA/InstrBuilder.cpp +++ b/lib/MCA/InstrBuilder.cpp @@ -558,6 +558,9 @@ InstrBuilder::createInstrDescImpl(const MCInst &MCI) { populateWrites(*ID, MCI, SchedClassID); populateReads(*ID, MCI, SchedClassID); +#ifndef NDEBUG + ID->Name = MCII.getName(Opcode); +#endif LLVM_DEBUG(dbgs() << "\t\tMaxLatency=" << ID->MaxLatency << '\n'); LLVM_DEBUG(dbgs() << "\t\tNumMicroOps=" << ID->NumMicroOps << '\n');