From: Alexey Bataev Date: Wed, 13 Mar 2019 20:46:28 +0000 (+0000) Subject: [OPENMP]Fix PR37283: Assertion failure on openmp task with by reference X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6371f3f160439dcaa0e384e6871a0b984a74f3fe;p=clang [OPENMP]Fix PR37283: Assertion failure on openmp task with by reference array. If the firstprivate variable is a reference, we may incorrectly classify the kind of the private copy. Use the type of the private copy instead of the original shared variable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356098 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGOpenMPRuntime.cpp b/lib/CodeGen/CGOpenMPRuntime.cpp index 4ed63e0084..f3a0f0d595 100644 --- a/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/lib/CodeGen/CGOpenMPRuntime.cpp @@ -4705,7 +4705,7 @@ static void emitPrivatesInit(CodeGenFunction &CGF, // Check if the variable is the target-based BasePointersArray, // PointersArray or SizesArray. LValue SharedRefLValue; - QualType Type = OriginalVD->getType(); + QualType Type = PrivateLValue.getType(); const FieldDecl *SharedField = CapturesInfo.lookup(OriginalVD); if (IsTargetTask && !SharedField) { assert(isa(OriginalVD) && diff --git a/test/OpenMP/task_firstprivate_codegen.cpp b/test/OpenMP/task_firstprivate_codegen.cpp index 09b1deabde..dc0ba8ac67 100644 --- a/test/OpenMP/task_firstprivate_codegen.cpp +++ b/test/OpenMP/task_firstprivate_codegen.cpp @@ -473,12 +473,13 @@ struct St { ~St() {} }; -void array_func(int n, float a[n], St s[2]) { +void array_func(int n, float a[n], St s[2], int(& p)[1]) { // ARRAY: call i8* @__kmpc_omp_task_alloc( // ARRAY: call i32 @__kmpc_omp_task( // ARRAY: store float** %{{.+}}, float*** %{{.+}}, // ARRAY: store %struct.St** %{{.+}}, %struct.St*** %{{.+}}, -#pragma omp task firstprivate(a, s) +// ARRAY: store [1 x i32]* %{{.+}}, [1 x i32]** %{{.+}}, +#pragma omp task firstprivate(a, s, p) ; } #endif