-
Notifications
You must be signed in to change notification settings - Fork 160
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
[luci] Introduce the parent class method to luci::Pass #14594
Conversation
This directive fixes a build break caused by a compiler error emitted when compiling with -Werror=overloaded-virtual flag switched on. The error is about the logo::Pass::run method being hidden by luci::Pass::run. ONE-DCO-1.0-Signed-off-by: Tomasz Dolbniak <[email protected]>
b3f60fe
to
83e647c
Compare
This directive fixes a build break caused by a compiler error emitted when compiling with -Werror=overloaded-virtual flag switched on. The error is about the logo::Pass::run method being hidden by luci::Pass::run. This is a backport of Samsung#14594 to the release branch. ONE-DCO-1.0-Signed-off-by: Tomasz Dolbniak <[email protected]>
@lemmaa , what is the guide for putting internal server URLs? |
@@ -28,6 +28,8 @@ namespace luci | |||
class Pass : public logo::Pass | |||
{ | |||
public: | |||
// This directive prevents emitting a compiler erro triggered by -Werror=overloaded-virtual | |||
using logo::Pass::run; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why add this here.
I cannot accept the resolution method. please find another way of solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in fact the solution. The reason this error occurs in the first place is that the luci::Pass::run(luci::Module *)
has a different signature than the parent's loco::Pass::run(loco::Graph *)
and this can cause overload resolution problems when compiling the code in certain situations. This is why newer compilers report a warning and the -Werror=overloaded-virtual
makes it an error which basically blocks the build on Ubuntu 24.
The using
directive adds the logo::Pass::run
method to the overload set of the luci::Pass
class which makes the warning(error) go away and most importantly - it doesn't break anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO you got it wrong. luci::Pass::run(luci::Module *)
is also pure virtual so that inherit class SHOULD also override.
You can inherit from loco::Pass
if do not want to use luci::Module *
parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original build error (screenshot in the linked issue) comes from a file CircleNodePass.h
which includes the logo/Pass.h
header and contains a class which inherits from logo::Pass
. This is correct and matches what you said above - CircleNodePass
overrides run(loco::Graph* graph)
and doesn't touch the version which operates on luci::Module
.
Yet the compiler produces an error about luci::Pass::run
hiding logo::Pass::run
withing this compilation context.
Here's a smaller snippet that demonstrates how hiding the virtual methods interferes with name lookup and overload resolution https://ideone.com/lI3QNL
Uncomment the using A::run;
line fixes the problem and this is exactly what I'm proposing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only other solution I can imagine is renaming the conflicting methods so that they don't hide each other:
logo::Pass::run(Graph*)
-> logo::Pass::run_on_graph(Graph*)
luci::Pass::run(Module*)
-> luci::Pass::run_on_module(Module*)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, I'm not familiar with this kind of warning and I didn't understand neither what above code tries to solve at the first.
So, I've searched the general solution for this warning and found that most of directions guided as @tomdol's.
"In cases where the different signatures are not an accident, the simplest solution is to add a using-declaration to the derived class to un-hide the base function, e.g. add using A::f; to B. "
We may solve the issue in different ways (e.g. duplicating logo::pass to luci:pass, renaming the functions ...) but current suggestion seems quite optimal for me ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried overriding
luci::Pass::run(luci::Module *)
? something likebool run(luci::Module *) override { throw "NYI"; }
It's impossible to override the suggested method because it's a member of luci::Pass
. The NPU_Compiler does not inherit from this class. It uses logo::Pass
instead.
The reason this became a problem is the change how GCC13 and newer versions compile the whole code base. The inheritance hierarchy of logo::Pass <- luci::Pass
is analyzed independently from logo::Pass <- CircleNodePass
so no matter what I do this warning will still be reported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why add this here. I cannot accept the resolution method. please find another way of solution.
@seanshpark , I believe some positive opinions about this resolution method were added:
#14594 (comment)
#14594 (comment)
and I believe this resolution is based on GCC documentation. So please give us your final decision about this PR, we want to merge it or close it and prepare patch for ONE in our project to solve this issue on our side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot accept the resolution method. please find another way of solution.
There was no updates after this comment.
I still do not accept this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason this became a problem is the change how GCC13 and newer versions compile the whole code base. The inheritance hierarchy of logo::Pass <- luci::Pass is analyzed independently from logo::Pass <- CircleNodePass so no matter what I do this warning will still be reported.
There's no other way of solving this warning but the using
directive.
I assume this issue is to fix for U24.04 cause of your situation. What I can suggest is written in #14589 (comment) |
@dahlinPL @seanshpark We can see this warning when we are using Clang or latest GCC version. https://stackoverflow.com/questions/18515183/c-overloaded-virtual-function-warning-by-clang
Clang users have been experiencing this issue for more than 10 years. And now GCC has begun to warn this issue, unfortunately. |
I fully understand your concern :) But please keep in mind below:
so, even if opinions about I would be grateful, it will help us a lot |
@seanshpark @jinevening thanks for merging #14808, thanks to this we are one step closer to bump ONE version in our project. WIll you please reconsider also this contribution? |
First of all, I think this PR can be merged as-is. This seems to be a widely-used solution for this situation. I can imagine another workaround that makes a separate class for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
It's up to @seanshpark 's decision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
It's up to @seanshpark 's decision.
Closing this PR since it hasn't been merged for almost 2 months despite providing the motivation and arguments explaining the proposed solution. If anything changes, feel free to reopen. |
This directive fixes a build break caused by a compiler error emitted when compiling with -Werror=overloaded-virtual flag switched on. The error is about the logo::Pass::run method being hidden by luci::Pass::run.
ONE-DCO-1.0-Signed-off-by: Tomasz Dolbniak [email protected]
Related issue
NPU_Compiler/issues/19901