r258394 - [OPENMP] Fix crash on reduction for complex variables.

2016-01-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jan 21 06:35:58 2016
New Revision: 258394

URL: http://llvm.org/viewvc/llvm-project?rev=258394=rev
Log:
[OPENMP] Fix crash on reduction for complex variables.
reworked codegen for reduction operation for complex types to avoid crash

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=258394=258393=258394=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jan 21 06:35:58 2016
@@ -3548,14 +3548,16 @@ void CGOpenMPRuntime::emitReduction(Code
   E = CGF.EmitAnyExpr(EExpr);
 CGF.EmitOMPAtomicSimpleUpdateExpr(
 X, E, BO, /*IsXLHSInRHSPart=*/true, llvm::Monotonic, Loc,
-[, UpExpr, VD, IPriv](RValue XRValue) {
+[, UpExpr, VD, IPriv, Loc](RValue XRValue) {
   CodeGenFunction::OMPPrivateScope PrivateScope(CGF);
-  PrivateScope.addPrivate(VD, [, VD, XRValue]() -> Address 
{
-Address LHSTemp = CGF.CreateMemTemp(VD->getType());
-CGF.EmitStoreThroughLValue(
-XRValue, CGF.MakeAddrLValue(LHSTemp, VD->getType()));
-return LHSTemp;
-  });
+  PrivateScope.addPrivate(
+  VD, [, VD, XRValue, Loc]() -> Address {
+Address LHSTemp = CGF.CreateMemTemp(VD->getType());
+CGF.emitOMPSimpleStore(
+CGF.MakeAddrLValue(LHSTemp, VD->getType()), 
XRValue,
+VD->getType().getNonReferenceType(), Loc);
+return LHSTemp;
+  });
   (void)PrivateScope.Privatize();
   return CGF.EmitAnyExpr(UpExpr);
 });

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=258394=258393=258394=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Jan 21 06:35:58 2016
@@ -2167,17 +2167,17 @@ static void emitSimpleAtomicStore(CodeGe
   }
 }
 
-static void emitSimpleStore(CodeGenFunction , LValue LVal, RValue RVal,
-QualType RValTy, SourceLocation Loc) {
-  switch (CGF.getEvaluationKind(LVal.getType())) {
+void CodeGenFunction::emitOMPSimpleStore(LValue LVal, RValue RVal,
+ QualType RValTy, SourceLocation Loc) {
+  switch (getEvaluationKind(LVal.getType())) {
   case TEK_Scalar:
-CGF.EmitStoreThroughLValue(RValue::get(convertToScalarValue(
-   CGF, RVal, RValTy, LVal.getType(), Loc)),
-   LVal);
+EmitStoreThroughLValue(RValue::get(convertToScalarValue(
+   *this, RVal, RValTy, LVal.getType(), Loc)),
+   LVal);
 break;
   case TEK_Complex:
-CGF.EmitStoreOfComplex(
-convertToComplexValue(CGF, RVal, RValTy, LVal.getType(), Loc), LVal,
+EmitStoreOfComplex(
+convertToComplexValue(*this, RVal, RValTy, LVal.getType(), Loc), LVal,
 /*isInit=*/false);
 break;
   case TEK_Aggregate:
@@ -2205,7 +2205,7 @@ static void EmitOMPAtomicReadExpr(CodeGe
   // list.
   if (IsSeqCst)
 CGF.CGM.getOpenMPRuntime().emitFlush(CGF, llvm::None, Loc);
-  emitSimpleStore(CGF, VLValue, Res, X->getType().getNonReferenceType(), Loc);
+  CGF.emitOMPSimpleStore(VLValue, Res, X->getType().getNonReferenceType(), 
Loc);
 }
 
 static void EmitOMPAtomicWriteExpr(CodeGenFunction , bool IsSeqCst,
@@ -2463,7 +2463,7 @@ static void EmitOMPAtomicCaptureExpr(Cod
 }
   }
   // Emit post-update store to 'v' of old/new 'x' value.
-  emitSimpleStore(CGF, VLValue, NewVVal, NewVValType, Loc);
+  CGF.emitOMPSimpleStore(VLValue, NewVVal, NewVValType, Loc);
   // OpenMP, 2.12.6, atomic Construct
   // Any atomic construct with a seq_cst clause forces the atomically
   // performed operation to include an implicit flush operation without a

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=258394=258393=258394=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Thu Jan 21 06:35:58 2016
@@ -2212,6 +2212,8 @@ public:
   llvm::Function *GenerateOpenMPCapturedStmtFunction(const CapturedStmt );
   

Re: r258394 - [OPENMP] Fix crash on reduction for complex variables.

2016-01-21 Thread Hans Wennborg via cfe-commits
Jack suggested (https://llvm.org/bugs/show_bug.cgi?id=26059#c7) that
this should be merged to 3.8.

Alexey, you're the code owner here. OK for merging? If yes, do you
want to go ahead and merge with utils/release/merge.sh?

On Thu, Jan 21, 2016 at 4:35 AM, Alexey Bataev via cfe-commits
 wrote:
> Author: abataev
> Date: Thu Jan 21 06:35:58 2016
> New Revision: 258394
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258394=rev
> Log:
> [OPENMP] Fix crash on reduction for complex variables.
> reworked codegen for reduction operation for complex types to avoid crash
>
> Modified:
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r258394 - [OPENMP] Fix crash on reduction for complex variables.

2016-01-21 Thread Alexey Bataev via cfe-commits
Ok, will do

Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

22.01.2016 0:10, Hans Wennborg пишет:
> Jack suggested (https://llvm.org/bugs/show_bug.cgi?id=26059#c7) that
> this should be merged to 3.8.
>
> Alexey, you're the code owner here. OK for merging? If yes, do you
> want to go ahead and merge with utils/release/merge.sh?
>
> On Thu, Jan 21, 2016 at 4:35 AM, Alexey Bataev via cfe-commits
>  wrote:
>> Author: abataev
>> Date: Thu Jan 21 06:35:58 2016
>> New Revision: 258394
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=258394=rev
>> Log:
>> [OPENMP] Fix crash on reduction for complex variables.
>> reworked codegen for reduction operation for complex types to avoid crash
>>
>> Modified:
>>  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
>>  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
>>  cfe/trunk/lib/CodeGen/CodeGenFunction.h
>>  cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits