diff options
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r-- | gcc/omp-low.c | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 27a513e..f7242df 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1161,14 +1161,17 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ALLOCATE && (OMP_CLAUSE_ALLOCATE_ALLOCATOR (c) == NULL_TREE /* omp_default_mem_alloc is 1 */ - || !integer_onep (OMP_CLAUSE_ALLOCATE_ALLOCATOR (c)))) + || !integer_onep (OMP_CLAUSE_ALLOCATE_ALLOCATOR (c)) + || OMP_CLAUSE_ALLOCATE_ALIGN (c) != NULL_TREE)) { if (ctx->allocate_map == NULL) ctx->allocate_map = new hash_map<tree, tree>; - ctx->allocate_map->put (OMP_CLAUSE_DECL (c), - OMP_CLAUSE_ALLOCATE_ALLOCATOR (c) - ? OMP_CLAUSE_ALLOCATE_ALLOCATOR (c) - : integer_zero_node); + tree val = integer_zero_node; + if (OMP_CLAUSE_ALLOCATE_ALLOCATOR (c)) + val = OMP_CLAUSE_ALLOCATE_ALLOCATOR (c); + if (OMP_CLAUSE_ALLOCATE_ALIGN (c)) + val = build_tree_list (val, OMP_CLAUSE_ALLOCATE_ALIGN (c)); + ctx->allocate_map->put (OMP_CLAUSE_DECL (c), val); } for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c)) @@ -3918,8 +3921,12 @@ omp_runtime_api_call (const_tree fndecl) { /* This array has 3 sections. First omp_* calls that don't have any suffixes. */ - "omp_alloc", - "omp_free", + "aligned_alloc", + "aligned_calloc", + "alloc", + "calloc", + "free", + "realloc", "target_alloc", "target_associate_ptr", "target_disassociate_ptr", @@ -4725,6 +4732,12 @@ lower_private_allocate (tree var, tree new_var, tree &allocator, return false; } + unsigned HOST_WIDE_INT ialign = 0; + if (TREE_CODE (allocator) == TREE_LIST) + { + ialign = tree_to_uhwi (TREE_VALUE (allocator)); + allocator = TREE_PURPOSE (allocator); + } if (TREE_CODE (allocator) != INTEGER_CST) allocator = build_outer_var_ref (allocator, ctx); allocator = fold_convert (pointer_sized_int_node, allocator); @@ -4739,21 +4752,21 @@ lower_private_allocate (tree var, tree new_var, tree &allocator, if (TYPE_P (new_var)) { ptr_type = build_pointer_type (new_var); - align = build_int_cst (size_type_node, TYPE_ALIGN_UNIT (new_var)); + ialign = MAX (ialign, TYPE_ALIGN_UNIT (new_var)); } else if (is_ref) { ptr_type = build_pointer_type (TREE_TYPE (TREE_TYPE (new_var))); - align = build_int_cst (size_type_node, - TYPE_ALIGN_UNIT (TREE_TYPE (ptr_type))); + ialign = MAX (ialign, TYPE_ALIGN_UNIT (TREE_TYPE (ptr_type))); } else { ptr_type = build_pointer_type (TREE_TYPE (new_var)); - align = build_int_cst (size_type_node, DECL_ALIGN_UNIT (new_var)); + ialign = MAX (ialign, DECL_ALIGN_UNIT (new_var)); if (sz == NULL_TREE) sz = fold_convert (size_type_node, DECL_SIZE_UNIT (new_var)); } + align = build_int_cst (size_type_node, ialign); if (TREE_CODE (sz) != INTEGER_CST) { tree szvar = create_tmp_var (size_type_node); @@ -5707,6 +5720,8 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, if (tree *allocatep = ctx->allocate_map->get (var)) { allocator = *allocatep; + if (TREE_CODE (allocator) == TREE_LIST) + allocator = TREE_PURPOSE (allocator); if (TREE_CODE (allocator) != INTEGER_CST) allocator = build_outer_var_ref (allocator, ctx); allocator = fold_convert (pointer_sized_int_node, @@ -6025,6 +6040,8 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, if (tree *allocatep = ctx->allocate_map->get (var)) { allocator = *allocatep; + if (TREE_CODE (allocator) == TREE_LIST) + allocator = TREE_PURPOSE (allocator); if (TREE_CODE (allocator) != INTEGER_CST) allocator = build_outer_var_ref (allocator, ctx); allocator = fold_convert (pointer_sized_int_node, @@ -12070,6 +12087,12 @@ create_task_copyfn (gomp_task *task_stmt, omp_context *ctx) if (tree *allocatorp = ctx->allocate_map->get (decl)) { tree allocator = *allocatorp; + HOST_WIDE_INT ialign = 0; + if (TREE_CODE (allocator) == TREE_LIST) + { + ialign = tree_to_uhwi (TREE_VALUE (allocator)); + allocator = TREE_PURPOSE (allocator); + } if (TREE_CODE (allocator) != INTEGER_CST) { n = splay_tree_lookup (ctx->sfield_map, @@ -12083,7 +12106,8 @@ create_task_copyfn (gomp_task *task_stmt, omp_context *ctx) allocator = fold_convert (pointer_sized_int_node, allocator); tree a = builtin_decl_explicit (BUILT_IN_GOMP_ALLOC); tree align = build_int_cst (size_type_node, - DECL_ALIGN_UNIT (decl)); + MAX (ialign, + DECL_ALIGN_UNIT (decl))); tree sz = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (dst))); tree ptr = build_call_expr_loc (loc, a, 3, align, sz, allocator); |