summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-09-21 23:35:30 +0000
committerChris Lattner <sabre@nondot.org>2010-09-21 23:35:30 +0000
commitc9066d3072637bd638b31fbac168b87142e02874 (patch)
tree16404934ba5b2a92c234ac0f56edb0abac40cda4 /clang/lib/CodeGen
parent9c48b8d79cf0c112e481f9b564807b3fa1a44e4e (diff)
downloadbcm5719-llvm-c9066d3072637bd638b31fbac168b87142e02874.tar.gz
bcm5719-llvm-c9066d3072637bd638b31fbac168b87142e02874.zip
same bug as before, this time with __sync_val_compare_and_swap.
llvm-svn: 114502
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGBuiltin.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index e9755f9b0cb..d00f1c1d794 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -35,7 +35,7 @@ static void EmitMemoryBarrier(CodeGenFunction &CGF,
Value *C[5] = { LoadLoad ? True : False,
LoadStore ? True : False,
StoreLoad ? True : False,
- StoreStore ? True : False,
+ StoreStore ? True : False,
Device ? True : False };
CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::memory_barrier),
C, C + 5);
@@ -788,16 +788,18 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__sync_val_compare_and_swap_4:
case Builtin::BI__sync_val_compare_and_swap_8:
case Builtin::BI__sync_val_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(),
CGF.getContext().getTypeSize(E->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,
OpenPOWER on IntegriCloud