r236828 - [OPENMP] Fixed atomic construct with non-integer expressions.

Alexey Bataev a.bataev at hotmail.com
Fri May 8 04:47:17 PDT 2015


Author: abataev
Date: Fri May  8 06:47:16 2015
New Revision: 236828

URL: http://llvm.org/viewvc/llvm-project?rev=236828&view=rev
Log:
[OPENMP] Fixed atomic construct with non-integer expressions.
Do not emit 'atomicrmw' instruction for simple atomic constructs with non-integer expressions.

Modified:
    cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
    cfe/trunk/test/OpenMP/atomic_update_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=236828&r1=236827&r2=236828&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Fri May  8 06:47:16 2015
@@ -1584,10 +1584,11 @@ static std::pair<bool, RValue> emitOMPAt
   // 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));

Modified: cfe/trunk/test/OpenMP/atomic_update_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_update_codegen.cpp?rev=236828&r1=236827&r2=236828&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/atomic_update_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/atomic_update_codegen.cpp Fri May  8 06:47:16 2015
@@ -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++;





More information about the cfe-commits mailing list