Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core/Ref] Resolve coverity issues in registers_pool #27854

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ class RegistersPool {
}
void release() {
if (auto pool = regPool.lock()) {
pool->return_to_pool(reg);
try {
pool->return_to_pool(reg);
} catch (...) {
// This function is called by destructor and should not throw. Well formed Reg object won't cause
// any exception throw from return_to_pool, while on badly formed object the destructor is most
// likely called during exception stack unwind.
}
regPool.reset();
}
}
Expand All @@ -90,8 +96,10 @@ class RegistersPool {
RegistersPool::WeakPtr regPool;
};

static thread_local bool is_created;

virtual ~RegistersPool() {
check_unique_and_update(false);
is_created = false;
}

template <ov::reference::jit::cpu_isa_t isa>
Expand Down Expand Up @@ -178,7 +186,7 @@ class RegistersPool {
}
}

void check_unique_and_update(bool isCtor = true);
void check_unique_and_update();

PhysicalSet m_general_set;
PhysicalSet m_simd_set;
Expand Down
15 changes: 6 additions & 9 deletions src/core/reference/src/utils/registers_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,13 @@ RegistersPool::RegistersPool(std::initializer_list<Xbyak::Reg> regsToExclude, in
m_general_set.exclude(Xbyak::Reg64(Xbyak::Operand::RSP));
}

void RegistersPool::check_unique_and_update(bool is_ctor) {
static thread_local bool is_created = false;
if (is_ctor) {
if (is_created) {
OPENVINO_THROW("There should be only one instance of RegistersPool per thread");
}
is_created = true;
} else {
is_created = false;
thread_local bool RegistersPool::is_created = false;

void RegistersPool::check_unique_and_update() {
if (is_created) {
OPENVINO_THROW("There should be only one instance of RegistersPool per thread");
}
t-jankowski marked this conversation as resolved.
Show resolved Hide resolved
is_created = true;
}

void RegistersPool::PhysicalSet::set_as_used(size_t reg_idx) {
Expand Down
Loading