Author: abataev Date: Wed Mar 13 13:46:28 2019 New Revision: 356098 URL: http://llvm.org/viewvc/llvm-project?rev=356098&view=rev Log: [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. Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/test/OpenMP/task_firstprivate_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=356098&r1=356097&r2=356098&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Mar 13 13:46:28 2019 @@ -4705,7 +4705,7 @@ static void emitPrivatesInit(CodeGenFunc // 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<ImplicitParamDecl>(OriginalVD) && Modified: cfe/trunk/test/OpenMP/task_firstprivate_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/task_firstprivate_codegen.cpp?rev=356098&r1=356097&r2=356098&view=diff ============================================================================== --- cfe/trunk/test/OpenMP/task_firstprivate_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/task_firstprivate_codegen.cpp Wed Mar 13 13:46:28 2019 @@ -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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits