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

[CIR][CIRGen] Add alignment attribute to AtomicCmpXchg #1327

Merged
merged 4 commits into from
Feb 11, 2025

Conversation

FantasqueX
Copy link
Contributor

There is an alignment attribute in MLIR's LLVMIR Dialect

OptionalAttr<I64Attr>:$alignment,

When Clang builds IR, it adds an alignment automatically

llvm::AtomicCmpXchgInst *
CreateAtomicCmpXchg(Address Addr, llvm::Value *Cmp, llvm::Value *New,
llvm::AtomicOrdering SuccessOrdering,
llvm::AtomicOrdering FailureOrdering,
llvm::SyncScope::ID SSID = llvm::SyncScope::System) {
return CGBuilderBaseTy::CreateAtomicCmpXchg(
Addr.emitRawPointer(*getCGF()), Cmp, New,
Addr.getAlignment().getAsAlign(), SuccessOrdering, FailureOrdering,
SSID);
}

This PR does the same thing for ClangIR.

Closes: #1275

Copy link

github-actions bot commented Feb 10, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Member

@Lancern Lancern left a comment

Choose a reason for hiding this comment

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

Thanks for improving. The code format checker is yelling; remember to reformat the code please.

clang/include/clang/CIR/Dialect/IR/CIROps.td Show resolved Hide resolved
@FantasqueX FantasqueX marked this pull request as draft February 10, 2025 23:08
Copy link
Member

@Lancern Lancern left a comment

Choose a reason for hiding this comment

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

LGTM!

@FantasqueX FantasqueX marked this pull request as ready for review February 11, 2025 05:56
@bcardosolopes bcardosolopes merged commit c4409e1 into llvm:main Feb 11, 2025
8 checks passed
@FantasqueX
Copy link
Contributor Author

Thanks a lot for helping my first PR for clangir.
Really appreciate for your quick and helpful review 😘@Lancern

@FantasqueX FantasqueX deleted the cmpxchg-align branch February 11, 2025 17:50
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.

LLVM lowering for cmpxchg might use different alignment from OG
3 participants