[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.

llvm-svn: 315586
This commit is contained in:
Alexey Bataev 2017-10-12 15:18:41 +00:00
parent d7d752ad33
commit 7b0f1f09a9
2 changed files with 9 additions and 6 deletions

View File

@ -3349,12 +3349,7 @@ static Address emitOMPArraySectionBase(CodeGenFunction &CGF, const Expr *Base,
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();

View File

@ -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;