]> granicus.if.org Git - clang/commitdiff
[OPENMP] Fixed atomic construct with non-integer expressions.
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 8 May 2015 11:47:16 +0000 (11:47 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Fri, 8 May 2015 11:47:16 +0000 (11:47 +0000)
Do not emit 'atomicrmw' instruction for simple atomic constructs with non-integer expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236828 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGStmtOpenMP.cpp
test/OpenMP/atomic_update_codegen.cpp

index 34e075925fd5f965a4094feffec904a99b383a02..70db0091938c3fdd941cd6eac9aa936a05cc8232 100644 (file)
@@ -1584,10 +1584,11 @@ static std::pair<bool, RValue> emitOMPAtomicRMW(CodeGenFunction &CGF, LValue X,
   // expression is simple and atomic is allowed for the given type for the
   // target platform.
   if (BO == BO_Comma || !Update.isScalar() ||
-      !Update.getScalarVal()->getType()->isIntegerTy() || !X.isSimple() ||
-      (!isa<llvm::ConstantInt>(Update.getScalarVal()) &&
-       (Update.getScalarVal()->getType() !=
-        X.getAddress()->getType()->getPointerElementType())) ||
+      !Update.getScalarVal()->getType()->isIntegerTy() ||
+      !X.isSimple() || (!isa<llvm::ConstantInt>(Update.getScalarVal()) &&
+                        (Update.getScalarVal()->getType() !=
+                         X.getAddress()->getType()->getPointerElementType())) ||
+      !X.getAddress()->getType()->getPointerElementType()->isIntegerTy() ||
       !Context.getTargetInfo().hasBuiltinAtomic(
           Context.getTypeSize(X.getType()), Context.toBits(X.getAlignment())))
     return std::make_pair(false, RValue::get(nullptr));
index ada2e411143f1d4ffadd986affd4f994c08bef90..b6d283224cc7d9fced2c0862e2999b3dc319f938 100644 (file)
@@ -75,6 +75,9 @@ float2 float2x;
 register int rix __asm__("0");
 
 int main() {
+// CHECK-NOT: atomicrmw
+#pragma omp atomic
+  ++dv;
 // CHECK: atomicrmw add i8* @{{.+}}, i8 1 monotonic
 #pragma omp atomic
   bx++;