]> granicus.if.org Git - clang/commitdiff
[OPENMP]Allow allocate directive on parameters.
authorAlexey Bataev <a.bataev@hotmail.com>
Tue, 9 Apr 2019 16:31:37 +0000 (16:31 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Tue, 9 Apr 2019 16:31:37 +0000 (16:31 +0000)
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

lib/Sema/SemaOpenMP.cpp
test/OpenMP/allocate_codegen.cpp

index 1ab0e0117f723592ee9ef4ec451be0e5d9a2eca8..59df77d67d83bbcbea2813b900d79e151c5288bd 100644 (file)
@@ -2361,9 +2361,6 @@ Sema::DeclGroupPtrTy Sema::ActOnOpenMPAllocateDirective(
         (VD->getStorageClass() == SC_Register && VD->hasAttr<AsmLabelAttr>() &&
          !VD->isLocalVarDecl()))
       continue;
-    // Do not apply for parameters.
-    if (isa<ParmVarDecl>(VD))
-      continue;
 
     // If the used several times in the allocate directive, the same allocator
     // must be used.
index 827b7012b06a510a3d83217a9d576c045174dbc5..c068589041af3de37f4450ca61c2f39da73efb2d 100644 (file)
@@ -91,4 +91,18 @@ int main () {
 
 // CHECK-NOT:  call {{.+}} {{__kmpc_alloc|__kmpc_free}}
 extern template int ST<int>::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