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

machobj: Rename align_ to p2align where its value is assumed as power of 2 #16220

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Feb 22, 2024

Machobj is the only backend that treats align_ as a "power of 2" rather than byte alignment, which seems to have tripped someone up before (see #16219). Renaming all uses of these to make it distinct from other variable/fields names that share the same name/purpose.

@ibuclaw ibuclaw added Refactoring No semantic changes to code Backend glue code, optimizer, code generation labels Feb 22, 2024
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @ibuclaw!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#16220"

@@ -2690,9 +2690,9 @@ int elf_align(targ_size_t size, int foffset)
@trusted
void MachObj_moduleinfo(Symbol *scc)
{
int align_ = I64 ? 3 : 2; // align to _tysize[TYnptr]
int p2align = I64 ? 3 : 2; // align to _tysize[TYnptr]
Copy link
Contributor

Choose a reason for hiding this comment

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

3 is not a power of 2...

Copy link
Member Author

Choose a reason for hiding this comment

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

It is a power of 2 byte alignment. (i.e: .p2align 3 is 8 bytes).

@ibuclaw ibuclaw marked this pull request as draft February 22, 2024 00:43
@ibuclaw
Copy link
Member Author

ibuclaw commented Feb 22, 2024

It'll probably save some time if this waits until after the next stable->master merge, as it'll need to be rebased anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend glue code, optimizer, code generation Refactoring No semantic changes to code
Projects
None yet
4 participants