base: fix name setter doesn't pass correct stat style

There are two kinds of stats in the system. The old one requires an
unique name, while the new one requires an local name. The setName
function has a flag to specify the difference. In the constructor of
InfoAccess, it sets correct flag to the setName function. However, if
you set the name later with the setter, it wouldn't set the flag for
you. This leads the name conflict in new style stats with same local
name. We should also pass the correct flag in the name setter.

Change-Id: I0fcaad3cca65d0f2859c5f6cb28a00813a026a0c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52323
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Yu-hsin Wang
2021-11-02 17:35:28 +08:00
parent 514c2cb48a
commit 0d64ec9a29
2 changed files with 13 additions and 4 deletions

View File

@@ -111,7 +111,7 @@ InfoAccess::setInit()
Info *
InfoAccess::info()
{
if (_info) {
if (newStyleStats()) {
// New-style stats
return _info;
} else {
@@ -125,7 +125,7 @@ InfoAccess::info()
const Info *
InfoAccess::info() const
{
if (_info) {
if (newStyleStats()) {
// New-style stats
return _info;
} else {
@@ -136,6 +136,12 @@ InfoAccess::info() const
}
}
bool
InfoAccess::newStyleStats() const
{
return _info != nullptr;
}
Formula::Formula(Group *parent, const char *name, const char *desc)
: DataWrapVec<Formula, FormulaInfoProxy>(
parent, name, units::Unspecified::get(), desc)

View File

@@ -198,6 +198,9 @@ class InfoAccess
/** Grab the information class for this statistic */
const Info *info() const;
/** Check if the info is new style stats */
bool newStyleStats() const;
public:
InfoAccess()
: _info(nullptr) {};
@@ -259,7 +262,7 @@ class DataWrap : public InfoAccess
parent->addStat(info);
if (name) {
info->setName(name, parent == nullptr);
info->setName(name, !newStyleStats());
info->flags.set(display);
}
@@ -286,7 +289,7 @@ class DataWrap : public InfoAccess
name(const std::string &name)
{
Info *info = this->info();
info->setName(name);
info->setName(name, !newStyleStats());
info->flags.set(display);
return this->self();
}