[clang] [libc++] fix _Atomic c11 compare exchange does not update expected results (PR #78707)
Louis Dionne via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 19 09:05:10 PST 2024
================
@@ -408,7 +409,15 @@ static void emitAtomicCmpXchg(CodeGenFunction &CGF, AtomicExpr *E, bool IsWeak,
CGF.Builder.SetInsertPoint(StoreExpectedBB);
// Update the memory at Expected with Old's value.
- CGF.Builder.CreateStore(Old, Val1);
+
+ llvm::Type *ExpectedType = ExpectedResult.getElementType();
+ uint64_t OriginalSizeInBits = CGF.CGM.getDataLayout().getTypeSizeInBits(ExpectedType);
+ if (OriginalSizeInBits / 8 == Size) {
+ CGF.Builder.CreateStore(Old, ExpectedResult);
+ } else {
+ // How to just store N bytes to ExpectedResult ?
+ CGF.Builder.CreateStore(Old, ExpectedResult);
----------------
ldionne wrote:
@bcardosolopes Hi Bruno! I'm chatting with @huixie90 right now and it seems like he needs to store an N bytes temporary object (that was used to perform the compare exchange above, but where only the first M bytes are used) into the actual result, which has exactly M bytes. We're novices in LLVM IR here -- can you suggest someone that would be able to answer a few questions like this one? Starting with you since Github suggested you as a reviewer for having modified these files recently :)
https://github.com/llvm/llvm-project/pull/78707
More information about the cfe-commits
mailing list