From: Alexey Bataev Date: Tue, 24 Nov 2015 13:01:44 +0000 (+0000) Subject: [OPENMP] Fix crash on codegen for 'task' directive with no shared variables. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c54870799af67799cf23c1852d888c3a5b79185;p=clang [OPENMP] Fix crash on codegen for 'task' directive with no shared variables. If 'task' region does not have shared variables codegen could crash on calculation of size of list of shared variables. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253977 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGOpenMPRuntime.cpp b/lib/CodeGen/CGOpenMPRuntime.cpp index f9fe8d2ecd..9c484de284 100644 --- a/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/lib/CodeGen/CGOpenMPRuntime.cpp @@ -2317,7 +2317,7 @@ void CGOpenMPRuntime::emitTaskCall( CGF.Builder.getInt32(/*C=*/0)) : CGF.Builder.getInt32(Final.getInt() ? FinalFlag : 0); TaskFlags = CGF.Builder.CreateOr(TaskFlags, CGF.Builder.getInt32(Flags)); - auto *SharedsSize = getTypeSize(CGF, SharedsTy); + auto *SharedsSize = CGM.getSize(C.getTypeSizeInChars(SharedsTy)); llvm::Value *AllocArgs[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc), TaskFlags, KmpTaskTWithPrivatesTySize, SharedsSize, diff --git a/test/OpenMP/task_private_codegen.cpp b/test/OpenMP/task_private_codegen.cpp index f5224730d1..1455fd11a9 100644 --- a/test/OpenMP/task_private_codegen.cpp +++ b/test/OpenMP/task_private_codegen.cpp @@ -138,6 +138,8 @@ int main() { s_arr[0] = var; sivar = 8; } +#pragma omp task + g+=1; return tmain(); #endif } @@ -188,6 +190,7 @@ int main() { // Start task. // CHECK: call i32 @__kmpc_omp_task([[LOC]], i32 [[GTID]], i8* [[RES]]) +// CHECK: call i32 @__kmpc_omp_task([[LOC]], i32 [[GTID]], i8* // CHECK: = call i{{.+}} [[TMAIN_INT:@.+]]()