aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGBuiltin.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-09-21 23:24:52 +0000
committerChris Lattner <sabre@nondot.org>2010-09-21 23:24:52 +0000
commitf2b95277be59f7d2a82cef8ea9f4cf6a36074593 (patch)
tree51ebd2eacdb5af17c240e7c4c56f6752e0d84f42 /lib/CodeGen/CGBuiltin.cpp
parentc7f78c74e155ece8af24cbe8b949daa9d0ba1828 (diff)
fix __sync_bool_compare_and_swap to work with address-space qualified types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114498 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBuiltin.cpp')
-rw-r--r--lib/CodeGen/CGBuiltin.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp
index 56078a0231..e9755f9b0c 100644
--- a/lib/CodeGen/CGBuiltin.cpp
+++ b/lib/CodeGen/CGBuiltin.cpp
@@ -812,17 +812,18 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
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,