From 5d780093fd6e0776a24d8203d2675a783d57f7e5 Mon Sep 17 00:00:00 2001 From: Evandro Menezes Date: Tue, 8 Jan 2019 22:29:38 +0000 Subject: [PATCH] [llvm-mca] Improve debugging (NFC) llvm-svn: 350661 --- llvm/include/llvm/MCA/Instruction.h | 6 ++++++ llvm/lib/MCA/HardwareUnits/ResourceManager.cpp | 1 + llvm/lib/MCA/InstrBuilder.cpp | 3 +++ 3 files changed, 10 insertions(+) diff --git a/llvm/include/llvm/MCA/Instruction.h b/llvm/include/llvm/MCA/Instruction.h index 01d08c1..38c7ff4 100644 --- a/llvm/include/llvm/MCA/Instruction.h +++ b/llvm/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/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp b/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp index b68e996..e3a0da2 100644 --- a/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp +++ b/llvm/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/llvm/lib/MCA/InstrBuilder.cpp b/llvm/lib/MCA/InstrBuilder.cpp index d8309b6..76881b0 100644 --- a/llvm/lib/MCA/InstrBuilder.cpp +++ b/llvm/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'); -- 2.7.4