Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions llvm/lib/CodeGen/AtomicExpandPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ AtomicExpandImpl::convertAtomicXchgToIntegerType(AtomicRMWInst *RMWI) {
RMWI->getAlign(), RMWI->getOrdering(),
RMWI->getSyncScopeID());
NewRMWI->setVolatile(RMWI->isVolatile());
copyMetadataForAtomic(*NewRMWI, *RMWI);
LLVM_DEBUG(dbgs() << "Replaced " << *RMWI << " with " << *NewRMWI << "\n");

Value *NewRVal = RMWI->getType()->isPointerTy()
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/Transforms/AtomicExpand/X86/expand-atomic-xchg-fp.ll
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,25 @@ define double @atomic_xchg_f64_as1(ptr addrspace(1) %ptr) nounwind {
%result = atomicrmw xchg ptr addrspace(1) %ptr, double 4.0 seq_cst
ret double %result
}

define double @atomic_xchg_f64_preserve_md(ptr %ptr) nounwind {
; CHECK-LABEL: @atomic_xchg_f64_preserve_md(
; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr [[PTR:%.*]], align 8, !mmra [[META0:![0-9]+]]
; CHECK-NEXT: br label [[ATOMICRMW_START:%.*]]
; CHECK: atomicrmw.start:
; CHECK-NEXT: [[LOADED:%.*]] = phi i64 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
; CHECK-NEXT: [[TMP2:%.*]] = cmpxchg ptr [[PTR]], i64 [[LOADED]], i64 4616189618054758400 seq_cst seq_cst, align 8, !mmra [[META0]]
; CHECK-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP2]], 1
; CHECK-NEXT: [[NEWLOADED]] = extractvalue { i64, i1 } [[TMP2]], 0
; CHECK-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
; CHECK: atomicrmw.end:
; CHECK-NEXT: [[TMP3:%.*]] = bitcast i64 [[NEWLOADED]] to double
; CHECK-NEXT: ret double [[TMP3]]
;
%result = atomicrmw xchg ptr %ptr, double 4.000000e+00 seq_cst, align 8, !mmra !0
ret double %result
}

!0 = !{!1, !2}
!1 = !{!"foo", !"bar"}
!2 = !{!"bux", !"baz"}
Loading