Skip to content

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
terapines-osc-cir pushed a commit to Terapines/clangir that referenced this pull request Sep 2, 2025
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.
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