From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id B9E08158089 for ; Fri, 27 Oct 2023 23:43:14 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0159E2BC029; Fri, 27 Oct 2023 23:43:13 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BEC1B2BC029 for ; Fri, 27 Oct 2023 23:43:13 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8BEB3335C0D for ; Fri, 27 Oct 2023 23:43:12 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 00A2712AC for ; Fri, 27 Oct 2023 23:43:10 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1698449982.4e7cf4e3cf83a83932fd23c7dfb6a31903d09dd7.sam@gentoo> Subject: [gentoo-commits] proj/gcc-patches:master commit in: 13.2.0/gentoo/ X-VCS-Repository: proj/gcc-patches X-VCS-Files: 13.2.0/gentoo/90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch 13.2.0/gentoo/README.history X-VCS-Directories: 13.2.0/gentoo/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 4e7cf4e3cf83a83932fd23c7dfb6a31903d09dd7 X-VCS-Branch: master Date: Fri, 27 Oct 2023 23:43:10 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 9f238801-0645-47fd-a681-417779395131 X-Archives-Hash: ed7fd4635f4c6893787a547668b560b6 commit: 4e7cf4e3cf83a83932fd23c7dfb6a31903d09dd7 Author: Sam James gentoo org> AuthorDate: Fri Oct 27 23:39:42 2023 +0000 Commit: Sam James gentoo org> CommitDate: Fri Oct 27 23:39:42 2023 +0000 URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=4e7cf4e3 13.2.0: update 90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch Signed-off-by: Sam James gentoo.org> ...genemit-Split-insn-emit.cc-into-ten-files.patch | 164 ++++++++++++--------- 13.2.0/gentoo/README.history | 4 + 2 files changed, 100 insertions(+), 68 deletions(-) diff --git a/13.2.0/gentoo/90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch b/13.2.0/gentoo/90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch index 19352ac..6a2f3ed 100644 --- a/13.2.0/gentoo/90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch +++ b/13.2.0/gentoo/90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch @@ -1,44 +1,42 @@ https://gcc.gnu.org/PR54179 -https://gcc.gnu.org/PR84402 -https://gcc.gnu.org/PR111600 -https://inbox.sourceware.org/gcc-patches/87il76kgk2.fsf@gentoo.org/T/ +https://inbox.sourceware.org/gcc-patches/de0f7bdc-d236-4f5b-9504-d5bfb215d023@gmail.com/ -From 6b25a6ca295528805d8dedd59e1ed2f1e218a819 Mon Sep 17 00:00:00 2001 +From a71bcc136fee1c5a5ec6639f802daf1b22a1aab6 Mon Sep 17 00:00:00 2001 From: Robin Dapp -Date: Mon, 16 Oct 2023 12:17:07 +0200 -Subject: [PATCH 6/6] genemit: Split insn-emit.cc into ten files. +Date: Fri, 27 Oct 2023 21:04:25 +0200 +Subject: [PATCH] genemit: Split insn-emit.cc into ten files. -Hi, +After working with Sam off-list (thanks) I managed to get hppa to +build. Initially it looked as if hppa just had a very small number of +instruction patterns so we wouldn't generate all 10 output files. +However, the actual issue (which we will only hit with a low +pattern count) was with counting all the patterns vs only counting +the patterns that will be output. A wrong pattern count lead to +prematurely stopping to write output files. -the attached v2 includes Tamar's suggestion of keeping the current -stdout behavior. When no output files are passed (via -O) the output -is written to stdout as before. +With that corrected, hppa "just works" until I hit linker errors +due to relocations - most likely unrelated: -Tamar also mentioned off-list that, similar to match.pd, it might make -sense to balance the partitions in a better way than a fixed number -of patterns threshold. That's a good idea but I'd rather do that -separately as the current approach already helps considerably. +bin/ld: unwind-dw2-fde-dip_s.o(.data.rel.ro+0): cannot handle +R_PARISC_FPTR64 for __pthread_key_create@@GLIBC_2.34 -Attached v2 was bootstrapped and regtested on power10, aarch64 and -x86 are still running. -Stefan also tested v1 on s390 where the partitioning does not help -but also doesn't slow anything down. insn-emit.cc isn't very large -to begin with on s390. +Attached is v3 that has been bootstrapped and tested on x86 and power10, +aarch64 bootstrap was ok, testsuite is still running. A riscv build and +testsuite run was successful as well. Regards Robin ->From 34d05113a4e3c7e83a4731020307e26c1144af69 Mon Sep 17 00:00:00 2001 +>From 248744c328440bff9cc339d2bf622852cbaac343 Mon Sep 17 00:00:00 2001 From: Robin Dapp Date: Thu, 12 Oct 2023 11:23:26 +0200 -Subject: [PATCH v2] genemit: Split insn-emit.cc into several partitions. +Subject: [PATCH v3] genemit: Split insn-emit.cc into several partitions. On riscv insn-emit.cc has grown to over 1.2 mio lines of code and compiling it takes considerable time. Therefore, this patch adjust genemit to create several partitions -(insn-emit-1.cc to insn-emit-n.cc). In order to do so it first counts -the number of available patterns, calculates the number of patterns per -file and starts a new file whenever that number is reached. +(insn-emit-1.cc to insn-emit-n.cc). The available patterns are +written to the given files in a sequential fashion. Similar to match.pd a configure option --with-emitinsn-partitions=num is introduced that makes the number of partition configurable. @@ -74,21 +72,19 @@ gcc/ChangeLog: * gensupport.h (count_patterns): Define. * read-md.cc (md_reader::print_md_ptr_loc): Add file argument. * read-md.h (class md_reader): Change definition. - -(cherry picked from commit 646ee18fef30ade65e5ff2e7445e4915a0f9a3ad) --- - gcc/Makefile.in | 38 +++- - gcc/configure | 22 +- + gcc/Makefile.in | 36 ++- + gcc/configure | 24 +- gcc/configure.ac | 13 ++ - gcc/genemit.cc | 536 +++++++++++++++++++++++++--------------------- - gcc/gensupport.cc | 36 ++++ + gcc/genemit.cc | 542 +++++++++++++++++++++++++--------------------- + gcc/gensupport.cc | 55 +++++ gcc/gensupport.h | 1 + gcc/read-md.cc | 4 +- gcc/read-md.h | 2 +- - 8 files changed, 398 insertions(+), 254 deletions(-) + 8 files changed, 422 insertions(+), 255 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in -index 2c16b14ad0f..9152525ec23 100644 +index 2c16b14ad0f3..b0c118e6d189 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -232,6 +232,13 @@ GIMPLE_MATCH_PD_SEQ_O = $(patsubst %, gimple-match-%.o, $(MATCH_SPLITS_SEQ)) @@ -150,31 +146,29 @@ index 2c16b14ad0f..9152525ec23 100644 insn-extract.cc insn-output.cc \ insn-peep.cc insn-recog.cc -@@ -2490,8 +2498,22 @@ $(simple_generated_c:insn-%.cc=s-%): s-%: build/gen%$(build_exeext) +@@ -2490,8 +2498,20 @@ $(simple_generated_c:insn-%.cc=s-%): s-%: build/gen%$(build_exeext) $(SHELL) $(srcdir)/../move-if-change tmp-$*.cc insn-$*.cc $(STAMP) s-$* +# genemit splits its output into different files and doesn't write to +# stdout. (but rather to tmp-emit-01.cc..tmp-emit-10.cc) -+s-tmp-emit: build/genemit$(build_exeext) insn-conditions.md ++$(INSNEMIT_SEQ_SRC): s-tmp-emit; @true ++s-tmp-emit: build/genemit$(build_exeext) $(MD_DEPS) insn-conditions.md + $(RUN_GEN) build/genemit$(build_exeext) $(md_file) insn-conditions.md \ + $(addprefix -O,${INSNEMIT_SEQ_TMP}) ++ $(foreach id, $(INSNEMIT_SPLITS_SEQ), \ ++ $(SHELL) $(srcdir)/../move-if-change tmp-emit-$(id).cc \ ++ insn-emit-$(id).cc;) + $(STAMP) s-tmp-emit -+ -+$(INSNEMIT_SEQ_SRC): insn-emit-%.cc: s-insn-emit-%; @true -+$(INSNEMIT_SEQ_SRC:insn-emit-%.cc=s-insn-emit-%): s-insn-emit-%: s-tmp-emit -+ $(SHELL) $(srcdir)/../move-if-change tmp-emit-$*.cc insn-emit-$*.cc -+ $(STAMP) s-insn-emit-$* + # gencheck doesn't read the machine description, and the file produced # doesn't use the insn-* convention. + -+# --> s-check has prerequisite tree-check.h (though nothing to do) tree-check.h: s-check ; @true s-check : build/gencheck$(build_exeext) $(RUN_GEN) build/gencheck$(build_exeext) > tmp-check.h diff --git a/gcc/configure b/gcc/configure -index 3750f77fd03..9e8febc17b4 100755 +index 3750f77fd037..056d098618b2 100755 --- a/gcc/configure +++ b/gcc/configure @@ -838,6 +838,7 @@ enable_gcov @@ -230,12 +224,21 @@ index 3750f77fd03..9e8febc17b4 100755 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19848 "configure" -+#line 19946 "configure" ++#line 19995 "configure" + #include "confdefs.h" + + #if HAVE_DLFCN_H +@@ -19951,7 +19971,7 @@ else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +-#line 19954 "configure" ++#line 20101 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac -index 7f8aa5329c7..efbaa0bf6ee 100644 +index 7f8aa5329c7f..efbaa0bf6eeb 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -934,6 +934,19 @@ fi @@ -259,7 +262,7 @@ index 7f8aa5329c7..efbaa0bf6ee 100644 AC_ARG_ENABLE(__cxa_atexit, [AS_HELP_STRING([--enable-__cxa_atexit], [enable __cxa_atexit for C++])], diff --git a/gcc/genemit.cc b/gcc/genemit.cc -index 33c9ec05d6f..aee69872470 100644 +index 33c9ec05d6fc..18c95e3f6412 100644 --- a/gcc/genemit.cc +++ b/gcc/genemit.cc @@ -49,29 +49,29 @@ struct clobber_ent @@ -1136,7 +1139,7 @@ index 33c9ec05d6f..aee69872470 100644 return (FATAL_EXIT_CODE); #define DEF_INTERNAL_OPTAB_FN(NAME, FLAGS, OPTAB, TYPE) \ -@@ -867,86 +924,81 @@ main (int argc, const char **argv) +@@ -867,86 +924,87 @@ main (int argc, const char **argv) /* Assign sequential codes to all entries in the machine description in parallel with the tables in insn-output.cc. */ @@ -1144,6 +1147,13 @@ index 33c9ec05d6f..aee69872470 100644 -from the machine description file `md'. */\n\n"); + int npatterns = count_patterns (); + md_rtx_info info; ++ ++ bool to_stdout = false; ++ int npatterns_per_file = npatterns; ++ if (!output_files.is_empty ()) ++ npatterns_per_file = npatterns / output_files.length () + 1; ++ else ++ to_stdout = true; - printf ("#define IN_TARGET_CODE 1\n"); - printf ("#include \"config.h\"\n"); @@ -1180,17 +1190,13 @@ index 33c9ec05d6f..aee69872470 100644 - printf ("#include \"tm-constrs.h\"\n"); - printf ("#include \"ggc.h\"\n"); - printf ("#include \"target.h\"\n\n"); -+ int npatterns_per_file = npatterns; -+ if (!output_files.is_empty ()) -+ npatterns_per_file = npatterns / output_files.length () + 1; - -- /* Read the machine description. */ + gcc_assert (npatterns_per_file > 1); -- md_rtx_info info; +- /* Read the machine description. */ + /* Reverse so we can pop the first-added element. */ + output_files.reverse (); -+ + +- md_rtx_info info; + int count = 0; + FILE *file = NULL; + @@ -1204,7 +1210,8 @@ index 33c9ec05d6f..aee69872470 100644 + { + if (count == 0 || count == npatterns_per_file) + { -+ if (file) ++ bool is_last = !to_stdout && output_files.is_empty (); ++ if (file && !is_last) + if (fclose (file) != 0) + return FATAL_EXIT_CODE; @@ -1217,8 +1224,10 @@ index 33c9ec05d6f..aee69872470 100644 + const char *const filename = output_files.pop (); + file = fopen (filename, "w"); + } -+ else ++ else if (to_stdout) + file = stdout; ++ else ++ break; - case DEFINE_SPLIT: - printf ("/* %s:%d */\n", info.loc.filename, info.loc.lineno); @@ -1284,10 +1293,10 @@ index 33c9ec05d6f..aee69872470 100644 + return (fclose (file) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE); } diff --git a/gcc/gensupport.cc b/gcc/gensupport.cc -index f9efc6eb757..8ea48ef755d 100644 +index f9efc6eb7572..f941f76a739f 100644 --- a/gcc/gensupport.cc +++ b/gcc/gensupport.cc -@@ -2631,6 +2631,42 @@ init_rtx_reader_args (int argc, const char **argv) +@@ -2631,6 +2631,61 @@ init_rtx_reader_args (int argc, const char **argv) return init_rtx_reader_args_cb (argc, argv, 0); } @@ -1295,32 +1304,51 @@ index f9efc6eb757..8ea48ef755d 100644 +int +count_patterns () +{ -+ int count = 0; ++ int count = 0, truth = 1; ++ rtx def; + class queue_elem *cur = define_attr_queue; -+ while (cur != NULL) ++ while (cur) + { -+ count++; ++ def = cur->data; ++ ++ truth = maybe_eval_c_test (get_c_test (def)); ++ if (truth || !insn_elision) ++ count++; + cur = cur->next; + } + + cur = define_pred_queue; -+ while (cur != NULL) ++ while (cur) + { -+ count++; ++ def = cur->data; ++ ++ truth = maybe_eval_c_test (get_c_test (def)); ++ if (truth || !insn_elision) ++ count++; + cur = cur->next; + } + + cur = define_insn_queue; -+ while (cur != NULL) ++ truth = 1; ++ while (cur) + { -+ count++; ++ def = cur->data; ++ ++ truth = maybe_eval_c_test (get_c_test (def)); ++ if (truth || !insn_elision) ++ count++; + cur = cur->next; + } + + cur = other_queue; -+ while (cur != NULL) ++ truth = 1; ++ while (cur) + { -+ count++; ++ def = cur->data; ++ ++ truth = maybe_eval_c_test (get_c_test (def)); ++ if (truth || !insn_elision) ++ count++; + cur = cur->next; + } + @@ -1331,7 +1359,7 @@ index f9efc6eb757..8ea48ef755d 100644 describing it in *INFO. */ diff --git a/gcc/gensupport.h b/gcc/gensupport.h -index a1edfbd7190..510ba19405e 100644 +index a1edfbd71908..510ba19405e4 100644 --- a/gcc/gensupport.h +++ b/gcc/gensupport.h @@ -129,6 +129,7 @@ extern rtx add_implicit_parallel (rtvec); @@ -1343,7 +1371,7 @@ index a1edfbd7190..510ba19405e 100644 extern unsigned int get_num_insn_codes (); diff --git a/gcc/read-md.cc b/gcc/read-md.cc -index fd38818e3a3..46ab9065e3e 100644 +index fd38818e3a3e..46ab9065e3e4 100644 --- a/gcc/read-md.cc +++ b/gcc/read-md.cc @@ -132,9 +132,9 @@ md_reader::fprint_md_ptr_loc (FILE *outf, const void *ptr) @@ -1359,7 +1387,7 @@ index fd38818e3a3..46ab9065e3e 100644 /* Return a condition that satisfies both COND1 and COND2. Either string diff --git a/gcc/read-md.h b/gcc/read-md.h -index b309c9c3deb..2adcb58478f 100644 +index b309c9c3deb6..2adcb58478fe 100644 --- a/gcc/read-md.h +++ b/gcc/read-md.h @@ -194,7 +194,7 @@ class md_reader diff --git a/13.2.0/gentoo/README.history b/13.2.0/gentoo/README.history index d58550f..4b18bf0 100644 --- a/13.2.0/gentoo/README.history +++ b/13.2.0/gentoo/README.history @@ -1,3 +1,7 @@ +10 28 Oct 2023 + + U 90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch + 9 16 Oct 2023 + 86_all_build-Replace-seq-for-portability-with-GNU-Make-vari.patch