summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp')
-rw-r--r--llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp47
1 files changed, 27 insertions, 20 deletions
diff --git a/llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp b/llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp
index 6923c6e0dc8..ae020c68432 100644
--- a/llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp
+++ b/llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp
@@ -136,31 +136,38 @@ bool LSUnit::isReady(const InstRef &IR) const {
}
void LSUnit::onInstructionExecuted(const InstRef &IR) {
+ const InstrDesc &Desc = IR.getInstruction()->getDesc();
const unsigned Index = IR.getSourceIndex();
- std::set<unsigned>::iterator it = LoadQueue.find(Index);
- if (it != LoadQueue.end()) {
- LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << Index
- << " has been removed from the load queue.\n");
- LoadQueue.erase(it);
- }
+ bool IsALoad = Desc.MayLoad;
+ bool IsAStore = Desc.MayStore;
- it = StoreQueue.find(Index);
- if (it != StoreQueue.end()) {
- LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << Index
- << " has been removed from the store queue.\n");
- StoreQueue.erase(it);
+ if (IsALoad) {
+ if (LoadQueue.erase(Index)) {
+ LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << Index
+ << " has been removed from the load queue.\n");
+ }
+ if (!LoadBarriers.empty() && Index == *LoadBarriers.begin()) {
+ LLVM_DEBUG(
+ dbgs() << "[LSUnit]: Instruction idx=" << Index
+ << " has been removed from the set of load barriers.\n");
+ LoadBarriers.erase(Index);
+ }
}
- if (!StoreBarriers.empty() && Index == *StoreBarriers.begin()) {
- LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << Index
- << " has been removed from the set of store barriers.\n");
- StoreBarriers.erase(StoreBarriers.begin());
- }
- if (!LoadBarriers.empty() && Index == *LoadBarriers.begin()) {
- LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << Index
- << " has been removed from the set of load barriers.\n");
- LoadBarriers.erase(LoadBarriers.begin());
+ if (IsAStore) {
+ if (StoreQueue.erase(Index)) {
+ LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << Index
+ << " has been removed from the store queue.\n");
+ }
+
+ if (!StoreBarriers.empty() && Index == *StoreBarriers.begin()) {
+ LLVM_DEBUG(
+ dbgs() << "[LSUnit]: Instruction idx=" << Index
+ << " has been removed from the set of store barriers.\n");
+ StoreBarriers.erase(Index);
+ }
}
}
+
} // namespace mca
} // namespace llvm
OpenPOWER on IntegriCloud