[cfe-commits] r114498 - in /cfe/trunk: lib/CodeGen/CGBuiltin.cpp test/CodeGen/atomic.c
Chris Lattner
sabre at nondot.org
Tue Sep 21 16:24:52 PDT 2010
Author: lattner
Date: Tue Sep 21 18:24:52 2010
New Revision: 114498
URL: http://llvm.org/viewvc/llvm-project?rev=114498&view=rev
Log:
fix __sync_bool_compare_and_swap to work with address-space qualified types.
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/atomic.c
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=114498&r1=114497&r2=114498&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Sep 21 18:24:52 2010
@@ -812,17 +812,18 @@
case Builtin::BI__sync_bool_compare_and_swap_4:
case Builtin::BI__sync_bool_compare_and_swap_8:
case Builtin::BI__sync_bool_compare_and_swap_16: {
+ llvm::Value *DestPtr = CGF.EmitScalarExpr(E->getArg(0));
+ unsigned AddrSpace =
+ cast<llvm::PointerType>(DestPtr->getType())->getAddressSpace();;
const llvm::Type *ValueType =
- llvm::IntegerType::get(
- CGF.getLLVMContext(),
+ llvm::IntegerType::get(CGF.getLLVMContext(),
CGF.getContext().getTypeSize(E->getArg(1)->getType()));
- const llvm::Type *PtrType = ValueType->getPointerTo();
+ const llvm::Type *PtrType = ValueType->getPointerTo(AddrSpace);
const llvm::Type *IntrinsicTypes[2] = { ValueType, PtrType };
Value *AtomF = CGM.getIntrinsic(Intrinsic::atomic_cmp_swap,
IntrinsicTypes, 2);
- Value *Args[3] = { Builder.CreateBitCast(CGF.EmitScalarExpr(E->getArg(0)),
- PtrType),
+ Value *Args[3] = { Builder.CreateBitCast(DestPtr, PtrType),
EmitCastToInt(CGF, ValueType,
CGF.EmitScalarExpr(E->getArg(1))),
EmitCastToInt(CGF, ValueType,
Modified: cfe/trunk/test/CodeGen/atomic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/atomic.c?rev=114498&r1=114497&r2=114498&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/atomic.c (original)
+++ cfe/trunk/test/CodeGen/atomic.c Tue Sep 21 18:24:52 2010
@@ -122,8 +122,19 @@
return old;
}
+// CHECK: @release_return
void release_return(int *lock) {
// Ensure this is actually returning void all the way through.
return __sync_lock_release(lock);
// CHECK: volatile store i32 0, i32*
}
+
+
+// CHECK: @addrspace
+void addrspace(int __attribute__((address_space(256))) * P) {
+ __sync_bool_compare_and_swap(P, 0, 1);
+ // CHECK: call void @llvm.memory.barrier(i1 true, i1 true, i1 true, i1 true, i1 true)
+ // CHECK: call i32 @llvm.atomic.cmp.swap.i32.p256i32(i32 addrspace(256)* %tmp, i32 0, i32 1)
+ // CHECK: call void @llvm.memory.barrier(i1 true, i1 true, i1 true, i1 true, i1 true)
+}
+
More information about the cfe-commits
mailing list