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

Add API to overwrite existing pass from plugin #4174

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Changes from 1 commit
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
Next Next commit
Add API to overwrite existing pass from plugin
Signed-off-by: Claire Xenia Wolf <[email protected]>
clairexen committed Jan 30, 2024
commit 4fa314c0bd0a7f314809e180f196d0974535b0f5
8 changes: 3 additions & 5 deletions kernel/register.cc
Original file line number Diff line number Diff line change
@@ -108,9 +108,8 @@ Pass::Pass(std::string name, std::string short_help) : pass_name(name), short_he

void Pass::run_register()
{
if (pass_register.count(pass_name))
if (pass_register.count(pass_name) && !replace_existing_pass())
log_error("Unable to register pass '%s', pass already exists!\n", pass_name.c_str());

pass_register[pass_name] = this;
}

@@ -447,13 +446,12 @@ Frontend::Frontend(std::string name, std::string short_help) :

void Frontend::run_register()
{
if (pass_register.count(pass_name))
if (pass_register.count(pass_name) && !replace_existing_pass())
log_error("Unable to register pass '%s', pass already exists!\n", pass_name.c_str());
pass_register[pass_name] = this;

if (frontend_register.count(frontend_name))
if (frontend_register.count(frontend_name) && !replace_existing_pass())
log_error("Unable to register frontend '%s', frontend already exists!\n", frontend_name.c_str());

frontend_register[frontend_name] = this;
}

1 change: 1 addition & 0 deletions kernel/register.h
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@ struct Pass

virtual void on_register();
virtual void on_shutdown();
virtual bool replace_existing_pass() const { return false; }
};

struct ScriptPass : Pass
1 change: 0 additions & 1 deletion passes/cmds/plugin.cc
Original file line number Diff line number Diff line change
@@ -103,7 +103,6 @@ void load_plugin(std::string filename, std::vector<std::string> aliases)

loaded_plugins[orig_filename] = hdl;
Pass::init_register();

}
}