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

Explore automatically marking anon fields skip if its value is not accessed #1872

Open
bbannier opened this issue Sep 26, 2024 · 3 comments
Open
Labels
Enhancement Improvement of existing functionality Parsing

Comments

@bbannier
Copy link
Member

bbannier commented Sep 26, 2024

The value from an anonymous field is not accessed via $$ in attributes like e.g., &convert or &requires, or hooks it should always be possible to automatically mark it skip.

While checking the attributes can be done locally, checking for $$ in hooks would require global analysis looking at all files in the compilation. If the unit is public we can never make this optimization since hooks might be implemented in C++ which we cannot inspect. We can make use of the fact that one can only add hooks to anon fields inline.

@awelzel
Copy link
Contributor

awelzel commented Sep 26, 2024

If the unit is public we can never make this optimization since hooks might be implemented in C++ which we cannot inspect.

If the field is anonymous, one can't install a hook, no? Seems reasonable to to imply "cannot be accessed and imply skip" even if the unit is public, no?

@bbannier
Copy link
Member Author

bbannier commented Sep 26, 2024

If the field is anonymous, one can't install a hook, no? Seems reasonable to to imply "cannot be accessed and imply skip" even if the unit is public, no?

Of course 🤦, since one cannot refer to anon fields elsewhere, hooks on them have to be defined inline!

@rsmmr
Copy link
Member

rsmmr commented Sep 26, 2024

If the unit is public we can never make this optimization since hooks might be implemented in C++ which we cannot inspect.

I don't think this is the case. How would you add a hook implementation in custom C++? For that to run, it would need to be called from the generated hook stub, which won't know anything about the hook. Or am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improvement of existing functionality Parsing
Projects
None yet
Development

No branches or pull requests

3 participants