Skip to content

[CIR] Fix load alignment #1640

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

Merged
merged 1 commit into from
May 23, 2025
Merged

Conversation

andykaylor
Copy link
Collaborator

This adds an explicit alignment to load instructions where needed in order to make CIR load alignment consistent with classic codegen.

As with aligned stores, I have updated tests that were failing with wildcard checks for cir.load, except where alignment was being specifically checked. Where tests failed because of changed alignment, I verified that the new alignment matches what is produced by classic codegen.

The new test for proper alignment behavior is align-load.c.

This adds an explicit alignment to load instructions where needed in order
to make CIR load alignment consistent with classic codegen.
auto loadOp =
builder.CIRBaseBuilderTy::createLoad(loc, Ptr, isVolatile, isNontemporal);
if (mlir::isa<cir::VoidType>(eltTy))
addr = addr.withElementType(builder, builder.getUIntNTy(8));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that the code I'm replacing here used a bitcast to a signed i8. An unsigned i8 seemed more appropriate for a void pointer, but the only test that hits this case (pointer-arith-ext.c) doesn't check for the type.

@bcardosolopes bcardosolopes merged commit bcc30f4 into llvm:main May 23, 2025
10 checks passed
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.

2 participants