Skip to content

Commit

Permalink
i#5520 memtrace encodings: Access field behind flag when counting
Browse files Browse the repository at this point in the history
Adds a check that the memref.instr.encoding_is_new flag is valid
in the basic_counts tool.

Issue: #5520
  • Loading branch information
derekbruening committed Oct 6, 2022
1 parent 8e161b4 commit d1769ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions clients/drcachesim/tools/basic_counts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@ basic_counts_t::parallel_shard_memref(void *shard_data, const memref_t &memref)
counters->unique_pc_addrs.insert(memref.instr.addr);
// The encoding entries aren't exposed at the memref_t level, but
// we use encoding_is_new as a proxy.
if (memref.instr.encoding_is_new)
if (TESTANY(OFFLINE_FILE_TYPE_ENCODINGS, per_shard->filetype_) &&
memref.instr.encoding_is_new)
++counters->encodings;
} else if (memref.instr.type == TRACE_TYPE_INSTR_NO_FETCH) {
++counters->instrs_nofetch;
// The encoding entries aren't exposed at the memref_t level, but
// we use encoding_is_new as a proxy.
if (memref.instr.encoding_is_new)
if (TESTANY(OFFLINE_FILE_TYPE_ENCODINGS, per_shard->filetype_) &&
memref.instr.encoding_is_new)
++counters->encodings;
} else if (type_is_prefetch(memref.data.type)) {
++counters->prefetches;
Expand Down Expand Up @@ -151,6 +153,16 @@ basic_counts_t::parallel_shard_memref(void *shard_data, const memref_t &memref)
case TRACE_MARKER_TYPE_PHYSICAL_ADDRESS_NOT_AVAILABLE:
++counters->phys_unavail_markers;
break;
case TRACE_MARKER_TYPE_FILETYPE:
if (per_shard->filetype_ == -1) {
per_shard->filetype_ =
static_cast<intptr_t>(memref.marker.marker_value);
} else if (per_shard->filetype_ !=
static_cast<intptr_t>(memref.marker.marker_value)) {
error_string_ = std::string("Filetype mismatch");
return false;
}
// Fall through.
default: ++counters->other_markers; break;
}
}
Expand Down
1 change: 1 addition & 0 deletions clients/drcachesim/tools/basic_counts.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class basic_counts_t : public analysis_tool_t {
std::vector<counters_t> counters;
std::string error;
intptr_t last_window = -1;
intptr_t filetype_ = -1;
};

static bool
Expand Down

0 comments on commit d1769ef

Please sign in to comment.