Re: [PATCH] Use more ARRAY_SIZE.

2022-05-23 Thread Martin Liška
On 5/23/22 09:56, Iain Buclaw wrote:
> Excerpts from Martin Liška's message of Mai 11, 2022 10:17 am:
>> On 5/9/22 14:03, Richard Biener wrote:
>>> On Thu, May 5, 2022 at 4:30 PM Martin Liška  wrote:

 On 5/5/22 14:58, Iain Buclaw wrote:
> This D front-end change doesn't look right to me, besides the slight

 Hello.

 Sorry, I've re-read the patch and fixed some places where the macro usage
 was wrong.

 Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>>
>>> The middle-end parts are OK.  I'd say in files where ARRAY_SIZE is already
>>> used it's OK to introduce more uses.  Otherwise I defer to the more specific
>>> maintainers if they like this or not.
>>
>> All right, CCing the following maintainers for other parts:
>>
>> - David for JIT and Analyzer
>> - Tobias for Fortran part
>> - Jason for C-family part
>>
> 
> Hi Martin,

Hello.

> 
> When running through contrib/config-list.mk, I noticed that this also
> broke the build for the following obsolete targets:

My periodic testers confirm that and I'm going to install the following patch.

Cheers,
Martin

> 
> tilegx-linux-gnu
> tilegxbe-linux-gnu
> tilepro-linux-gnu
> 
> ---
> gcc/config/tilepro/gen-mul-tables.cc: In function ‘void 
> find_sequences(ExpressionTree&, ExpressionTreeMap&)’:
> gcc/config/tilepro/gen-mul-tables.cc:465:26: error: ‘ARRAY_SIZE’ was not 
> declared in this scope
>   465 |   for (size_t f = 0; f < ARRAY_SIZE (ops); f++)
>   |  ^~
> gcc/config/tilepro/gen-mul-tables.cc: In function ‘void 
> create_insn_code_compression_table()’:
> gcc/config/tilepro/gen-mul-tables.cc:567:26: error: ‘ARRAY_SIZE’ was not 
> declared in this scope
>   567 |   for (size_t i = 0; i < ARRAY_SIZE (ops); i++)
>   |  ^~
> ---
From 63798f67dcc848dcd110ce222b97304565c9ea29 Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Mon, 23 May 2022 13:54:53 +0200
Subject: [PATCH] tilepro: fix missing ARRAY_SIZE macro

gcc/ChangeLog:

	* config/tilepro/gen-mul-tables.cc (ARRAY_SIZE): Add new macro.
---
 gcc/config/tilepro/gen-mul-tables.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/config/tilepro/gen-mul-tables.cc b/gcc/config/tilepro/gen-mul-tables.cc
index 798766a723b..52183982f65 100644
--- a/gcc/config/tilepro/gen-mul-tables.cc
+++ b/gcc/config/tilepro/gen-mul-tables.cc
@@ -90,6 +90,8 @@ typedef long long MUL_TYPE;
 #define MIN(x, y)  ((x) <= (y) ? (x) : (y))
 #define MAX(x, y)  ((x) >= (y) ? (x) : (y))
 
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+
 /* For this program a unary op is one which has only one nonconstant
operand.  So shift left by 5 is considered unary.  */
 typedef MUL_TYPE (*unary_op_func) (MUL_TYPE);
-- 
2.36.1



Re: [PATCH] Use more ARRAY_SIZE.

2022-05-23 Thread Iain Buclaw via Gcc-patches
Excerpts from Martin Liška's message of Mai 11, 2022 10:17 am:
> On 5/9/22 14:03, Richard Biener wrote:
>> On Thu, May 5, 2022 at 4:30 PM Martin Liška  wrote:
>>>
>>> On 5/5/22 14:58, Iain Buclaw wrote:
 This D front-end change doesn't look right to me, besides the slight
>>>
>>> Hello.
>>>
>>> Sorry, I've re-read the patch and fixed some places where the macro usage
>>> was wrong.
>>>
>>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>> 
>> The middle-end parts are OK.  I'd say in files where ARRAY_SIZE is already
>> used it's OK to introduce more uses.  Otherwise I defer to the more specific
>> maintainers if they like this or not.
> 
> All right, CCing the following maintainers for other parts:
> 
> - David for JIT and Analyzer
> - Tobias for Fortran part
> - Jason for C-family part
> 

Hi Martin,

When running through contrib/config-list.mk, I noticed that this also
broke the build for the following obsolete targets:

tilegx-linux-gnu
tilegxbe-linux-gnu
tilepro-linux-gnu

---
gcc/config/tilepro/gen-mul-tables.cc: In function ‘void 
find_sequences(ExpressionTree&, ExpressionTreeMap&)’:
gcc/config/tilepro/gen-mul-tables.cc:465:26: error: ‘ARRAY_SIZE’ was not 
declared in this scope
  465 |   for (size_t f = 0; f < ARRAY_SIZE (ops); f++)
  |  ^~
gcc/config/tilepro/gen-mul-tables.cc: In function ‘void 
create_insn_code_compression_table()’:
gcc/config/tilepro/gen-mul-tables.cc:567:26: error: ‘ARRAY_SIZE’ was not 
declared in this scope
  567 |   for (size_t i = 0; i < ARRAY_SIZE (ops); i++)
  |  ^~
---


Re: [committed] Revert 'Use more ARRAY_SIZE.' for mkoffload (was: [PATCH] Use more ARRAY_SIZE.)

2022-05-18 Thread Martin Liška
On 5/17/22 21:03, Tobias Burnus wrote:
> This patch broke offloading – fixed by reverting the patch for
> {gcn,nvptx}/mkoffload.cc – and committed as obvious. Changing a C-code
> generating string without telling the then called C compiler about the
> macro won't fly.  See attachment for
> r13-569-gc9852156dd2fedec130f6d8eb669579ef6237946, which reverts it for
> mkoffload.cc, only.

Thank you for the fix and sorry for the code breakage ;)

Cheers,
Martin


[committed] Revert 'Use more ARRAY_SIZE.' for mkoffload (was: [PATCH] Use more ARRAY_SIZE.)

2022-05-17 Thread Tobias Burnus

Hi Martin,

On 16.05.22 10:39, Martin Liška wrote:

All right, CCing the following maintainers for other parts:

- David for JIT and Analyzer
- Tobias for Fortran part
- Jason for C-family part


Sorry for having missed that review request – and thanks to Mikael for
doing the review!

And thanks for the patch in general.


There are not further comments from the remaining C-family part so I'm going
to install the patch.


This patch broke offloading – fixed by reverting the patch for
{gcn,nvptx}/mkoffload.cc – and committed as obvious. Changing a C-code
generating string without telling the then called C compiler about the
macro won't fly.  See attachment for
r13-569-gc9852156dd2fedec130f6d8eb669579ef6237946, which reverts it for
mkoffload.cc, only.

Tobias
-
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
München, HRB 106955
commit c9852156dd2fedec130f6d8eb669579ef6237946
Author: Tobias Burnus 
Date:   Tue May 17 20:46:29 2022 +0200

Revert 'Use more ARRAY_SIZE.' for mkoffload

Revert commit r13-472-gca32b29ec3e92dcf8dda5c2501d0baf9dd1cb09d partially;
namely for {gcn,nvptx}/mkoffload.cc, only.

The patch changed 'sizeof(...)/sizeof(...[0])' to the 'ARRAY_SIZE' macro,
which is in principle a good idea – except that in the two mkoffload.cc,
the change happened inside a string that is used to generate plain C code.

With offlading to nvptx or gcn, the mkoffload genenates then the C file
and compilation of the latter fails with
"warning: implicit declaration of function 'ARRAY_SIZE'" followed by
"error: initializer element is not constant"

gcc/
* config/gcn/mkoffload.cc (process_obj): Revert: Use ARRAY_SIZE.
* config/nvptx/mkoffload.cc (process): Likewise.
---
 gcc/config/gcn/mkoffload.cc   | 2 +-
 gcc/config/nvptx/mkoffload.cc | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/config/gcn/mkoffload.cc b/gcc/config/gcn/mkoffload.cc
index 9db2124b129..94ba7ffa5af 100644
--- a/gcc/config/gcn/mkoffload.cc
+++ b/gcc/config/gcn/mkoffload.cc
@@ -723,7 +723,7 @@ process_obj (FILE *in, FILE *cfile)
 	   "  unsigned global_variable_count;\n"
 	   "} target_data = {\n"
 	   "  _image,\n"
-	   "  ARRAY_SIZE (gcn_kernels),\n"
+	   "  sizeof (gcn_kernels) / sizeof (gcn_kernels[0]),\n"
 	   "  gcn_kernels,\n"
 	   "  gcn_num_vars\n"
 	   "};\n\n");
diff --git a/gcc/config/nvptx/mkoffload.cc b/gcc/config/nvptx/mkoffload.cc
index fa3b4b76821..b28c1a32292 100644
--- a/gcc/config/nvptx/mkoffload.cc
+++ b/gcc/config/nvptx/mkoffload.cc
@@ -316,11 +316,11 @@ process (FILE *in, FILE *out)
 	   "  const struct nvptx_fn *fn_names;\n"
 	   "  unsigned fn_num;\n"
 	   "} target_data = {\n"
-	   "  ptx_objs, ARRAY_SIZE (ptx_objs),\n"
+	   "  ptx_objs, sizeof (ptx_objs) / sizeof (ptx_objs[0]),\n"
 	   "  var_mappings,"
-	   "  ARRAY_SIZE (var_mappings),\n"
+	   "  sizeof (var_mappings) / sizeof (var_mappings[0]),\n"
 	   "  func_mappings,"
-	   "  ARRAY_SIZE (func_mappings)\n"
+	   "  sizeof (func_mappings) / sizeof (func_mappings[0])\n"
 	   "};\n\n");
 
   fprintf (out, "#ifdef __cplusplus\n"


Re: [PATCH] Use more ARRAY_SIZE.

2022-05-16 Thread Martin Liška
On 5/11/22 10:17, Martin Liška wrote:
> On 5/9/22 14:03, Richard Biener wrote:
>> On Thu, May 5, 2022 at 4:30 PM Martin Liška  wrote:
>>>
>>> On 5/5/22 14:58, Iain Buclaw wrote:
 This D front-end change doesn't look right to me, besides the slight
>>>
>>> Hello.
>>>
>>> Sorry, I've re-read the patch and fixed some places where the macro usage
>>> was wrong.
>>>
>>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>
>> The middle-end parts are OK.  I'd say in files where ARRAY_SIZE is already
>> used it's OK to introduce more uses.  Otherwise I defer to the more specific
>> maintainers if they like this or not.
> 
> All right, CCing the following maintainers for other parts:
> 
> - David for JIT and Analyzer
> - Tobias for Fortran part
> - Jason for C-family part

There are not further comments from the remaining C-family part so I'm going
to install the patch.

Martin

> 
> Thanks,
> Martin
> 
>>
>> Richard.
>>
>>> Martin
> 



Re: [PATCH] Use more ARRAY_SIZE.

2022-05-12 Thread Mikael Morin

Le 11/05/2022 à 10:17, Martin Liška a écrit :

On 5/9/22 14:03, Richard Biener wrote:

On Thu, May 5, 2022 at 4:30 PM Martin Liška  wrote:


On 5/5/22 14:58, Iain Buclaw wrote:

This D front-end change doesn't look right to me, besides the slight


Hello.

Sorry, I've re-read the patch and fixed some places where the macro usage
was wrong.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.


The middle-end parts are OK.  I'd say in files where ARRAY_SIZE is already
used it's OK to introduce more uses.  Otherwise I defer to the more specific
maintainers if they like this or not.


All right, CCing the following maintainers for other parts:

- David for JIT and Analyzer
- Tobias for Fortran part
- Jason for C-family part


OK for fortran.


Re: [PATCH] Use more ARRAY_SIZE.

2022-05-12 Thread Richard Biener via Gcc-patches
On Wed, May 11, 2022 at 10:01 PM David Malcolm via Gcc-patches
 wrote:
>
> On Wed, 2022-05-11 at 15:04 -0400, Eric Gallager wrote:
> > On Wed, May 11, 2022 at 9:53 AM David Malcolm via Gcc-patches
> >  wrote:
> > >
> > > On Thu, 2022-05-05 at 14:16 +0200, Martin Liška wrote:
> > > > Patch can bootstrap on x86_64-linux-gnu and survives regression
> > > > tests.
> > > >
> > > > Ready to be installed?
> > >
> > > I looked over the changes to:
> > >
> > >   gcc/analyzer/*.cc
> > >   gcc/input.cc
> > >   gcc/jit/*.cc
> > >
> > > and they look good to me.
> > >
> > > I assume that you enabled "jit" during the testing, right?  (it's
> > > not
> > > in --enable-languages=all, which is a perennial source of issues).
> > >
> >
> > So, what remains to be done to include "jit" in "all" anyways? Are
> > there still some platforms left that it's not supported on yet or
> > something?
>
> IIRC the issue was that it requires --enable-host-shared, which slows
> down the compiler for everyone else by a few percent (since it requires
> the compiler to be built as position-independent code).

And with all symbols exported aka interposable.  Maybe we could
funnel in -fno-semantic-interposition ... (and see if it makes a difference)

Richard.

>
> Dave
>


Re: [PATCH] Use more ARRAY_SIZE.

2022-05-11 Thread David Malcolm via Gcc-patches
On Wed, 2022-05-11 at 15:04 -0400, Eric Gallager wrote:
> On Wed, May 11, 2022 at 9:53 AM David Malcolm via Gcc-patches
>  wrote:
> > 
> > On Thu, 2022-05-05 at 14:16 +0200, Martin Liška wrote:
> > > Patch can bootstrap on x86_64-linux-gnu and survives regression
> > > tests.
> > > 
> > > Ready to be installed?
> > 
> > I looked over the changes to:
> > 
> >   gcc/analyzer/*.cc
> >   gcc/input.cc
> >   gcc/jit/*.cc
> > 
> > and they look good to me.
> > 
> > I assume that you enabled "jit" during the testing, right?  (it's
> > not
> > in --enable-languages=all, which is a perennial source of issues).
> > 
> 
> So, what remains to be done to include "jit" in "all" anyways? Are
> there still some platforms left that it's not supported on yet or
> something?

IIRC the issue was that it requires --enable-host-shared, which slows
down the compiler for everyone else by a few percent (since it requires
the compiler to be built as position-independent code). 

Dave



Re: [PATCH] Use more ARRAY_SIZE.

2022-05-11 Thread Eric Gallager via Gcc-patches
On Wed, May 11, 2022 at 9:53 AM David Malcolm via Gcc-patches
 wrote:
>
> On Thu, 2022-05-05 at 14:16 +0200, Martin Liška wrote:
> > Patch can bootstrap on x86_64-linux-gnu and survives regression
> > tests.
> >
> > Ready to be installed?
>
> I looked over the changes to:
>
>   gcc/analyzer/*.cc
>   gcc/input.cc
>   gcc/jit/*.cc
>
> and they look good to me.
>
> I assume that you enabled "jit" during the testing, right?  (it's not
> in --enable-languages=all, which is a perennial source of issues).
>

So, what remains to be done to include "jit" in "all" anyways? Are
there still some platforms left that it's not supported on yet or
something?

> Thanks
> Dave
>
>


Re: [PATCH] Use more ARRAY_SIZE.

2022-05-11 Thread David Malcolm via Gcc-patches
On Thu, 2022-05-05 at 14:16 +0200, Martin Liška wrote:
> Patch can bootstrap on x86_64-linux-gnu and survives regression
> tests.
> 
> Ready to be installed?

I looked over the changes to:

  gcc/analyzer/*.cc
  gcc/input.cc
  gcc/jit/*.cc

and they look good to me.

I assume that you enabled "jit" during the testing, right?  (it's not
in --enable-languages=all, which is a perennial source of issues).

Thanks
Dave




Re: [PATCH] Use more ARRAY_SIZE.

2022-05-11 Thread Martin Liška
On 5/9/22 14:03, Richard Biener wrote:
> On Thu, May 5, 2022 at 4:30 PM Martin Liška  wrote:
>>
>> On 5/5/22 14:58, Iain Buclaw wrote:
>>> This D front-end change doesn't look right to me, besides the slight
>>
>> Hello.
>>
>> Sorry, I've re-read the patch and fixed some places where the macro usage
>> was wrong.
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> The middle-end parts are OK.  I'd say in files where ARRAY_SIZE is already
> used it's OK to introduce more uses.  Otherwise I defer to the more specific
> maintainers if they like this or not.

All right, CCing the following maintainers for other parts:

- David for JIT and Analyzer
- Tobias for Fortran part
- Jason for C-family part

Thanks,
Martin

> 
> Richard.
> 
>> Martin



Re: [PATCH] Use more ARRAY_SIZE.

2022-05-09 Thread Richard Biener via Gcc-patches
On Thu, May 5, 2022 at 4:30 PM Martin Liška  wrote:
>
> On 5/5/22 14:58, Iain Buclaw wrote:
> > This D front-end change doesn't look right to me, besides the slight
>
> Hello.
>
> Sorry, I've re-read the patch and fixed some places where the macro usage
> was wrong.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

The middle-end parts are OK.  I'd say in files where ARRAY_SIZE is already
used it's OK to introduce more uses.  Otherwise I defer to the more specific
maintainers if they like this or not.

Richard.

> Martin


Re: [PATCH] Use more ARRAY_SIZE.

2022-05-09 Thread Arnaud Charlet via Gcc-patches
> > So I don't see how your patch can work, can you clarify?
> 
> Sorry for that, fixed in the updated version.

Assuming you're getting a successful Ada build, the Ada part is OK.

> From 5ad8fe059d3419446647eadf8785c768b647d15b Mon Sep 17 00:00:00 2001
> From: Martin Liska 
> Date: Thu, 13 Jan 2022 18:46:26 +0100
> Subject: [PATCH] Use more ARRAY_SIZE.
> 
> gcc/ada/ChangeLog:
> 
>   * locales.c (iso_639_1_to_639_3): Use ARRAY_SIZE.
>   (language_name_to_639_3): Likewise.
>   (country_name_to_3166): Likewise.


Re: [PATCH] Use more ARRAY_SIZE.

2022-05-09 Thread Martin Liška
On 5/9/22 12:21, Arnaud Charlet wrote:
> So I don't see how your patch can work, can you clarify?

Sorry for that, fixed in the updated version.

Cheers,
MartinFrom 5ad8fe059d3419446647eadf8785c768b647d15b Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Thu, 13 Jan 2022 18:46:26 +0100
Subject: [PATCH] Use more ARRAY_SIZE.

gcc/ada/ChangeLog:

	* locales.c (iso_639_1_to_639_3): Use ARRAY_SIZE.
	(language_name_to_639_3): Likewise.
	(country_name_to_3166): Likewise.

gcc/analyzer/ChangeLog:

	* engine.cc (exploded_node::get_dot_fillcolor): Use ARRAY_SIZE.
	* function-set.cc (test_stdio_example): Likewise.
	* sm-file.cc (get_file_using_fns): Likewise.
	* sm-malloc.cc (malloc_state_machine::unaffected_by_call_p): Likewise.
	* sm-signal.cc (get_async_signal_unsafe_fns): Likewise.

gcc/ChangeLog:

	* attribs.cc (diag_attr_exclusions): Use ARRAY_SIZE.
	(decls_mismatched_attributes): Likewise.
	* builtins.cc (c_strlen): Likewise.
	* cfg.cc (DEF_BASIC_BLOCK_FLAG): Likewise.
	* common/config/aarch64/aarch64-common.cc (aarch64_option_init_struct): Likewise.
	* config/aarch64/aarch64-builtins.cc (aarch64_lookup_simd_builtin_type): Likewise.
	(aarch64_init_simd_builtin_types): Likewise.
	(aarch64_init_builtin_rsqrt): Likewise.
	* config/aarch64/aarch64.cc (is_madd_op): Likewise.
	* config/arm/arm-builtins.cc (arm_lookup_simd_builtin_type): Likewise.
	(arm_init_simd_builtin_types): Likewise.
	* config/avr/gen-avr-mmcu-texi.cc (mcus[ARRAY_SIZE): Likewise.
	(c_prefix): Likewise.
	(main): Likewise.
	* config/c6x/c6x.cc (N_SAVE_ORDER): Likewise.
	* config/darwin-c.cc (darwin_register_frameworks): Likewise.
	* config/gcn/mkoffload.cc (process_obj): Likewise.
	* config/i386/i386-builtins.cc (get_builtin_code_for_version): Likewise.
	(fold_builtin_cpu): Likewise.
	* config/m32c/m32c.cc (PUSHM_N): Likewise.
	* config/nvptx/mkoffload.cc (process): Likewise.
	* config/rs6000/driver-rs6000.cc (host_detect_local_cpu): Likewise.
	* config/s390/s390.cc (NR_C_MODES): Likewise.
	* config/tilepro/gen-mul-tables.cc (find_sequences): Likewise.
	(create_insn_code_compression_table): Likewise.
	* config/vms/vms.cc (NBR_CRTL_NAMES): Likewise.
	* diagnostic-format-json.cc (json_from_expanded_location): Likewise.
	* dwarf2out.cc (ARRAY_SIZE): Likewise.
	* genhooks.cc (emit_documentation): Likewise.
	(emit_init_macros): Likewise.
	* gimple-ssa-sprintf.cc (format_floating): Likewise.
	* gimple-ssa-warn-access.cc (memmodel_name): Likewise.
	* godump.cc (keyword_hash_init): Likewise.
	* hash-table.cc (hash_table_higher_prime_index): Likewise.
	* input.cc (for_each_line_table_case): Likewise.
	* ipa-free-lang-data.cc (free_lang_data): Likewise.
	* ipa-inline.cc (sanitize_attrs_match_for_inline_p): Likewise.
	* optc-save-gen.awk: Likewise.
	* spellcheck.cc (test_metric_conditions): Likewise.
	* tree-vect-slp-patterns.cc (sizeof): Likewise.
	(ARRAY_SIZE): Likewise.
	* tree.cc (build_common_tree_nodes): Likewise.

gcc/c-family/ChangeLog:

	* c-common.cc (ARRAY_SIZE): Use ARRAY_SIZE.
	(c_common_nodes_and_builtins): Likewise.
	* c-format.cc (check_tokens): Likewise.
	(check_plain): Likewise.
	* c-pragma.cc (c_pp_lookup_pragma): Likewise.
	(init_pragma): Likewise.
	* known-headers.cc (get_string_macro_hint): Likewise.
	(get_stdlib_header_for_name): Likewise.
	* c-attribs.cc: Likewise.

gcc/c/ChangeLog:

	* c-decl.cc (match_builtin_function_types): Use ARRAY_SIZE.

gcc/cp/ChangeLog:

	* module.cc (depset::entity_kind_name): Use ARRAY_SIZE.
	* name-lookup.cc (get_std_name_hint): Likewise.
	* parser.cc (cp_parser_new): Likewise.

gcc/fortran/ChangeLog:

	* frontend-passes.cc (gfc_code_walker): Use ARRAY_SIZE.
	* openmp.cc (gfc_match_omp_context_selector_specification): Likewise.
	* trans-intrinsic.cc (conv_intrinsic_ieee_builtin): Likewise.
	* trans-types.cc (gfc_get_array_descr_info): Likewise.

gcc/jit/ChangeLog:

	* jit-builtins.cc (find_builtin_by_name): Use ARRAY_SIZE.
	(get_string_for_type_id): Likewise.
	* jit-recording.cc (recording::context::context): Likewise.

gcc/lto/ChangeLog:

	* lto-common.cc (lto_resolution_read): Use ARRAY_SIZE.
	* lto-lang.cc (lto_init): Likewise.
---
 gcc/ada/locales.c   |  8 +---
 gcc/analyzer/engine.cc  |  2 +-
 gcc/analyzer/function-set.cc|  2 +-
 gcc/analyzer/sm-file.cc |  3 +--
 gcc/analyzer/sm-malloc.cc   |  3 +--
 gcc/analyzer/sm-signal.cc   |  3 +--
 gcc/attribs.cc  |  4 ++--
 gcc/builtins.cc |  2 +-
 gcc/c-family/c-attribs.cc   |  3 +--
 gcc/c-family/c-common.cc|  7 ++-
 gcc/c-family/c-format.cc| 12 ++--
 gcc/c-family/c-pragma.cc|  9 -
 gcc/c-family/known-headers.cc   |  5 ++---
 gcc/c/c-decl.cc |  8 +++-
 gcc/cfg.cc  |  2 +-
 gcc/common/config/aarch64/aarch64-common

Re: [PATCH] Use more ARRAY_SIZE.

2022-05-09 Thread Arnaud Charlet via Gcc-patches
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Ready to be installed?
> Thanks,
> Martin
> 
> gcc/ada/ChangeLog:
> 
>   * locales.c (iso_639_1_to_639_3): Use ARRAY_SIZE.
>   (language_name_to_639_3): Likewise.
>   (country_name_to_3166): Likewise.

Can you clarify where ARRAY_SIZE is defined? locales.c only contains:

#include 
#include 
#include 

So I don't see how your patch can work, can you clarify?
Also, did you perform a build with Ada enabled with this change?

Arno


Re: [PATCH] Use more ARRAY_SIZE.

2022-05-05 Thread Martin Liška
On 5/5/22 14:58, Iain Buclaw wrote:
> This D front-end change doesn't look right to me, besides the slight

Hello.

Sorry, I've re-read the patch and fixed some places where the macro usage
was wrong.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

MartinFrom 8d9630e411321c8584dd83ff64ec6fefad48813e Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Thu, 13 Jan 2022 18:46:26 +0100
Subject: [PATCH] Use more ARRAY_SIZE.

gcc/ada/ChangeLog:

	* locales.c (iso_639_1_to_639_3): Use ARRAY_SIZE.
	(language_name_to_639_3): Likewise.
	(country_name_to_3166): Likewise.

gcc/analyzer/ChangeLog:

	* engine.cc (exploded_node::get_dot_fillcolor): Use ARRAY_SIZE.
	* function-set.cc (test_stdio_example): Likewise.
	* sm-file.cc (get_file_using_fns): Likewise.
	* sm-malloc.cc (malloc_state_machine::unaffected_by_call_p): Likewise.
	* sm-signal.cc (get_async_signal_unsafe_fns): Likewise.

gcc/ChangeLog:

	* attribs.cc (diag_attr_exclusions): Use ARRAY_SIZE.
	(decls_mismatched_attributes): Likewise.
	* builtins.cc (c_strlen): Likewise.
	* cfg.cc (DEF_BASIC_BLOCK_FLAG): Likewise.
	* common/config/aarch64/aarch64-common.cc (aarch64_option_init_struct): Likewise.
	* config/aarch64/aarch64-builtins.cc (aarch64_lookup_simd_builtin_type): Likewise.
	(aarch64_init_simd_builtin_types): Likewise.
	(aarch64_init_builtin_rsqrt): Likewise.
	* config/aarch64/aarch64.cc (is_madd_op): Likewise.
	* config/arm/arm-builtins.cc (arm_lookup_simd_builtin_type): Likewise.
	(arm_init_simd_builtin_types): Likewise.
	* config/avr/gen-avr-mmcu-texi.cc (mcus[ARRAY_SIZE): Likewise.
	(c_prefix): Likewise.
	(main): Likewise.
	* config/c6x/c6x.cc (N_SAVE_ORDER): Likewise.
	* config/darwin-c.cc (darwin_register_frameworks): Likewise.
	* config/gcn/mkoffload.cc (process_obj): Likewise.
	* config/i386/i386-builtins.cc (get_builtin_code_for_version): Likewise.
	(fold_builtin_cpu): Likewise.
	* config/m32c/m32c.cc (PUSHM_N): Likewise.
	* config/nvptx/mkoffload.cc (process): Likewise.
	* config/rs6000/driver-rs6000.cc (host_detect_local_cpu): Likewise.
	* config/s390/s390.cc (NR_C_MODES): Likewise.
	* config/tilepro/gen-mul-tables.cc (find_sequences): Likewise.
	(create_insn_code_compression_table): Likewise.
	* config/vms/vms.cc (NBR_CRTL_NAMES): Likewise.
	* diagnostic-format-json.cc (json_from_expanded_location): Likewise.
	* dwarf2out.cc (ARRAY_SIZE): Likewise.
	* genhooks.cc (emit_documentation): Likewise.
	(emit_init_macros): Likewise.
	* gimple-ssa-sprintf.cc (format_floating): Likewise.
	* gimple-ssa-warn-access.cc (memmodel_name): Likewise.
	* godump.cc (keyword_hash_init): Likewise.
	* hash-table.cc (hash_table_higher_prime_index): Likewise.
	* input.cc (for_each_line_table_case): Likewise.
	* ipa-free-lang-data.cc (free_lang_data): Likewise.
	* ipa-inline.cc (sanitize_attrs_match_for_inline_p): Likewise.
	* optc-save-gen.awk: Likewise.
	* spellcheck.cc (test_metric_conditions): Likewise.
	* tree-vect-slp-patterns.cc (sizeof): Likewise.
	(ARRAY_SIZE): Likewise.
	* tree.cc (build_common_tree_nodes): Likewise.

gcc/c-family/ChangeLog:

	* c-common.cc (ARRAY_SIZE): Use ARRAY_SIZE.
	(c_common_nodes_and_builtins): Likewise.
	* c-format.cc (check_tokens): Likewise.
	(check_plain): Likewise.
	* c-pragma.cc (c_pp_lookup_pragma): Likewise.
	(init_pragma): Likewise.
	* known-headers.cc (get_string_macro_hint): Likewise.
	(get_stdlib_header_for_name): Likewise.
	* c-attribs.cc: Likewise.

gcc/c/ChangeLog:

	* c-decl.cc (match_builtin_function_types): Use ARRAY_SIZE.

gcc/cp/ChangeLog:

	* module.cc (depset::entity_kind_name): Use ARRAY_SIZE.
	* name-lookup.cc (get_std_name_hint): Likewise.
	* parser.cc (cp_parser_new): Likewise.

gcc/fortran/ChangeLog:

	* frontend-passes.cc (gfc_code_walker): Use ARRAY_SIZE.
	* openmp.cc (gfc_match_omp_context_selector_specification): Likewise.
	* trans-intrinsic.cc (conv_intrinsic_ieee_builtin): Likewise.
	* trans-types.cc (gfc_get_array_descr_info): Likewise.

gcc/jit/ChangeLog:

	* jit-builtins.cc (find_builtin_by_name): Use ARRAY_SIZE.
	(get_string_for_type_id): Likewise.
	* jit-recording.cc (recording::context::context): Likewise.

gcc/lto/ChangeLog:

	* lto-common.cc (lto_resolution_read): Use ARRAY_SIZE.
	* lto-lang.cc (lto_init): Likewise.
---
 gcc/ada/locales.c   |  6 +++---
 gcc/analyzer/engine.cc  |  2 +-
 gcc/analyzer/function-set.cc|  2 +-
 gcc/analyzer/sm-file.cc |  3 +--
 gcc/analyzer/sm-malloc.cc   |  3 +--
 gcc/analyzer/sm-signal.cc   |  3 +--
 gcc/attribs.cc  |  4 ++--
 gcc/builtins.cc |  2 +-
 gcc/c-family/c-attribs.cc   |  3 +--
 gcc/c-family/c-common.cc|  7 ++-
 gcc/c-family/c-format.cc| 12 ++--
 gcc/c-family/c-pragma.cc|  9 -
 gcc/c-family/known-headers.cc   |  5 ++---
 gcc/c/c-decl

Re: [PATCH] Use more ARRAY_SIZE.

2022-05-05 Thread Iain Buclaw via Gcc-patches
Excerpts from Martin Liška's message of Mai 5, 2022 2:16 pm:
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Ready to be installed?
> Thanks,
> Martin
> 
> gcc/d/ChangeLog:
> 
>   * longdouble.h: Use ARRAY_SIZE.
> 
> diff --git a/gcc/d/longdouble.h b/gcc/d/longdouble.h
> index 1e457ae04d6..2d9695a4309 100644
> --- a/gcc/d/longdouble.h
> +++ b/gcc/d/longdouble.h
> @@ -117,7 +117,7 @@ public:
>  private:
>/* Including gcc/real.h presents too many problems, so just
>   statically allocate enough space for REAL_VALUE_TYPE.  */
> -  long realvalue[(2 + (16 + sizeof (long)) / sizeof (long))];
> +  long realvalue[(2 + (16 + ARRAY_SIZE (long))];
>  };
>  
>  /* Declared, but "volatile" is not required.  */
> 

Hi,

This D front-end change doesn't look right to me, besides the slight
difference in parentheses meaning the calculation would be off by some
measure - (2 + (16 + N) / N) => 7 vs. (2 + 16 + N) => 22 - if I
understand the ARRAY_SIZE macro correctly, it wouldn't even generate
valid code either.

Regards,
Iain.


[PATCH] Use more ARRAY_SIZE.

2022-05-05 Thread Martin Liška
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ada/ChangeLog:

* locales.c (iso_639_1_to_639_3): Use ARRAY_SIZE.
(language_name_to_639_3): Likewise.
(country_name_to_3166): Likewise.

gcc/analyzer/ChangeLog:

* engine.cc (exploded_node::get_dot_fillcolor): Use ARRAY_SIZE.
* function-set.cc (test_stdio_example): Likewise.
* sm-file.cc (get_file_using_fns): Likewise.
* sm-malloc.cc (malloc_state_machine::unaffected_by_call_p): Likewise.
* sm-signal.cc (get_async_signal_unsafe_fns): Likewise.

gcc/ChangeLog:

* attribs.cc (diag_attr_exclusions): Use ARRAY_SIZE.
(decls_mismatched_attributes): Likewise.
* builtins.cc (c_strlen): Likewise.
* cfg.cc (DEF_BASIC_BLOCK_FLAG): Likewise.
* common/config/aarch64/aarch64-common.cc (aarch64_option_init_struct): 
Likewise.
* config/aarch64/aarch64-builtins.cc 
(aarch64_lookup_simd_builtin_type): Likewise.
(aarch64_init_simd_builtin_types): Likewise.
(aarch64_init_builtin_rsqrt): Likewise.
* config/aarch64/aarch64.cc (is_madd_op): Likewise.
* config/arm/arm-builtins.cc (arm_lookup_simd_builtin_type): Likewise.
(arm_init_simd_builtin_types): Likewise.
* config/avr/gen-avr-mmcu-texi.cc (mcus[ARRAY_SIZE): Likewise.
(c_prefix): Likewise.
(main): Likewise.
* config/c6x/c6x.cc (N_SAVE_ORDER): Likewise.
* config/darwin-c.cc (darwin_register_frameworks): Likewise.
* config/gcn/mkoffload.cc (process_obj): Likewise.
* config/i386/i386-builtins.cc (get_builtin_code_for_version): Likewise.
(fold_builtin_cpu): Likewise.
* config/m32c/m32c.cc (PUSHM_N): Likewise.
* config/nvptx/mkoffload.cc (process): Likewise.
* config/rs6000/driver-rs6000.cc (host_detect_local_cpu): Likewise.
* config/rs6000/rs6000.cc (rs6000_hash_constant): Likewise.
* config/s390/s390.cc (NR_C_MODES): Likewise.
* config/tilepro/gen-mul-tables.cc (find_sequences): Likewise.
(create_insn_code_compression_table): Likewise.
* config/vms/vms.cc (NBR_CRTL_NAMES): Likewise.
* diagnostic-format-json.cc (json_from_expanded_location): Likewise.
* dwarf2out.cc (ARRAY_SIZE): Likewise.
* genautomata.cc (output_get_cpu_unit_code_func): Likewise.
* genhooks.cc (emit_documentation): Likewise.
(emit_init_macros): Likewise.
* gimple-ssa-sprintf.cc (format_floating): Likewise.
* gimple-ssa-warn-access.cc (memmodel_name): Likewise.
* godump.cc (keyword_hash_init): Likewise.
* hash-table.cc (hash_table_higher_prime_index): Likewise.
* input.cc (for_each_line_table_case): Likewise.
* ipa-free-lang-data.cc (free_lang_data): Likewise.
* ipa-inline.cc (sanitize_attrs_match_for_inline_p): Likewise.
* optc-save-gen.awk: Likewise.
* spellcheck.cc (test_metric_conditions): Likewise.
* sreal.cc (sreal_verify_arithmetics): Likewise.
(sreal_verify_shifting): Likewise.
* tree-vect-slp-patterns.cc (sizeof): Likewise.
(ARRAY_SIZE): Likewise.
* tree.cc (build_common_tree_nodes): Likewise.

gcc/c-family/ChangeLog:

* c-attribs.cc (handle_access_attribute): Use ARRAY_SIZE.
* c-common.cc (ARRAY_SIZE): Likewise.
(c_common_nodes_and_builtins): Likewise.
* c-format.cc (check_tokens): Likewise.
(check_plain): Likewise.
* c-pragma.cc (c_pp_lookup_pragma): Likewise.
(init_pragma): Likewise.
* c-warn.cc (warn_parm_array_mismatch): Likewise.
* known-headers.cc (get_string_macro_hint): Likewise.
(get_stdlib_header_for_name): Likewise.

gcc/c/ChangeLog:

* c-decl.cc (match_builtin_function_types): Use ARRAY_SIZE.

gcc/cp/ChangeLog:

* module.cc (depset::entity_kind_name): Use ARRAY_SIZE.
* name-lookup.cc (get_std_name_hint): Likewise.
* parser.cc (cp_parser_new): Likewise.

gcc/d/ChangeLog:

* longdouble.h: Use ARRAY_SIZE.

gcc/fortran/ChangeLog:

* frontend-passes.cc (gfc_code_walker): Use ARRAY_SIZE.
* openmp.cc (gfc_match_omp_context_selector_specification): Likewise.
* trans-intrinsic.cc (conv_intrinsic_ieee_builtin): Likewise.
* trans-types.cc (gfc_get_array_descr_info): Likewise.

gcc/jit/ChangeLog:

* jit-builtins.cc (find_builtin_by_name): Use ARRAY_SIZE.
(get_string_for_type_id): Likewise.
* jit-recording.cc (recording::context::context): Likewise.

gcc/lto/ChangeLog:

* lto-common.cc (lto_resolution_read): Use ARRAY_SIZE.
* lto-lang.cc (lto_init): Likewise.
---
 gcc/ada/locales.c   |  6 +++---
 gcc/analyzer/engine.cc  |  2 +-
 gcc/analyzer/function-set.cc|  2 +-
 gcc/analyzer/sm-file.cc |  3 +--