From: Alexey Bataev Date: Tue, 9 Apr 2019 16:31:37 +0000 (+0000) Subject: [OPENMP]Allow allocate directive on parameters. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c5a77ab63d1abd64398ea2f76721e59d4517ad5;p=clang [OPENMP]Allow allocate directive on parameters. Patch allows to use allocate directives on the function parameters. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@358016 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index 1ab0e0117f..59df77d67d 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -2361,9 +2361,6 @@ Sema::DeclGroupPtrTy Sema::ActOnOpenMPAllocateDirective( (VD->getStorageClass() == SC_Register && VD->hasAttr() && !VD->isLocalVarDecl())) continue; - // Do not apply for parameters. - if (isa(VD)) - continue; // If the used several times in the allocate directive, the same allocator // must be used. diff --git a/test/OpenMP/allocate_codegen.cpp b/test/OpenMP/allocate_codegen.cpp index 827b7012b0..c068589041 100644 --- a/test/OpenMP/allocate_codegen.cpp +++ b/test/OpenMP/allocate_codegen.cpp @@ -91,4 +91,18 @@ int main () { // CHECK-NOT: call {{.+}} {{__kmpc_alloc|__kmpc_free}} extern template int ST::m; + +// CHECK: define void @{{.+}}bar{{.+}}(i32 %{{.+}}, float* {{.+}}) +void bar(int a, float &z) { +// CHECK: [[A_VOID_PTR:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID:%.+]], i64 4, i8* inttoptr (i64 1 to i8*)) +// CHECK: [[A_ADDR:%.+]] = bitcast i8* [[A_VOID_PTR]] to i32* +// CHECK: store i32 %{{.+}}, i32* [[A_ADDR]], +// CHECK: [[Z_VOID_PTR:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID]], i64 8, i8* inttoptr (i64 1 to i8*)) +// CHECK: [[Z_ADDR:%.+]] = bitcast i8* [[Z_VOID_PTR]] to float** +// CHECK: store float* %{{.+}}, float** [[Z_ADDR]], +#pragma omp allocate(a,z) allocator(omp_default_mem_alloc) +// CHECK: call void @__kmpc_free(i32 [[GTID]], i8* [[Z_VOID_PTR]], i8* inttoptr (i64 1 to i8*)) +// CHECK: call void @__kmpc_free(i32 [[GTID]], i8* [[A_VOID_PTR]], i8* inttoptr (i64 1 to i8*)) +// CHECK: ret void +} #endif