From a6bd380438744b75e0f86176c6fe337126b6be27 Mon Sep 17 00:00:00 2001 From: Janne Blomqvist Date: Sun, 1 Jul 2007 15:08:59 +0300 Subject: [PATCH] fortran frontend: 2007-07-01 Janne Blomqvist * trans.h: Remove decls for 64-bit allocation functions. * trans-array.c (gfc_grow_array): Always pick the standard realloc function decl. (gfc_array_allocate): Likewise. * trans-decl.c: Remove trees for 64-bit allocation functions. (gfc_build_builtin_function_decls): Don't build fndecls for 64-bit allocations functions, use index_int_type for normal allocation functions. libgfortran changelog: 2007-07-01 Janne Blomqvist * runtime/memory.c (internal_realloc): Use index_type for size argument instead of GFC_INTEGER_4. (allocate_array): Likewise. (allocate): Likewise, add ifdef around unnecessary check. (internal_reallo64): Remove. (allocate_array64): Remove. (allocate64): Remove. * gfortran.map: Remove symbols for 64-bit allocation functions. From-SVN: r126166 --- gcc/fortran/ChangeLog | 11 ++++++ gcc/fortran/trans-array.c | 16 +++------ gcc/fortran/trans-decl.c | 29 +++------------- gcc/fortran/trans.h | 3 -- libgfortran/ChangeLog | 11 ++++++ libgfortran/gfortran.map | 3 -- libgfortran/runtime/memory.c | 79 +++++++------------------------------------- 7 files changed, 42 insertions(+), 110 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7c0618d..d76029d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,14 @@ +2007-07-01 Janne Blomqvist + + * trans.h: Remove decls for 64-bit allocation functions. + * trans-array.c (gfc_grow_array): Always pick the standard realloc + function decl. + (gfc_array_allocate): Likewise. + * trans-decl.c: Remove trees for 64-bit allocation functions. + (gfc_build_builtin_function_decls): Don't build fndecls for 64-bit + allocations functions, use index_int_type for normal allocation + functions. + 2007-06-30 Daniel Franke PR fortran/20373 diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 8b13e67..07862d6 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -842,11 +842,9 @@ gfc_grow_array (stmtblock_t * pblock, tree desc, tree extra) arg1 = build2 (MULT_EXPR, gfc_array_index_type, tmp, fold_convert (gfc_array_index_type, size)); - /* Pick the appropriate realloc function. */ - if (gfc_index_integer_kind == 4) + /* Pick the realloc function. */ + if (gfc_index_integer_kind == 4 || gfc_index_integer_kind == 8) tmp = gfor_fndecl_internal_realloc; - else if (gfc_index_integer_kind == 8) - tmp = gfor_fndecl_internal_realloc64; else gcc_unreachable (); @@ -3575,20 +3573,14 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree pstat) pointer = gfc_conv_descriptor_data_get (se->expr); STRIP_NOPS (pointer); - if (TYPE_PRECISION (gfc_array_index_type) == 32) + if (TYPE_PRECISION (gfc_array_index_type) == 32 || + TYPE_PRECISION (gfc_array_index_type) == 64) { if (allocatable_array) allocate = gfor_fndecl_allocate_array; else allocate = gfor_fndecl_allocate; } - else if (TYPE_PRECISION (gfc_array_index_type) == 64) - { - if (allocatable_array) - allocate = gfor_fndecl_allocate64_array; - else - allocate = gfor_fndecl_allocate64; - } else gcc_unreachable (); diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 0ab2d74..e1379ba 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -75,11 +75,8 @@ tree gfc_static_ctors; /* Function declarations for builtin library functions. */ tree gfor_fndecl_internal_realloc; -tree gfor_fndecl_internal_realloc64; tree gfor_fndecl_allocate; -tree gfor_fndecl_allocate64; tree gfor_fndecl_allocate_array; -tree gfor_fndecl_allocate64_array; tree gfor_fndecl_deallocate; tree gfor_fndecl_pause_numeric; tree gfor_fndecl_pause_string; @@ -2241,46 +2238,28 @@ gfc_build_builtin_function_decls (void) { tree gfc_c_int_type_node = gfc_get_int_type (gfc_c_int_kind); tree gfc_int4_type_node = gfc_get_int_type (4); - tree gfc_int8_type_node = gfc_get_int_type (8); tree gfc_logical4_type_node = gfc_get_logical_type (4); tree gfc_pint4_type_node = build_pointer_type (gfc_int4_type_node); + tree gfc_index_int_type_node = gfc_get_int_type (gfc_index_integer_kind); gfor_fndecl_internal_realloc = gfc_build_library_function_decl (get_identifier (PREFIX("internal_realloc")), pvoid_type_node, 2, pvoid_type_node, - gfc_int4_type_node); - - gfor_fndecl_internal_realloc64 = - gfc_build_library_function_decl (get_identifier - (PREFIX("internal_realloc64")), - pvoid_type_node, 2, pvoid_type_node, - gfc_int8_type_node); + gfc_index_int_type_node); gfor_fndecl_allocate = gfc_build_library_function_decl (get_identifier (PREFIX("allocate")), pvoid_type_node, 2, - gfc_int4_type_node, gfc_pint4_type_node); + gfc_index_int_type_node, gfc_pint4_type_node); DECL_IS_MALLOC (gfor_fndecl_allocate) = 1; - gfor_fndecl_allocate64 = - gfc_build_library_function_decl (get_identifier (PREFIX("allocate64")), - pvoid_type_node, 2, - gfc_int8_type_node, gfc_pint4_type_node); - DECL_IS_MALLOC (gfor_fndecl_allocate64) = 1; - gfor_fndecl_allocate_array = gfc_build_library_function_decl (get_identifier (PREFIX("allocate_array")), pvoid_type_node, 3, pvoid_type_node, - gfc_int4_type_node, gfc_pint4_type_node); + gfc_index_int_type_node, gfc_pint4_type_node); DECL_IS_MALLOC (gfor_fndecl_allocate_array) = 1; - gfor_fndecl_allocate64_array = - gfc_build_library_function_decl (get_identifier (PREFIX("allocate64_array")), - pvoid_type_node, 3, pvoid_type_node, - gfc_int8_type_node, gfc_pint4_type_node); - DECL_IS_MALLOC (gfor_fndecl_allocate64_array) = 1; - gfor_fndecl_deallocate = gfc_build_library_function_decl (get_identifier (PREFIX("deallocate")), void_type_node, 2, pvoid_type_node, diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index f2a5d44..a57deca 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -482,11 +482,8 @@ void gfc_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *, tree); /* Runtime library function decls. */ extern GTY(()) tree gfor_fndecl_internal_realloc; -extern GTY(()) tree gfor_fndecl_internal_realloc64; extern GTY(()) tree gfor_fndecl_allocate; -extern GTY(()) tree gfor_fndecl_allocate64; extern GTY(()) tree gfor_fndecl_allocate_array; -extern GTY(()) tree gfor_fndecl_allocate64_array; extern GTY(()) tree gfor_fndecl_deallocate; extern GTY(()) tree gfor_fndecl_pause_numeric; extern GTY(()) tree gfor_fndecl_pause_string; diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 0b5afde..1b6a6bd 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,14 @@ +2007-07-01 Janne Blomqvist + + * runtime/memory.c (internal_realloc): Use index_type for size + argument instead of GFC_INTEGER_4. + (allocate_array): Likewise. + (allocate): Likewise, add ifdef around unnecessary check. + (internal_reallo64): Remove. + (allocate_array64): Remove. + (allocate64): Remove. + * gfortran.map: Remove symbols for 64-bit allocation functions. + 2007-06-29 Jerry DeLisle PR libgfortran/32456 diff --git a/libgfortran/gfortran.map b/libgfortran/gfortran.map index f67192d..e135784 100644 --- a/libgfortran/gfortran.map +++ b/libgfortran/gfortran.map @@ -10,8 +10,6 @@ GFORTRAN_1.0 { _gfortran_all_l4; _gfortran_all_l8; _gfortran_allocate; - _gfortran_allocate64; - _gfortran_allocate64_array; _gfortran_allocate_array; _gfortran_any_l16; _gfortran_any_l4; @@ -168,7 +166,6 @@ GFORTRAN_1.0 { _gfortran_ierrno_i8; _gfortran_internal_pack; _gfortran_internal_realloc; - _gfortran_internal_realloc64; _gfortran_internal_unpack; _gfortran_irand; _gfortran_isatty_l4; diff --git a/libgfortran/runtime/memory.c b/libgfortran/runtime/memory.c index 53643dc..7d89371 100644 --- a/libgfortran/runtime/memory.c +++ b/libgfortran/runtime/memory.c @@ -1,5 +1,5 @@ /* Memory management routines. - Copyright 2002, 2005, 2006 Free Software Foundation, Inc. + Copyright 2002, 2005, 2006, 2007 Free Software Foundation, Inc. Contributed by Paul Brook This file is part of the GNU Fortran 95 runtime library (libgfortran). @@ -102,11 +102,11 @@ internal_realloc_size (void *mem, size_t size) return mem; } -extern void *internal_realloc (void *, GFC_INTEGER_4); +extern void *internal_realloc (void *, index_type); export_proto(internal_realloc); void * -internal_realloc (void *mem, GFC_INTEGER_4 size) +internal_realloc (void *mem, index_type size) { #ifdef GFC_CHECK_MEMORY /* Under normal circumstances, this is _never_ going to happen! */ @@ -116,21 +116,6 @@ internal_realloc (void *mem, GFC_INTEGER_4 size) return internal_realloc_size (mem, (size_t) size); } -extern void *internal_realloc64 (void *, GFC_INTEGER_8); -export_proto(internal_realloc64); - -void * -internal_realloc64 (void *mem, GFC_INTEGER_8 size) -{ -#ifdef GFC_CHECK_MEMORY - /* Under normal circumstances, this is _never_ going to happen! */ - if (size < 0) - runtime_error ("Attempt to allocate a negative amount of memory."); -#endif - return internal_realloc_size (mem, (size_t) size); -} - - /* User-allocate, one call for each member of the alloc-list of an ALLOCATE statement. */ @@ -157,12 +142,15 @@ allocate_size (size_t size, GFC_INTEGER_4 * stat) return newmem; } -extern void *allocate (GFC_INTEGER_4, GFC_INTEGER_4 *); +extern void *allocate (index_type, GFC_INTEGER_4 *); export_proto(allocate); void * -allocate (GFC_INTEGER_4 size, GFC_INTEGER_4 * stat) +allocate (index_type size, GFC_INTEGER_4 * stat) { +#ifdef GFC_CHECK_MEMORY + /* The only time this can happen is the size computed by the + frontend wraps around. */ if (size < 0) { if (stat) @@ -174,40 +162,19 @@ allocate (GFC_INTEGER_4 size, GFC_INTEGER_4 * stat) runtime_error ("Attempt to allocate negative amount of memory. " "Possible integer overflow"); } - - return allocate_size ((size_t) size, stat); -} - -extern void *allocate64 (GFC_INTEGER_8, GFC_INTEGER_4 *); -export_proto(allocate64); - -void * -allocate64 (GFC_INTEGER_8 size, GFC_INTEGER_4 * stat) -{ - if (size < 0) - { - if (stat) - { - *stat = ERROR_ALLOCATION; - return NULL; - } - else - runtime_error ("ALLOCATE64: Attempt to allocate negative amount of " - "memory. Possible integer overflow"); - } - +#endif return allocate_size ((size_t) size, stat); } /* Function to call in an ALLOCATE statement when the argument is an allocatable array. If the array is currently allocated, it is - an error to allocate it again. 32-bit version. */ + an error to allocate it again. */ -extern void *allocate_array (void *, GFC_INTEGER_4, GFC_INTEGER_4 *); +extern void *allocate_array (void *, index_type, GFC_INTEGER_4 *); export_proto(allocate_array); void * -allocate_array (void *mem, GFC_INTEGER_4 size, GFC_INTEGER_4 * stat) +allocate_array (void *mem, index_type size, GFC_INTEGER_4 * stat) { if (mem == NULL) return allocate (size, stat); @@ -222,28 +189,6 @@ allocate_array (void *mem, GFC_INTEGER_4 size, GFC_INTEGER_4 * stat) runtime_error ("Attempting to allocate already allocated array."); } -/* Function to call in an ALLOCATE statement when the argument is an - allocatable array. If the array is currently allocated, it is - an error to allocate it again. 64-bit version. */ - -extern void *allocate64_array (void *, GFC_INTEGER_8, GFC_INTEGER_4 *); -export_proto(allocate64_array); - -void * -allocate64_array (void *mem, GFC_INTEGER_8 size, GFC_INTEGER_4 * stat) -{ - if (mem == NULL) - return allocate64 (size, stat); - if (stat) - { - free (mem); - mem = allocate (size, stat); - *stat = ERROR_ALLOCATION; - return mem; - } - - runtime_error ("Attempting to allocate already allocated array."); -} /* User-deallocate; pointer is then NULLified by the front-end. */ -- 2.7.4