forked from OSchip/llvm-project
Don't try to create "store atomic" instructions of non-integer types; they aren't supported at the moment. PR12040.
llvm-svn: 152891
This commit is contained in:
parent
676d3b0682
commit
fefe0d07ea
|
@ -942,12 +942,13 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
|
|||
case Builtin::BI__sync_lock_release_8:
|
||||
case Builtin::BI__sync_lock_release_16: {
|
||||
Value *Ptr = EmitScalarExpr(E->getArg(0));
|
||||
llvm::Type *ElLLVMTy =
|
||||
cast<llvm::PointerType>(Ptr->getType())->getElementType();
|
||||
llvm::StoreInst *Store =
|
||||
Builder.CreateStore(llvm::Constant::getNullValue(ElLLVMTy), Ptr);
|
||||
QualType ElTy = E->getArg(0)->getType()->getPointeeType();
|
||||
CharUnits StoreSize = getContext().getTypeSizeInChars(ElTy);
|
||||
llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
|
||||
StoreSize.getQuantity() * 8);
|
||||
Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
|
||||
llvm::StoreInst *Store =
|
||||
Builder.CreateStore(llvm::Constant::getNullValue(ITy), Ptr);
|
||||
Store->setAlignment(StoreSize.getQuantity());
|
||||
Store->setAtomic(llvm::Release);
|
||||
return RValue::get(0);
|
||||
|
|
|
@ -8,6 +8,7 @@ int atomic(void) {
|
|||
_Bool valb = 0;
|
||||
unsigned int uval = 1;
|
||||
int cmp = 0;
|
||||
int* ptrval;
|
||||
|
||||
old = __sync_fetch_and_add(&val, 1);
|
||||
// CHECK: atomicrmw add i32* %val, i32 1 seq_cst
|
||||
|
@ -75,8 +76,11 @@ int atomic(void) {
|
|||
// CHECK: cmpxchg i32* null, i32 0, i32 0 seq_cst
|
||||
|
||||
__sync_lock_release(&val);
|
||||
// CHECK: store atomic {{.*}} release, align 4
|
||||
|
||||
// CHECK: store atomic i32 0, {{.*}} release, align 4
|
||||
|
||||
__sync_lock_release(&ptrval);
|
||||
// CHECK: store atomic i32 0, {{.*}} release, align 4
|
||||
|
||||
__sync_synchronize ();
|
||||
// CHECK: fence seq_cst
|
||||
|
||||
|
|
Loading…
Reference in New Issue