From 9d541a72e84a6e8a7e082fee07d80c823ab7c997 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Fri, 8 May 2015 11:47:16 +0000 Subject: [PATCH] [OPENMP] Fixed atomic construct with non-integer expressions. Do not emit 'atomicrmw' instruction for simple atomic constructs with non-integer expressions. llvm-svn: 236828 --- clang/lib/CodeGen/CGStmtOpenMP.cpp | 9 +++++---- clang/test/OpenMP/atomic_update_codegen.cpp | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 34e075925fd5..70db0091938c 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -1584,10 +1584,11 @@ static std::pair 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(Update.getScalarVal()) && - (Update.getScalarVal()->getType() != - X.getAddress()->getType()->getPointerElementType())) || + !Update.getScalarVal()->getType()->isIntegerTy() || + !X.isSimple() || (!isa(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)); diff --git a/clang/test/OpenMP/atomic_update_codegen.cpp b/clang/test/OpenMP/atomic_update_codegen.cpp index ada2e411143f..b6d283224cc7 100644 --- a/clang/test/OpenMP/atomic_update_codegen.cpp +++ b/clang/test/OpenMP/atomic_update_codegen.cpp @@ -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++;