[llvm-branch-commits] [cfe-branch] r258483 - Merging r258394:
Alexey Bataev via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 21 20:07:49 PST 2016
Author: abataev
Date: Thu Jan 21 22:07:48 2016
New Revision: 258483
URL: http://llvm.org/viewvc/llvm-project?rev=258483&view=rev
Log:
Merging r258394:
------------------------------------------------------------------------
r258394 | abataev | 2016-01-21 15:35:58 +0300 (Thu, 21 Jan 2016) | 3 lines
[OPENMP] Fix crash on reduction for complex variables.
reworked codegen for reduction operation for complex types to avoid crash
------------------------------------------------------------------------
Modified:
cfe/branches/release_38/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/branches/release_38/lib/CodeGen/CGStmtOpenMP.cpp
cfe/branches/release_38/lib/CodeGen/CodeGenFunction.h
cfe/branches/release_38/test/OpenMP/parallel_reduction_codegen.cpp
Modified: cfe/branches/release_38/lib/CodeGen/CGOpenMPRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_38/lib/CodeGen/CGOpenMPRuntime.cpp?rev=258483&r1=258482&r2=258483&view=diff
==============================================================================
--- cfe/branches/release_38/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/branches/release_38/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jan 21 22:07:48 2016
@@ -3548,14 +3548,16 @@ void CGOpenMPRuntime::emitReduction(Code
E = CGF.EmitAnyExpr(EExpr);
CGF.EmitOMPAtomicSimpleUpdateExpr(
X, E, BO, /*IsXLHSInRHSPart=*/true, llvm::Monotonic, Loc,
- [&CGF, UpExpr, VD, IPriv](RValue XRValue) {
+ [&CGF, UpExpr, VD, IPriv, Loc](RValue XRValue) {
CodeGenFunction::OMPPrivateScope PrivateScope(CGF);
- PrivateScope.addPrivate(VD, [&CGF, VD, XRValue]() -> Address {
- Address LHSTemp = CGF.CreateMemTemp(VD->getType());
- CGF.EmitStoreThroughLValue(
- XRValue, CGF.MakeAddrLValue(LHSTemp, VD->getType()));
- return LHSTemp;
- });
+ PrivateScope.addPrivate(
+ VD, [&CGF, 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/branches/release_38/lib/CodeGen/CGStmtOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_38/lib/CodeGen/CGStmtOpenMP.cpp?rev=258483&r1=258482&r2=258483&view=diff
==============================================================================
--- cfe/branches/release_38/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/branches/release_38/lib/CodeGen/CGStmtOpenMP.cpp Thu Jan 21 22:07:48 2016
@@ -2163,17 +2163,17 @@ static void emitSimpleAtomicStore(CodeGe
}
}
-static void emitSimpleStore(CodeGenFunction &CGF, 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:
@@ -2201,7 +2201,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 &CGF, bool IsSeqCst,
@@ -2459,7 +2459,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/branches/release_38/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_38/lib/CodeGen/CodeGenFunction.h?rev=258483&r1=258482&r2=258483&view=diff
==============================================================================
--- cfe/branches/release_38/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/branches/release_38/lib/CodeGen/CodeGenFunction.h Thu Jan 21 22:07:48 2016
@@ -2211,6 +2211,8 @@ public:
llvm::Function *GenerateOpenMPCapturedStmtFunction(const CapturedStmt &S);
void GenerateOpenMPCapturedVars(const CapturedStmt &S,
SmallVectorImpl<llvm::Value *> &CapturedVars);
+ void emitOMPSimpleStore(LValue LVal, RValue RVal, QualType RValTy,
+ SourceLocation Loc);
/// \brief Perform element by element copying of arrays with type \a
/// OriginalType from \a SrcAddr to \a DestAddr using copying procedure
/// generated by \a CopyGen.
Modified: cfe/branches/release_38/test/OpenMP/parallel_reduction_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_38/test/OpenMP/parallel_reduction_codegen.cpp?rev=258483&r1=258482&r2=258483&view=diff
==============================================================================
--- cfe/branches/release_38/test/OpenMP/parallel_reduction_codegen.cpp (original)
+++ cfe/branches/release_38/test/OpenMP/parallel_reduction_codegen.cpp Thu Jan 21 22:07:48 2016
@@ -158,6 +158,7 @@ int main() {
int vec[] = {1, 2};
S<float> s_arr[] = {1, 2};
S<float> var(3), var1;
+ float _Complex cf;
#pragma omp parallel reduction(+:t_var) reduction(&:var) reduction(&& : var1) reduction(min: t_var1)
{
vec[0] = t_var;
@@ -169,6 +170,8 @@ int main() {
vec[0] = t_var;
s_arr[0] = var;
}
+#pragma omp parallel reduction(+ : cf)
+ ;
return tmain<int>();
#endif
}
@@ -178,6 +181,7 @@ int main() {
// CHECK: call {{.*}} [[S_FLOAT_TY_CONSTR:@.+]]([[S_FLOAT_TY]]* [[TEST]])
// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 6, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [2 x i32]*, float*, [2 x [[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]*, float*)* [[MAIN_MICROTASK:@.+]] to void
// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 6, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [2 x i32]*, float*, [2 x [[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]*, float*)* [[MAIN_MICROTASK1:@.+]] to void
+// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, { float, float }*)* [[MAIN_MICROTASK2:@.+]] to void
// CHECK: = call {{.*}}i{{.+}} [[TMAIN_INT:@.+]]()
// CHECK: call {{.*}} [[S_FLOAT_TY_DESTR:@.+]]([[S_FLOAT_TY]]*
// CHECK: ret
More information about the llvm-branch-commits
mailing list