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

reduced size of ValueFlow::Value #6784

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

Conversation

firewave
Copy link
Collaborator

@firewave firewave commented Sep 8, 2024

No description provided.

lib/vfvalue.h Outdated

/** kind of moved */
enum class MoveKind : std::uint8_t { NonMovedVariable, MovedVariable, ForwardedVariable } moveKind = MoveKind::NonMovedVariable;
int indirect{}; // TODO: can we reduce the size?
Copy link
Collaborator Author

@firewave firewave Sep 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrchr-github how high/low can this go? would a 8-bit value be enough for this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8bit unsigned should plenty, unless negative values are used somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it can go negative based on the code so it should be signed.

lib/vfvalue.h Outdated
@@ -280,27 +299,12 @@ namespace ValueFlow

ErrorPath errorPath;

ErrorPath debugPath;
ErrorPath debugPath; // TODO: make lighter by default
Copy link
Collaborator Author

@firewave firewave Sep 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used when --debug is specified. So we waste 16 bytes for having a full type instead of a pointer.

I did hack this out locally and it saves about 3% IR and several operations no longer show up at all in profiling it appears we just narrowly exceed some threshold for some compiler optimization(s) or allocation pattern.

This comment was marked as outdated.

@firewave
Copy link
Collaborator Author

firewave commented Sep 8, 2024

Still need to clean up the macros. And I would like to get the TODOs addressed as well.

The constant for the padding also needs to be adjusted so takes the default alignment into account and we do not overpad. I was also thinking about a macro.

lib/vfvalue.h Outdated

int indirect{};
long long : 4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What the reason for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is explicit padding.

@firewave
Copy link
Collaborator Author

This is mostly clean now and reduces the size from 168 bytes to 136 bytes.

But the debugpath code is broken. And I still want to cleanup the redundancies in the config.h macros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants