зеркало из https://github.com/microsoft/clang-1.git
Don't try to create "store atomic" instructions of non-integer types; they aren't supported at the moment. PR12040.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152891 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
9ace587fe5
Коммит
ff993202ab
|
@ -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
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче