r315586 - [OPENMP] Fix PR34926: Fix handling of the array sections passed as
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 12 08:18:42 PDT 2017
Author: abataev
Date: Thu Oct 12 08:18:41 2017
New Revision: 315586
URL: http://llvm.org/viewvc/llvm-project?rev=315586&view=rev
Log:
[OPENMP] Fix PR34926: Fix handling of the array sections passed as
function params.
Codegen could crash if the array section base expression is the
function parameter.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315586&r1=315585&r2=315586&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Oct 12 08:18:41 2017
@@ -3349,12 +3349,7 @@ static Address emitOMPArraySectionBase(C
LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr *E,
bool IsLowerBound) {
- QualType BaseTy;
- if (auto *ASE =
- dyn_cast<OMPArraySectionExpr>(E->getBase()->IgnoreParenImpCasts()))
- BaseTy = OMPArraySectionExpr::getBaseOriginalType(ASE);
- else
- BaseTy = E->getBase()->getType();
+ QualType BaseTy = OMPArraySectionExpr::getBaseOriginalType(E->getBase());
QualType ResultExprTy;
if (auto *AT = getContext().getAsArrayType(BaseTy))
ResultExprTy = AT->getElementType();
Modified: cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp?rev=315586&r1=315585&r2=315586&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp Thu Oct 12 08:18:41 2017
@@ -80,6 +80,14 @@ struct SST {
// CHECK-DAG: [[REDUCTION_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 18, i32 0, i32 0, i8*
// CHECK-DAG: [[REDUCTION_LOCK:@.+]] = common global [8 x i32] zeroinitializer
+//CHECK: foo_array_sect
+//CHECK: call void {{.+}}@__kmpc_fork_call(
+//CHECK: ret void
+void foo_array_sect(short x[1]) {
+#pragma omp parallel reduction(+ : x[:])
+ {}
+}
+
template <typename T>
T tmain() {
T t;
More information about the cfe-commits
mailing list