73,74c73,74
< auto sf_it = cachedLocations.find(line_addr);
< bool is_hit = (sf_it != cachedLocations.end());
---
> reqLookupResult = cachedLocations.find(line_addr);
> bool is_hit = (reqLookupResult != cachedLocations.end());
82,83c82,85
< // Create a new element through operator[] and modify in-place
< SnoopItem& sf_item = is_hit ? sf_it->second : cachedLocations[line_addr];
---
> // If no hit in snoop filter create a new element and update iterator
> if (!is_hit)
> reqLookupResult = cachedLocations.emplace(line_addr, SnoopItem()).first;
> SnoopItem& sf_item = reqLookupResult->second;
147,148c149
< SnoopFilter::updateRequest(const Packet* cpkt, const SlavePort& slave_port,
< bool will_retry)
---
> SnoopFilter::finishRequest(bool will_retry, const Packet* cpkt)
150,151c151,159
< DPRINTF(SnoopFilter, "%s: packet src %s addr 0x%x cmd %s\n",
< __func__, slave_port.name(), cpkt->getAddr(), cpkt->cmdString());
---
> if (reqLookupResult != cachedLocations.end()) {
> // since we rely on the caller, do a basic check to ensure
> // that finishRequest is being called following lookupRequest
> assert(reqLookupResult->first == cpkt->getBlockAddr(linesize));
> if (will_retry) {
> // Undo any changes made in lookupRequest to the snoop filter
> // entry if the request will come again. retryItem holds
> // the previous value of the snoopfilter entry.
> reqLookupResult->second = retryItem;
153,157c161,163
< // Ultimately we should check if the packet came from an
< // allocating source, not just if the port is snooping
< bool allocate = !cpkt->req->isUncacheable() && slave_port.isSnooping();
< if (!allocate)
< return;
---
> DPRINTF(SnoopFilter, "%s: restored SF value %x.%x\n",
> __func__, retryItem.requested, retryItem.holder);
> }
159,169c165
< Addr line_addr = cpkt->getBlockAddr(linesize);
< auto sf_it = cachedLocations.find(line_addr);
< assert(sf_it != cachedLocations.end());
< if (will_retry) {
< // Undo any changes made in lookupRequest to the snoop filter
< // entry if the request will come again. retryItem holds
< // the previous value of the snoopfilter entry.
< sf_it->second = retryItem;
<
< DPRINTF(SnoopFilter, "%s: restored SF value %x.%x\n",
< __func__, retryItem.requested, retryItem.holder);
---
> eraseIfNullEntry(reqLookupResult);
171,172d166
<
< eraseIfNullEntry(sf_it);