[PATCH Committed] Fix ICE due to REGNO of a SUBREG.
Use reg_or_subregno instead. Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Committed as an obvious patch. gcc/ChangeLog: PR target/115452 * config/i386/i386-features.cc (scalar_chain::convert_op): Use reg_or_subregno instead of REGNO to avoid ICE. gcc/testsuite/ChangeLog: * gcc.target/i386/pr115452.c: New test. --- gcc/config/i386/i386-features.cc | 2 +- gcc/testsuite/gcc.target/i386/pr115452.c | 4 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr115452.c diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc index e3e004d5526..607d1991460 100644 --- a/gcc/config/i386/i386-features.cc +++ b/gcc/config/i386/i386-features.cc @@ -1054,7 +1054,7 @@ scalar_chain::convert_op (rtx *op, rtx_insn *insn) if (dump_file) fprintf (dump_file, " Preloading operand for insn %d into r%d\n", -INSN_UID (insn), REGNO (tmp)); +INSN_UID (insn), reg_or_subregno (tmp)); } else if (REG_P (*op)) *op = gen_rtx_SUBREG (vmode, *op, 0); diff --git a/gcc/testsuite/gcc.target/i386/pr115452.c b/gcc/testsuite/gcc.target/i386/pr115452.c new file mode 100644 index 000..6c7935feb9f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr115452.c @@ -0,0 +1,4 @@ +/* { dg-do compile { target ia32 } } */ +/* { dg-options "-O2 -msse2 -mstv -mno-bmi -mno-stackrealign -fdump-rtl-stv2" } */ + +#include "pr70322-2.c" -- 2.31.1
[PATCH committed] Add additional option --param max-completely-peeled-insns=200 for power64*-*-*
gcc/testsuite/ChangeLog: * gcc.dg/vect/pr112325.c:Add additional option --param max-completely-peeled-insns=200 for power64*-*-*. --- gcc/testsuite/gcc.dg/vect/pr112325.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/testsuite/gcc.dg/vect/pr112325.c b/gcc/testsuite/gcc.dg/vect/pr112325.c index dea6cca3b86..143903beab2 100644 --- a/gcc/testsuite/gcc.dg/vect/pr112325.c +++ b/gcc/testsuite/gcc.dg/vect/pr112325.c @@ -3,6 +3,7 @@ /* { dg-require-effective-target vect_int } */ /* { dg-require-effective-target vect_shift } */ /* { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } } */ +/* { dg-additional-options "--param max-completely-peeled-insns=200" { target powerpc64*-*-* } } */ typedef unsigned short ggml_fp16_t; static float table_f32_f16[1 << 16]; -- 2.31.1
[PATCH Committed] Refine testcase for power10.
For power10, there're extra 3 REG_EQUIV notes with (fix:SI. to avoid the failure. Check (fix:SI is from the pattern not NOTE. gcc/testsuite/ChangeLog: PR target/115365 * gcc.dg/pr100927.c: Don't scan fix:SI from the note. --- gcc/testsuite/gcc.dg/pr100927.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/pr100927.c b/gcc/testsuite/gcc.dg/pr100927.c index ea0e627befa..8a7d69c3831 100644 --- a/gcc/testsuite/gcc.dg/pr100927.c +++ b/gcc/testsuite/gcc.dg/pr100927.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* { dg-options "-O2 -ftrapping-math -fdump-tree-optimized -fdump-rtl-final" } */ /* { dg-final { scan-tree-dump-times {(?n)= \(int\)} 3 "optimized" } } */ -/* { dg-final { scan-rtl-dump-times {(?n)\(fix:SI} 3 "final" } } */ +/* { dg-final { scan-rtl-dump-times {(?n)^[ \t]*\(fix:SI} 3 "final" } } */ int foo_ofr () -- 2.31.1
[PATCH][committed] [avx512] Fix predicate mismatch between vfcmaddcph's define_insn and define_expand.
When I applied Roger's patch [1], there's ICE due to it. The patch fix the latent bug. [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651365.html Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Pushed to trunk. gcc/ChangeLog: * config/i386/sse.md (___mask): Align operands' predicate with corresponding expander. (__): Ditto. --- gcc/config/i386/sse.md | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index b59c988fc31..0f4fbcb2c5d 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -6867,9 +6867,9 @@ (define_insn "___mask" [(set (match_operand:VHF_AVX512VL 0 "register_operand" "=") (vec_merge:VHF_AVX512VL (unspec:VHF_AVX512VL - [(match_operand:VHF_AVX512VL 1 "nonimmediate_operand" "v") -(match_operand:VHF_AVX512VL 2 "nonimmediate_operand" "") -(match_operand:VHF_AVX512VL 3 "register_operand" "0")] + [(match_operand:VHF_AVX512VL 1 "" "v") +(match_operand:VHF_AVX512VL 2 "" "") +(match_operand:VHF_AVX512VL 3 "" "0")] UNSPEC_COMPLEX_F_C_MA) (match_dup 1) (unspec: @@ -6892,8 +6892,8 @@ (define_expand "cmul3" (define_insn "__" [(set (match_operand:VHF_AVX512VL 0 "register_operand" "=") (unspec:VHF_AVX512VL - [(match_operand:VHF_AVX512VL 1 "nonimmediate_operand" "v") -(match_operand:VHF_AVX512VL 2 "nonimmediate_operand" "")] + [(match_operand:VHF_AVX512VL 1 "" "v") +(match_operand:VHF_AVX512VL 2 "" "")] UNSPEC_COMPLEX_F_C_MUL))] "TARGET_AVX512FP16 && " { -- 2.31.1
[PATCH, committed] Fortran: fix frontend memleak
Dear all, the attached obvious patch fixes a frontend memleak that was introduced recently, and which shows up when checking for inquiry references. I came across it when working on pr115039. Committed after regtesting as r15-391-g13b6ac4ebd04f0. Thanks, Harald From 13b6ac4ebd04f0703d92828c9268b0b216890b0d Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sun, 12 May 2024 21:48:03 +0200 Subject: [PATCH] Fortran: fix frontend memleak gcc/fortran/ChangeLog: * primary.cc (gfc_match_varspec): Replace 'ref' argument to is_inquiry_ref() by NULL when the result is not needed to avoid a memleak. --- gcc/fortran/primary.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc index 606e84432be..8e7833769a8 100644 --- a/gcc/fortran/primary.cc +++ b/gcc/fortran/primary.cc @@ -2250,7 +2250,7 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, can be found. If this was an inquiry reference with the same name as a derived component and the associate-name type is not derived or class, this is fixed up in 'gfc_fixup_inferred_type_refs'. */ - if (mm == MATCH_YES && is_inquiry_ref (name, ) + if (mm == MATCH_YES && is_inquiry_ref (name, NULL) && !(sym->ts.type == BT_UNKNOWN && gfc_find_derived_types (sym, gfc_current_ns, name))) inquiry = true; -- 2.35.3
libgo patch committed: Use in runtime/runtime.h
This libgo patch changes runtime/runtime.h to use the C99 header file rather than defining a bool type and true/false constants itself. C99 was a long time ago and in case this file is always compiled by the newly built GCC. This should fix GCC PR 114875. Bootstrapped on x86_64-pc-linux-gnu. Committed to mainline. Ian ef246d48fd487805f1c4181c7482545c54a4d4a9 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 50d430d5034..8a2810d5b2d 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -98e92493db2ab7857a5934a950a830fc1f95a4e5 +1f0c8364cd35026a647aa4e66ee4d8563c8a5d27 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h index 699770d53ad..da31e11bb77 100644 --- a/libgo/runtime/runtime.h +++ b/libgo/runtime/runtime.h @@ -7,6 +7,7 @@ #include "go-assert.h" #include #include +#include #include #include #include @@ -51,7 +52,6 @@ typedef uintptr uintreg; /* Defined types. */ -typedef_Bool bool; typedefuint8 byte; typedefstruct g G; typedefstruct mutex Lock; @@ -114,11 +114,6 @@ extern M* runtime_m(void); extern G* runtime_g(void) __asm__(GOSYM_PREFIX "runtime.getg"); -enum -{ - true= 1, - false = 0, -}; enum { PtrSize = sizeof(void*),
[PATCH][committed] aarch64: Fix whitespace in aarch64-ldp-fusion.cc:alias_walker
I spotted this whitespace error during the review of https://gcc.gnu.org/pipermail/gcc-patches/2024-April/648846.html. Pushing as obvious after testing on aarch64-linux-gnu. Thanks, Alex gcc/ChangeLog: * config/aarch64/aarch64-ldp-fusion.cc (struct alias_walker): Fix double space after const qualifier on valid (). diff --git a/gcc/config/aarch64/aarch64-ldp-fusion.cc b/gcc/config/aarch64/aarch64-ldp-fusion.cc index 22ed95eb743..365dcf48b22 100644 --- a/gcc/config/aarch64/aarch64-ldp-fusion.cc +++ b/gcc/config/aarch64/aarch64-ldp-fusion.cc @@ -2138,7 +2138,7 @@ struct alias_walker { virtual bool conflict_p (int ) const = 0; virtual insn_info *insn () const = 0; - virtual bool valid () const = 0; + virtual bool valid () const = 0; virtual void advance () = 0; };
Go patch committed: Use correct check for index value overflow
This patch to the Go frontend uses the correct size and comparison when doing an index value overflow check. This has apparently been wrong since I introduced the code ten years ago. This fixes GCC PR 114500. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 1091113a0036c7315197e09af572dce2beaf1c4c diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index de6e21fb3b5..50d430d5034 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -3f597287b6b858794dabdfe1bf83b386aad18102 +98e92493db2ab7857a5934a950a830fc1f95a4e5 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 8429e553eac..238d5a56ca2 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -18790,7 +18790,7 @@ Composite_literal_expression::lower_array(Type* type) Named_type* ntype = Type::lookup_integer_type("int"); Integer_type* inttype = ntype->integer_type(); - if (sizeof(index) <= static_cast(inttype->bits() * 8) + if (sizeof(index) >= static_cast(inttype->bits() / 8) && index >> (inttype->bits() - 1) != 0) { go_error_at(index_expr->location(), "index value overflow");
Go patch committed: Update issue16016 test
This patch to the Go testsuite updates issue16016.go. This backports https://go.dev/cl/574536 into the GCC testsuite. This fixes PR go/114453. Bootstrapped and ran test. Committed to mainline. Ian 5b6f599670994bef957bd15c683102468a7104f1 diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16016.go b/gcc/testsuite/go.test/test/fixedbugs/issue16016.go index e738e1dba0e..b1947f5548d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue16016.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16016.go @@ -6,7 +6,10 @@ package main -import "time" +import ( + "runtime" + "time" +) type T struct{} @@ -24,8 +27,19 @@ type Q interface { } func main() { + var count = 1 + if runtime.Compiler == "gccgo" { + // On targets without split-stack libgo allocates + // a large stack for each goroutine. On 32-bit + // systems this test can run out of memory. + const intSize = 32 << (^uint(0) >> 63) // 32 or 64 + if intSize < 64 { + count = 100 + } + } + var q Q = {{}} - for i := 0; i < 1; i++ { + for i := 0; i < count; i++ { go func() { defer q.Foo([]interface{}{"meow"}) time.Sleep(100 * time.Millisecond)
Go patch committed: initialize local variable in lower_method_expression
This patch to the Go frontend fixes an uninitialized variables in lower_method_expression. This fixes GCC PR 114463. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 7b2a24f3964509bd5b74c4579c7ea5684e82aee1 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 73cb095322c..de6e21fb3b5 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -e15a14e410b8fc5d28012d5b313cb6c8476c7df9 +3f597287b6b858794dabdfe1bf83b386aad18102 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 51ff0206129..8429e553eac 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -9059,7 +9059,7 @@ Selector_expression::lower_method_expression(Gogo* gogo) Named_type* nt = type->named_type(); Struct_type* st = type->struct_type(); - bool is_ambiguous; + bool is_ambiguous = false; Method* method = NULL; if (nt != NULL) method = nt->method_function(name, _ambiguous);
[PATCH, committed] Fortran: error recovery in frontend optimization [PR103715]
Dear all, I've committed the attached simple & obvious patch for an ICE due to an invalid read in frontend optimization after regtesting and an OK by Jerry in the PR. Pushed: https://gcc.gnu.org/g:3be2b8f475f22c531d6cef1b041c0573b3ea5133 As this PR is marked as a regression, I plan to backport to open branches. Thanks, Harald From 3be2b8f475f22c531d6cef1b041c0573b3ea5133 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 18 Mar 2024 19:36:59 +0100 Subject: [PATCH] Fortran: error recovery in frontend optimization [PR103715] gcc/fortran/ChangeLog: PR fortran/103715 * frontend-passes.cc (check_externals_expr): Prevent invalid read in case of mismatch of external subroutine with function. gcc/testsuite/ChangeLog: PR fortran/103715 * gfortran.dg/pr103715.f90: New test. --- gcc/fortran/frontend-passes.cc | 3 +++ gcc/testsuite/gfortran.dg/pr103715.f90 | 12 2 files changed, 15 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr103715.f90 diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc index 06dfa1a3232..3c06018fdbb 100644 --- a/gcc/fortran/frontend-passes.cc +++ b/gcc/fortran/frontend-passes.cc @@ -5807,6 +5807,9 @@ check_externals_expr (gfc_expr **ep, int *walk_subtrees ATTRIBUTE_UNUSED, if (e->expr_type != EXPR_FUNCTION) return 0; + if (e->symtree && e->symtree->n.sym->attr.subroutine) +return 0; + sym = e->value.function.esym; if (sym == NULL) return 0; diff --git a/gcc/testsuite/gfortran.dg/pr103715.f90 b/gcc/testsuite/gfortran.dg/pr103715.f90 new file mode 100644 index 000..72c5a31fb21 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr103715.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! PR fortran/103715 - ICE in gfc_find_gsymbol +! +! valgrind did report an invalid read in check_externals_procedure + +program p + select type (y => g()) ! { dg-error "Selector shall be polymorphic" } + end select + call g() +end + +! { dg-prune-output "already being used as a FUNCTION" } -- 2.35.3
Summary: [PATCH][committed]AArch64: Do not allow SIMD clones with simdlen 1 [PR113552][GCC 13/12/11 backport]
Hi All, This is a backport of g:306713c953d509720dc394c43c0890548bb0ae07. The AArch64 vector PCS does not allow simd calls with simdlen 1, however due to a bug we currently do allow it for num == 0. This causes us to emit a symbol that doesn't exist and we fail to link. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Committed to GCC 13,12,11 branches as previously approved. Thanks, Tamar gcc/ChangeLog: PR tree-optimization/113552 * config/aarch64/aarch64.cc (aarch64_simd_clone_compute_vecsize_and_simdlen): Block simdlen 1. gcc/testsuite/ChangeLog: PR tree-optimization/113552 * gcc.target/aarch64/pr113552.c: New test. * gcc.target/aarch64/simd_pcs_attribute-3.c: Remove bogus check. --- diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index f546c48ae2d2bad2e34c6b72e5e3e30aba3c3bd6..d19a9c16cc97ae75afd4e29f4339d65d39cfb73a 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -27027,7 +27027,7 @@ aarch64_simd_clone_compute_vecsize_and_simdlen (struct cgraph_node *node, bool explicit_p) { tree t, ret_type; - unsigned int elt_bits, count; + unsigned int elt_bits, count = 0; unsigned HOST_WIDE_INT const_simdlen; poly_uint64 vec_bits; @@ -27104,7 +27104,7 @@ aarch64_simd_clone_compute_vecsize_and_simdlen (struct cgraph_node *node, vec_bits = (num == 0 ? 64 : 128); clonei->simdlen = exact_div (vec_bits, elt_bits); } - else + else if (maybe_ne (clonei->simdlen, 1U)) { count = 1; vec_bits = clonei->simdlen * elt_bits; diff --git a/gcc/testsuite/gcc.target/aarch64/pr113552.c b/gcc/testsuite/gcc.target/aarch64/pr113552.c new file mode 100644 index ..9c96b061ed2b4fcc57e58925277f74d14f79c51f --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr113552.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -march=armv8-a" } */ + +__attribute__ ((__simd__ ("notinbranch"), const)) +double cos (double); + +void foo (float *a, double *b) +{ +for (int i = 0; i < 12; i+=3) + { +b[i] = cos (5.0 * a[i]); +b[i+1] = cos (5.0 * a[i+1]); +b[i+2] = cos (5.0 * a[i+2]); + } +} + +/* { dg-final { scan-assembler-times {bl\t_ZGVnN2v_cos} 6 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c index 95f6a6803e889c02177ef10972962ed62d2095eb..c6dac6b104c94c9de89ed88dc5a73e185d2be125 100644 --- a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c +++ b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c @@ -18,7 +18,7 @@ double foo(double x) } /* { dg-final { scan-assembler-not {\.variant_pcs\tfoo} } } */ -/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnM1v_foo} 1 } } */ +/* { dg-final { scan-assembler-not {\.variant_pcs\t_ZGVnM1v_foo} } } */ /* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnM2v_foo} 1 } } */ -/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnN1v_foo} 1 } } */ +/* { dg-final { scan-assembler-not {\.variant_pcs\t_ZGVnN1v_foo} } } */ /* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnN2v_foo} 1 } } */ -- diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index f546c48ae2d2bad2e34c6b72e5e3e30aba3c3bd6..d19a9c16cc97ae75afd4e29f4339d65d39cfb73a 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -27027,7 +27027,7 @@ aarch64_simd_clone_compute_vecsize_and_simdlen (struct cgraph_node *node, bool explicit_p) { tree t, ret_type; - unsigned int elt_bits, count; + unsigned int elt_bits, count = 0; unsigned HOST_WIDE_INT const_simdlen; poly_uint64 vec_bits; @@ -27104,7 +27104,7 @@ aarch64_simd_clone_compute_vecsize_and_simdlen (struct cgraph_node *node, vec_bits = (num == 0 ? 64 : 128); clonei->simdlen = exact_div (vec_bits, elt_bits); } - else + else if (maybe_ne (clonei->simdlen, 1U)) { count = 1; vec_bits = clonei->simdlen * elt_bits; diff --git a/gcc/testsuite/gcc.target/aarch64/pr113552.c b/gcc/testsuite/gcc.target/aarch64/pr113552.c new file mode 100644 index ..9c96b061ed2b4fcc57e58925277f74d14f79c51f --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr113552.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -march=armv8-a" } */ + +__attribute__ ((__simd__ ("notinbranch"), const)) +double cos (double); + +void foo (float *a, double *b) +{ +for (int i = 0; i < 12; i+=3) + { +b[i] = cos (5.0 * a[i]); +b[i+1] = cos (5.0 * a[i+1]); +b[i+2] = cos (5.0 * a[i+2]); + } +} + +/* { dg-final { scan-assembler-times {bl\t_ZGVnN2v_cos} 6 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c index
Re: libbacktrace patch committed: Don't assume compressed section aligned
On Fri, Mar 8, 2024 at 2:48 PM Fangrui Song wrote: > > On ELF64, it looks like BFD uses 8-byte alignment for compressed > `.debug_*` sections while gold/lld/mold use 1-byte alignment. I do not > know how the Solaris linker sets the alignment. > > The specification's wording makes me confused whether it really > requires 8-byte alignment, even if a non-packed `Elf64_Chdr` surely > requires 8. Since compressed sections begin with a compression header structure that identifies the compression algorithm, compressed sections must be aligned to the alignment of the compression header. I don't think there is any ambiguity here. > > The sh_size and sh_addralign fields of the section header for a compressed > > section reflect the requirements of the compressed section. > > There are many `.debug_*` sections. So avoiding some alignment padding > seems a very natural extension (a DWARF v5 -gsplit-dwarf relocatable > file has ~10 `.debug_*` sections), even if the specification doesn't > allow it with a very strict interpretation... > > (Off-topic: I wonder whether ELF control structures should use > unaligned LEB128 more. REL/RELA can naturally be replaced with a > LEB128 one similar to wasm.) > > On Fri, Mar 8, 2024 at 1:57 PM Ian Lance Taylor wrote: > > > > Reportedly when lld compresses debug sections, it fails to set the > > alignment of the compressed section such that the compressed header > > can be read directly. To me this seems like a bug in lld. However, > > libbacktrace needs to work around it. This patch, originally by the > > GitHub user ubyte, does that. Bootstrapped and tested on > > x86_64-pc-linux-gnu. Committed to mainline. > > > > Ian > > > > * elf.c (elf_uncompress_chdr): Don't assume compressed section is > > aligned. > > > > -- > 宋方睿 -- H.J.
Re: libbacktrace patch committed: Don't assume compressed section aligned
On ELF64, it looks like BFD uses 8-byte alignment for compressed `.debug_*` sections while gold/lld/mold use 1-byte alignment. I do not know how the Solaris linker sets the alignment. The specification's wording makes me confused whether it really requires 8-byte alignment, even if a non-packed `Elf64_Chdr` surely requires 8. > The sh_size and sh_addralign fields of the section header for a compressed > section reflect the requirements of the compressed section. There are many `.debug_*` sections. So avoiding some alignment padding seems a very natural extension (a DWARF v5 -gsplit-dwarf relocatable file has ~10 `.debug_*` sections), even if the specification doesn't allow it with a very strict interpretation... (Off-topic: I wonder whether ELF control structures should use unaligned LEB128 more. REL/RELA can naturally be replaced with a LEB128 one similar to wasm.) On Fri, Mar 8, 2024 at 1:57 PM Ian Lance Taylor wrote: > > Reportedly when lld compresses debug sections, it fails to set the > alignment of the compressed section such that the compressed header > can be read directly. To me this seems like a bug in lld. However, > libbacktrace needs to work around it. This patch, originally by the > GitHub user ubyte, does that. Bootstrapped and tested on > x86_64-pc-linux-gnu. Committed to mainline. > > Ian > > * elf.c (elf_uncompress_chdr): Don't assume compressed section is > aligned. -- 宋方睿
libbacktrace patch committed: Don't assume compressed section aligned
Reportedly when lld compresses debug sections, it fails to set the alignment of the compressed section such that the compressed header can be read directly. To me this seems like a bug in lld. However, libbacktrace needs to work around it. This patch, originally by the GitHub user ubyte, does that. Bootstrapped and tested on x86_64-pc-linux-gnu. Committed to mainline. Ian * elf.c (elf_uncompress_chdr): Don't assume compressed section is aligned. 5825bd0e0d0040126e78269e56c9b9f533e2a520 diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index 7841c86cd9c..3cd87020b03 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -5076,7 +5076,7 @@ elf_uncompress_chdr (struct backtrace_state *state, backtrace_error_callback error_callback, void *data, unsigned char **uncompressed, size_t *uncompressed_size) { - const b_elf_chdr *chdr; + b_elf_chdr chdr; char *alc; size_t alc_len; unsigned char *po; @@ -5088,27 +5088,30 @@ elf_uncompress_chdr (struct backtrace_state *state, if (compressed_size < sizeof (b_elf_chdr)) return 1; - chdr = (const b_elf_chdr *) compressed; + /* The lld linker can misalign a compressed section, so we can't safely read + the fields directly as we can for other ELF sections. See + https://github.com/ianlancetaylor/libbacktrace/pull/120. */ + memcpy (, compressed, sizeof (b_elf_chdr)); alc = NULL; alc_len = 0; - if (*uncompressed != NULL && *uncompressed_size >= chdr->ch_size) + if (*uncompressed != NULL && *uncompressed_size >= chdr.ch_size) po = *uncompressed; else { - alc_len = chdr->ch_size; + alc_len = chdr.ch_size; alc = backtrace_alloc (state, alc_len, error_callback, data); if (alc == NULL) return 0; po = (unsigned char *) alc; } - switch (chdr->ch_type) + switch (chdr.ch_type) { case ELFCOMPRESS_ZLIB: if (!elf_zlib_inflate_and_verify (compressed + sizeof (b_elf_chdr), compressed_size - sizeof (b_elf_chdr), - zdebug_table, po, chdr->ch_size)) + zdebug_table, po, chdr.ch_size)) goto skip; break; @@ -5116,7 +5119,7 @@ elf_uncompress_chdr (struct backtrace_state *state, if (!elf_zstd_decompress (compressed + sizeof (b_elf_chdr), compressed_size - sizeof (b_elf_chdr), (unsigned char *)zdebug_table, po, - chdr->ch_size)) + chdr.ch_size)) goto skip; break; @@ -5126,7 +5129,7 @@ elf_uncompress_chdr (struct backtrace_state *state, } *uncompressed = po; - *uncompressed_size = chdr->ch_size; + *uncompressed_size = chdr.ch_size; return 1; @@ -6876,8 +6879,8 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, } } - // A debuginfo file may not have a useful .opd section, but we can use the - // one from the original executable. + /* A debuginfo file may not have a useful .opd section, but we can use the + one from the original executable. */ if (opd == NULL) opd = caller_opd;
libbacktrace patch committed: Link test programs with -no-install
Some of the libbacktrace tests link a program and then modify the debug info in some way. When configured with --enable-shared the linking, using libtool, generates a shell script. That causes the tests to fail because they can't modify the debug info of a shell script. This patch, originally by Jan Tojnar, pass the -no-install flag to libtool to avoid generating a shell script. Bootstrapped and ran libbacktrace tests on x86_64-pc-linux-gnu. Committed to mainline. Ian * Makefile.am (libbacktrace_testing_ldflags): Define. (*_LDFLAGS): Add $(libbacktrace_testing_ldflags) for test programs. * Makefile.in: Regenerate 9b0d218544cd1b12bf63792c70052d2970acc69b diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am index 750ed80ed05..5677ecd8865 100644 --- a/libbacktrace/Makefile.am +++ b/libbacktrace/Makefile.am @@ -106,6 +106,10 @@ check_DATA = # Flags to use when compiling test programs. libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g +# Flags to use when linking test programs. +# This avoids generating a shell script when configured with --enable-shared. +libbacktrace_testing_ldflags = -no-install + if USE_DSYMUTIL %.dSYM: % @@ -170,54 +174,63 @@ xcoff_%.c: xcoff.c test_elf_32_SOURCES = test_format.c testlib.c test_elf_32_CFLAGS = $(libbacktrace_TEST_CFLAGS) +test_elf_32_LDFLAGS = $(libbacktrace_testing_ldflags) test_elf_32_LDADD = libbacktrace_noformat.la elf_32.lo BUILDTESTS += test_elf_32 test_elf_64_SOURCES = test_format.c testlib.c test_elf_64_CFLAGS = $(libbacktrace_TEST_CFLAGS) +test_elf_64_LDFLAGS = $(libbacktrace_testing_ldflags) test_elf_64_LDADD = libbacktrace_noformat.la elf_64.lo BUILDTESTS += test_elf_64 test_macho_SOURCES = test_format.c testlib.c test_macho_CFLAGS = $(libbacktrace_TEST_CFLAGS) +test_macho_LDFLAGS = $(libbacktrace_testing_ldflags) test_macho_LDADD = libbacktrace_noformat.la macho.lo BUILDTESTS += test_macho test_xcoff_32_SOURCES = test_format.c testlib.c test_xcoff_32_CFLAGS = $(libbacktrace_TEST_CFLAGS) +test_xcoff_32_LDFLAGS = $(libbacktrace_testing_ldflags) test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo BUILDTESTS += test_xcoff_32 test_xcoff_64_SOURCES = test_format.c testlib.c test_xcoff_64_CFLAGS = $(libbacktrace_TEST_CFLAGS) +test_xcoff_64_LDFLAGS = $(libbacktrace_testing_ldflags) test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo BUILDTESTS += test_xcoff_64 test_pecoff_SOURCES = test_format.c testlib.c test_pecoff_CFLAGS = $(libbacktrace_TEST_CFLAGS) +test_pecoff_LDFLAGS = $(libbacktrace_testing_ldflags) test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo BUILDTESTS += test_pecoff test_unknown_SOURCES = test_format.c testlib.c test_unknown_CFLAGS = $(libbacktrace_TEST_CFLAGS) +test_unknown_LDFLAGS = $(libbacktrace_testing_ldflags) test_unknown_LDADD = libbacktrace_noformat.la unknown.lo BUILDTESTS += test_unknown unittest_SOURCES = unittest.c testlib.c unittest_CFLAGS = $(libbacktrace_TEST_CFLAGS) +unittest_LDFLAGS = $(libbacktrace_testing_ldflags) unittest_LDADD = libbacktrace.la BUILDTESTS += unittest unittest_alloc_SOURCES = $(unittest_SOURCES) unittest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS) +unittest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags) unittest_alloc_LDADD = libbacktrace_alloc.la BUILDTESTS += unittest_alloc @@ -253,7 +266,7 @@ if HAVE_OBJCOPY_DEBUGLINK b2test_SOURCES = $(btest_SOURCES) b2test_CFLAGS = $(libbacktrace_TEST_CFLAGS) -b2test_LDFLAGS = -Wl,--build-id +b2test_LDFLAGS = -Wl,--build-id $(libbacktrace_testing_ldflags) b2test_LDADD = libbacktrace_elf_for_test.la check_PROGRAMS += b2test @@ -263,7 +276,7 @@ if HAVE_DWZ b3test_SOURCES = $(btest_SOURCES) b3test_CFLAGS = $(libbacktrace_TEST_CFLAGS) -b3test_LDFLAGS = -Wl,--build-id +b3test_LDFLAGS = -Wl,--build-id $(libbacktrace_testing_ldflags) b3test_LDADD = libbacktrace_elf_for_test.la check_PROGRAMS += b3test @@ -277,6 +290,7 @@ endif HAVE_ELF btest_SOURCES = btest.c testlib.c btest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O +btest_LDFLAGS = $(libbacktrace_testing_ldflags) btest_LDADD = libbacktrace.la BUILDTESTS += btest @@ -289,6 +303,7 @@ if HAVE_ELF btest_lto_SOURCES = btest.c testlib.c btest_lto_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O -flto +btest_lto_LDFLAGS = $(libbacktrace_testing_ldflags) btest_lto_LDADD = libbacktrace.la BUILDTESTS += btest_lto @@ -297,6 +312,7 @@ endif HAVE_ELF btest_alloc_SOURCES = $(btest_SOURCES) btest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS) +btest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags) btest_alloc_LDADD = libbacktrace_alloc.la BUILDTESTS += btest_alloc @@ -331,6 +347,7 @@ endif HAVE_DWZ stest_SOURCES = stest.c stest_CFLAGS = $(libbacktrace_TEST_CFLAGS) +stest_LDFLAGS = $(libbacktrace_testing_ldflags) stest_LDADD = libbacktrace.la BUILDTESTS += stest @@ -341,6 +358,7 @@ endif USE_DSYMUTIL stest_alloc_SOURCES = $(stest_SOURCES) stest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
libbacktrace patch committed: Skip all LZMA block header padding bytes
This patch to libbacktrace corrects the LZMA block header parsing to skip all the padding bytes, verifying that they are zero. This fixes https://github.com/ianlancetaylor/libbacktrace/issues/118. Bootstrapped and ran libbacktrace tests on x86_64-pc-linux-gnu. I was able to verify that the problem occurred when setting the environment variable XZ_OPT="--threads=2", and that this patch fixes the bug. Committed to mainline. Ian * elf.c (elf_uncompress_lzma_block): Skip all header padding bytes and verify that they are zero. 23f9fbed3c97ed70d2615d7d3fa7c249cc862553 diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index f4527e2477d..7841c86cd9c 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -5568,6 +5568,7 @@ elf_uncompress_lzma_block (const unsigned char *compressed, uint64_t header_compressed_size; uint64_t header_uncompressed_size; unsigned char lzma2_properties; + size_t crc_offset; uint32_t computed_crc; uint32_t stream_crc; size_t uncompressed_offset; @@ -5671,19 +5672,20 @@ elf_uncompress_lzma_block (const unsigned char *compressed, /* The properties describe the dictionary size, but we don't care what that is. */ - /* Block header padding. */ - if (unlikely (off + 4 > compressed_size)) + /* Skip to just before CRC, verifying zero bytes in between. */ + crc_offset = block_header_offset + block_header_size - 4; + if (unlikely (crc_offset + 4 > compressed_size)) { elf_uncompress_failed (); return 0; } - - off = (off + 3) &~ (size_t) 3; - - if (unlikely (off + 4 > compressed_size)) + for (; off < crc_offset; off++) { - elf_uncompress_failed (); - return 0; + if (compressed[off] != 0) + { + elf_uncompress_failed (); + return 0; + } } /* Block header CRC. */
Re: libbacktrace patch committed: Read symbol table of debuginfo file
On Thu, Feb 29, 2024 at 7:47 PM Ian Lance Taylor wrote: > > This patch to libbacktrace reads symbol tables from debuginfo files. > These become another symbol table to search. This is needed if people > use --strip-all rather than --strip-debug when adding a debuglink > section. This fixes > https://github.com/ianlancetaylor/libbacktrace/issues/113. > Bootstrapped and ran libbacktrace and libgo tests on > x86_64-pc-linux-gnu. Committed to mainline. This introduced a bug on the PPC v1 ABI, where libbacktrace uses the .opd section to convert from a function descriptor address to a code address. The .opd section is missing from a debuginfo file. This patch changes the code to use the original .opd section if it is missing. Checked on powerpc64-linux-gnu and x86_64-pc-linux-gnu. Committed to mainline. Ian PR libbacktrace/114201 * elf.c (elf_add): Add caller_opd parameter. Change all callers. Release opd data after all recursive calls. f692b338cd27a4e0d38fcb5af3d416cd66fbf814 diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index 664937e1438..f4527e2477d 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -6501,8 +6501,9 @@ backtrace_uncompress_lzma (struct backtrace_state *state, static int elf_add (struct backtrace_state *state, const char *filename, int descriptor, const unsigned char *memory, size_t memory_size, -uintptr_t base_address, backtrace_error_callback error_callback, -void *data, fileline *fileline_fn, int *found_sym, int *found_dwarf, +uintptr_t base_address, struct elf_ppc64_opd_data *caller_opd, +backtrace_error_callback error_callback, void *data, +fileline *fileline_fn, int *found_sym, int *found_dwarf, struct dwarf_data **fileline_entry, int exe, int debuginfo, const char *with_buildid_data, uint32_t with_buildid_size) { @@ -6557,6 +6558,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, struct elf_view split_debug_view[DEBUG_MAX]; unsigned char split_debug_view_valid[DEBUG_MAX]; struct elf_ppc64_opd_data opd_data, *opd; + int opd_view_valid; struct dwarf_sections dwarf_sections; if (!debuginfo) @@ -6584,6 +6586,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, debug_view_valid = 0; memset (_debug_view_valid[0], 0, sizeof split_debug_view_valid); opd = NULL; + opd_view_valid = 0; if (!elf_get_view (state, descriptor, memory, memory_size, 0, sizeof ehdr, error_callback, data, _view)) @@ -6867,9 +6870,15 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, opd->addr = shdr->sh_addr; opd->data = (const char *) opd_data.view.view.data; opd->size = shdr->sh_size; + opd_view_valid = 1; } } + // A debuginfo file may not have a useful .opd section, but we can use the + // one from the original executable. + if (opd == NULL) +opd = caller_opd; + if (symtab_shndx == 0) symtab_shndx = dynsym_shndx; if (symtab_shndx != 0) @@ -6948,9 +6957,9 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, elf_release_view (state, _view, error_callback, data); if (debugaltlink_view_valid) elf_release_view (state, _view, error_callback, data); - ret = elf_add (state, "", d, NULL, 0, base_address, error_callback, -data, fileline_fn, found_sym, found_dwarf, NULL, 0, -1, NULL, 0); + ret = elf_add (state, "", d, NULL, 0, base_address, opd, +error_callback, data, fileline_fn, found_sym, +found_dwarf, NULL, 0, 1, NULL, 0); if (ret < 0) backtrace_close (d, error_callback, data); else if (descriptor >= 0) @@ -6965,12 +6974,6 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, buildid_view_valid = 0; } - if (opd) -{ - elf_release_view (state, >view, error_callback, data); - opd = NULL; -} - if (debuglink_name != NULL) { int d; @@ -6985,9 +6988,9 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, elf_release_view (state, _view, error_callback, data); if (debugaltlink_view_valid) elf_release_view (state, _view, error_callback, data); - ret = elf_add (state, "", d, NULL, 0, base_address, error_callback, -data, fileline_fn, found_sym, found_dwarf, NULL, 0, -1, NULL, 0); + ret = elf_add (state, "", d, NULL, 0, base_address, opd, +error_callback, data, fileline_fn, found_sym, +found_dwarf, NULL, 0, 1, NULL, 0); if (ret < 0) backtrace_close (d, error_callback, data); else if (descriptor >= 0) @@ -7013,7 +7016,7 @@ elf_add (struct
libbacktrace patch committed: Read symbol table of debuginfo file
This patch to libbacktrace reads symbol tables from debuginfo files. These become another symbol table to search. This is needed if people use --strip-all rather than --strip-debug when adding a debuglink section. This fixes https://github.com/ianlancetaylor/libbacktrace/issues/113. Bootstrapped and ran libbacktrace and libgo tests on x86_64-pc-linux-gnu. Committed to mainline. Ian * elf.c (elf_add): Add the symbol table from a debuginfo file. * Makefile.am (MAKETESTS): Add buildidfull and gnudebuglinkfull variants of buildid and gnudebuglink tests. (%_gnudebuglinkfull, %_buildidfull): New patterns. * Makefile.in: Regenerate. 24810fbf7b0ce274dfa46cc362305ac77ee5a72c diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am index 16a72d2abf7..750ed80ed05 100644 --- a/libbacktrace/Makefile.am +++ b/libbacktrace/Makefile.am @@ -257,7 +257,7 @@ b2test_LDFLAGS = -Wl,--build-id b2test_LDADD = libbacktrace_elf_for_test.la check_PROGRAMS += b2test -MAKETESTS += b2test_buildid +MAKETESTS += b2test_buildid b2test_buildidfull if HAVE_DWZ @@ -267,7 +267,7 @@ b3test_LDFLAGS = -Wl,--build-id b3test_LDADD = libbacktrace_elf_for_test.la check_PROGRAMS += b3test -MAKETESTS += b3test_dwz_buildid +MAKETESTS += b3test_dwz_buildid b3test_dwz_buildidfull endif HAVE_DWZ @@ -443,12 +443,16 @@ endif HAVE_PTHREAD if HAVE_OBJCOPY_DEBUGLINK -MAKETESTS += btest_gnudebuglink +MAKETESTS += btest_gnudebuglink btest_gnudebuglinkfull %_gnudebuglink: % $(OBJCOPY) --only-keep-debug $< $@.debug $(OBJCOPY) --strip-debug --add-gnu-debuglink=$@.debug $< $@ +%_gnudebuglinkfull: % + $(OBJCOPY) --only-keep-debug $< $@.debug + $(OBJCOPY) --strip-all --add-gnu-debuglink=$@.debug $< $@ + endif HAVE_OBJCOPY_DEBUGLINK %_buildid: % @@ -457,6 +461,12 @@ endif HAVE_OBJCOPY_DEBUGLINK $< $(OBJCOPY) --strip-debug $< $@ +%_buildidfull: % + ./install-debuginfo-for-buildid.sh \ + "$(TEST_BUILD_ID_DIR)" \ + $< + $(OBJCOPY) --strip-all $< $@ + if HAVE_COMPRESSED_DEBUG ctestg_SOURCES = btest.c testlib.c diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index c506cc29fe1..664937e1438 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -6872,7 +6872,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, if (symtab_shndx == 0) symtab_shndx = dynsym_shndx; - if (symtab_shndx != 0 && !debuginfo) + if (symtab_shndx != 0) { const b_elf_shdr *symtab_shdr; unsigned int strtab_shndx;
[PATCH][committed]middle-end: fix pointer conversion error in testcase vect-early-break_110-pr113467.c
Hi All, I had missed a conversion from unsigned long to uint64_t. This fixes the failing test on -m32. Regtested on x86_64-pc-linux-gnu with -m32 and no issues. Committed as obvious. Thanks, Tamar gcc/testsuite/ChangeLog: * gcc.dg/vect/vect-early-break_110-pr113467.c: Change unsigned long * to uint64_t *. --- inline copy of patch -- diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_110-pr113467.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_110-pr113467.c index 1e2c47be5fdf1e1fed88e4b5f45d7eda6c3b85d1..12d0ea1e871b51742c040c909ea5741bc820206e 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-early-break_110-pr113467.c +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_110-pr113467.c @@ -10,7 +10,7 @@ typedef struct gcry_mpi *gcry_mpi_t; struct gcry_mpi { int nlimbs; - unsigned long *d; + uint64_t *d; }; long gcry_mpi_add_ui_up; -- diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_110-pr113467.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_110-pr113467.c index 1e2c47be5fdf1e1fed88e4b5f45d7eda6c3b85d1..12d0ea1e871b51742c040c909ea5741bc820206e 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-early-break_110-pr113467.c +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_110-pr113467.c @@ -10,7 +10,7 @@ typedef struct gcry_mpi *gcry_mpi_t; struct gcry_mpi { int nlimbs; - unsigned long *d; + uint64_t *d; }; long gcry_mpi_add_ui_up;
libgo patch committed: Bump version number
This libgo patch bumps the version number for the GCC 14 release. This is for GCC PR 113668. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 7b0597eba6b29387b56b8d6a4b38f3586e6b49a5 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index ec7e2ab1acf..73cb095322c 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -1cb83a415e86ab4de0d436d277377d8fc060cb61 +e15a14e410b8fc5d28012d5b313cb6c8476c7df9 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/configure.ac b/libgo/configure.ac index 22158ac7f5d..898091276f7 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac @@ -10,7 +10,7 @@ AC_INIT(package-unused, version-unused,, libgo) AC_CONFIG_SRCDIR(Makefile.am) AC_CONFIG_HEADER(config.h) -libtool_VERSION=22:0:0 +libtool_VERSION=23:0:0 AC_SUBST(libtool_VERSION) AM_ENABLE_MULTILIB(, ..)
Go frontend patch committed: print types in a more readable way
This patch to the Go frontend adds Type::message_name to print types in ways that makes sense to users. As we move toward generics, the error messages need to be able to refer to types in a readable manner. Today we use this new feature in AST dumps. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 3818237cd5111fdd089f9c9470d384eebbe6ee1e diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 429904a2b8f..ec7e2ab1acf 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -8c056e335cecec67d1d223a329b7ba4dac778a65 +1cb83a415e86ab4de0d436d277377d8fc060cb61 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/ast-dump.cc b/gcc/go/gofrontend/ast-dump.cc index eca0bf1fad2..12f49e68700 100644 --- a/gcc/go/gofrontend/ast-dump.cc +++ b/gcc/go/gofrontend/ast-dump.cc @@ -223,14 +223,7 @@ Ast_dump_context::dump_type(const Type* t) if (t == NULL) this->ostream() << "(nil type)"; else -// FIXME: write a type pretty printer instead of -// using mangled names. -if (this->gogo_ != NULL) - { - Backend_name bname; - t->backend_name(this->gogo_, ); - this->ostream() << "(" << bname.name() << ")"; - } +this->ostream() << "(" << t->message_name() << ")"; } // Dump a textual representation of a block to the diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index b349ad10d6f..a39cfbf7679 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -270,6 +270,16 @@ Type::set_is_error() this->classification_ = TYPE_ERROR; } +// Return a string version of this type to use in an error message. + +std::string +Type::message_name() const +{ + std::string ret; + this->do_message_name(); + return ret; +} + // If this is a pointer type, return the type to which it points. // Otherwise, return NULL. @@ -742,16 +752,14 @@ Type::are_assignable(const Type* lhs, const Type* rhs, std::string* reason) { if (rhs->interface_type() != NULL) reason->assign(_("need explicit conversion")); - else if (lhs_orig->named_type() != NULL - && rhs_orig->named_type() != NULL) + else { - size_t len = (lhs_orig->named_type()->name().length() - + rhs_orig->named_type()->name().length() - + 100); + const std::string& lhs_name(lhs_orig->message_name()); + const std::string& rhs_name(rhs_orig->message_name()); + size_t len = lhs_name.length() + rhs_name.length() + 100; char* buf = new char[len]; snprintf(buf, len, _("cannot use type %s as type %s"), - rhs_orig->named_type()->message_name().c_str(), - lhs_orig->named_type()->message_name().c_str()); + rhs_name.c_str(), lhs_name.c_str()); reason->assign(buf); delete[] buf; } @@ -4244,6 +4252,33 @@ Integer_type::is_identical(const Integer_type* t) const return this->is_abstract_ == t->is_abstract_; } +// Message name. + +void +Integer_type::do_message_name(std::string* ret) const +{ + ret->append("is_byte_) +ret->append("byte"); + else if (this->is_rune_) +ret->append("rune"); + else +{ + if (this->is_unsigned_) + ret->push_back('u'); + if (this->is_abstract_) + ret->append("int"); + else + { + ret->append("int"); + char buf[10]; + snprintf(buf, sizeof buf, "%d", this->bits_); + ret->append(buf); + } +} + ret->push_back('>'); +} + // Hash code. unsigned int @@ -4382,6 +4417,21 @@ Float_type::is_identical(const Float_type* t) const return this->is_abstract_ == t->is_abstract_; } +// Message name. + +void +Float_type::do_message_name(std::string* ret) const +{ + ret->append("is_abstract_) +{ + char buf[10]; + snprintf(buf, sizeof buf, "%d", this->bits_); + ret->append(buf); +} + ret->push_back('>'); +} + // Hash code. unsigned int @@ -4496,6 +4546,21 @@ Complex_type::is_identical(const Complex_type *t) const return this->is_abstract_ == t->is_abstract_; } +// Message name. + +void +Complex_type::do_message_name(std::string* ret) const +{ + ret->append("is_abstract_) +{ + char buf[10]; + snprintf(buf, sizeof buf, "%d", this->bits_); + ret->append(buf); +} + ret->push_back('>'); +} + // Hash code. unsigned int @@ -4661,6 +4726,10 @@ class Sink_type : public Type { } protected: + void + do_message_name(std::string* ret) const + { ret->append(""); } + bool do_compare_is_identity(Gogo*) { return false; } @@ -4696,6 +4765,70 @@ Type::make_sink_type() // Class Function_type. +// Message name. + +void +Function_type::do_message_name(std::string* ret) const +{ + ret->append("func"); + if (this->receiver_ != NULL) +{ +
libgo patch committed: Better error messages for unsupported target
This libgo patch generates better error messages then the Go GOARCH and GOOS values can't be determined from the target. This indicates that the target is not supported. This is for GCC PR 113530. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian cfc6d9ae8143cf0e903384bc63e8d659ca1c9fe7 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 18281c6cd1e..429904a2b8f 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -7ab229670f7dad1d79f33929f9a4f8e6e4a71526 +8c056e335cecec67d1d223a329b7ba4dac778a65 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/Makefile.am b/libgo/Makefile.am index c95dc2106cd..3eccadbac67 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -497,6 +497,10 @@ s-version: Makefile zgoarch.go: s-zgoarch; @true s-zgoarch: Makefile goarch.sh rm -f zgoarch.go.tmp + if ! $(SHELL) $(srcdir)/goarch.sh $(GOARCH) family >/dev/null 2>/dev/null; then \ + $(SHELL) $(srcdir)/goarch.sh $(GOARCH) family; \ + exit 1; \ + fi echo "package goarch" > zgoarch.go.tmp echo >> zgoarch.go.tmp echo 'const GOARCH = "'$(GOARCH)'"' >> zgoarch.go.tmp diff --git a/libgo/configure.ac b/libgo/configure.ac index e8d66f8415d..22158ac7f5d 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac @@ -209,6 +209,10 @@ AM_CONDITIONAL(LIBGO_IS_BSD, test $is_darwin = yes -o $is_dragonfly = yes -o $is AC_SUBST(GOOS) AC_SUBST(ALLGOOS) +if test "${GOOS}" = "unknown"; then + AC_MSG_ERROR("could not determine GOOS from ${host}") +fi + dnl Test whether we need to use DejaGNU or whether we can use the dnl simpler gotest approach. We can only use gotest for a native dnl build. @@ -376,6 +380,10 @@ AC_SUBST(GOARCH) AC_SUBST(ALLGOARCH) AC_SUBST(ALLGOARCHFAMILY) +if test "${GOARCH}" = "unknown"; then + AC_MSG_ERROR("could not determine GOARCH from ${host}") +fi + AM_CONDITIONAL(LIBGO_IS_X86, test "$GOARCH" = "386" -o "$GOARCH" = "amd64" -o "$GOARCH" = "amd64p32") FUNCTION_DESCRIPTORS=false
Go patch committed: Export the type "any" as a builtin
This patch to the Go frontend exports the type "any" as a builtin. Otherwise we can't tell the difference between builtin type "any" and a locally defined type "any". This will require updates to the gccgo export data parsers in the main Go repo and the x/tools repo. These updates are https://go.dev/cl/537195 and https://go.dev/cl/537215. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian e52d31804a910642c9817bdd400c290a593c98ef diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index c2a6032ae80..18281c6cd1e 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -ddf3758e4a45ca2816fb68f3e4224501a3c4c438 +7ab229670f7dad1d79f33929f9a4f8e6e4a71526 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/export.cc b/gcc/go/gofrontend/export.cc index 7373deee310..40f6d5d4b2f 100644 --- a/gcc/go/gofrontend/export.cc +++ b/gcc/go/gofrontend/export.cc @@ -1661,6 +1661,7 @@ Export::register_builtin_types(Gogo* gogo) this->register_builtin_type(gogo, "error", BUILTIN_ERROR); this->register_builtin_type(gogo, "byte", BUILTIN_BYTE); this->register_builtin_type(gogo, "rune", BUILTIN_RUNE); + this->register_builtin_type(gogo, "any", BUILTIN_ANY); } // Register one builtin type in the export table. diff --git a/gcc/go/gofrontend/export.h b/gcc/go/gofrontend/export.h index 1f613434cab..be117ece2ce 100644 --- a/gcc/go/gofrontend/export.h +++ b/gcc/go/gofrontend/export.h @@ -51,8 +51,9 @@ enum Builtin_code BUILTIN_ERROR = -19, BUILTIN_BYTE = -20, BUILTIN_RUNE = -21, + BUILTIN_ANY = -22, - SMALLEST_BUILTIN_CODE = -21 + SMALLEST_BUILTIN_CODE = -22 }; // Export data version number. New export data is written with the diff --git a/gcc/go/gofrontend/import.cc b/gcc/go/gofrontend/import.cc index 21691fa5ff4..3cc8a720ee4 100644 --- a/gcc/go/gofrontend/import.cc +++ b/gcc/go/gofrontend/import.cc @@ -1408,6 +1408,7 @@ Import::register_builtin_types(Gogo* gogo) this->register_builtin_type(gogo, "error", BUILTIN_ERROR); this->register_builtin_type(gogo, "byte", BUILTIN_BYTE); this->register_builtin_type(gogo, "rune", BUILTIN_RUNE); + this->register_builtin_type(gogo, "any", BUILTIN_ANY); } // Register a single builtin type. diff --git a/libgo/go/go/internal/gccgoimporter/parser.go b/libgo/go/go/internal/gccgoimporter/parser.go index 48335fa6d8f..2161df7f368 100644 --- a/libgo/go/go/internal/gccgoimporter/parser.go +++ b/libgo/go/go/internal/gccgoimporter/parser.go @@ -187,7 +187,6 @@ func (p *parser) parseQualifiedNameStr(unquotedName string) (pkgpath, name strin // getPkg returns the package for a given path. If the package is // not found but we have a package name, create the package and // add it to the p.imports map. -// func (p *parser) getPkg(pkgpath, name string) *types.Package { // package unsafe is not in the imports map - handle explicitly if pkgpath == "unsafe" { @@ -904,6 +903,7 @@ const ( gccgoBuiltinERROR = 19 gccgoBuiltinBYTE = 20 gccgoBuiltinRUNE = 21 + gccgoBuiltinANY= 22 ) func lookupBuiltinType(typ int) types.Type { @@ -928,13 +928,13 @@ func lookupBuiltinType(typ int) types.Type { gccgoBuiltinERROR: types.Universe.Lookup("error").Type(), gccgoBuiltinBYTE: types.Universe.Lookup("byte").Type(), gccgoBuiltinRUNE: types.Universe.Lookup("rune").Type(), + gccgoBuiltinANY:types.Universe.Lookup("any").Type(), }[typ] } // Type = "<" "type" ( "-" int | int [ TypeSpec ] ) ">" . // // parseType updates the type map to t for all type numbers n. -// func (p *parser) parseType(pkg *types.Package, n ...any) types.Type { p.expect('<') t, _ := p.parseTypeAfterAngle(pkg, n...) @@ -1117,9 +1117,10 @@ func (p *parser) maybeCreatePackage() { } // InitDataDirective = ( "v1" | "v2" | "v3" ) ";" | -// "priority" int ";" | -// "init" { PackageInit } ";" | -// "checksum" unquotedString ";" . +// +// "priority" int ";" | +// "init" { PackageInit } ";" | +// "checksum" unquotedString ";" . func (p *parser) parseInitDataDirective() { if p.tok != scanner.Ident { // unexpected token kind; panic @@ -1170,15 +1171,16 @@ func (p *parser) parseInitDataDirective() { } // Directive = InitDataDirective | -// "package" unquotedString [ unquotedString ] [ unquotedString ] ";" | -// "pkgpath" unquotedString ";" | -// "prefix" unquotedString ";" | -// "import" unquotedString unquotedString string ";" | -// "indirectimport" unquotedString unquotedstring ";" | -// "func" Func ";" | -// "type" Type ";" | -// "var" Var ";" | -// "const"
[PATCH, committed] Fortran: fix bounds-checking errors for CLASS array dummies [PR104908]
Dear all, commit r11-1235 for pr95331 addressed array bounds issues with unlimited polymorphic array dummies, but caused regressions for CLASS array dummies that lead to either wrong code with bounds-checking, or an ICE. The solution is simple: add a check whether the dummy is unlimited polymorphic and otherwise restore the previous behavior. The attached patch regtested fine on x86_64-pc-linux-gnu and was OK'ed in the PR by Jerry. Pushed as: r14-8471-gce61de1b8a1bb3 Since this is a 11/12/13/14 regression and appears safe otherwise, I intend to backport as suitable, unless there are comments. Thanks, Harald From ce61de1b8a1bb3a22118e900376f380768f2ba59 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sat, 27 Jan 2024 17:41:43 +0100 Subject: [PATCH] Fortran: fix bounds-checking errors for CLASS array dummies [PR104908] Commit r11-1235 addressed issues with bounds of unlimited polymorphic array dummies. However, using the descriptor from sym->backend_decl does break the case of CLASS array dummies. The obvious solution is to restrict the fix to the unlimited polymorphic case, thus keeping the original descriptor in the ordinary case. gcc/fortran/ChangeLog: PR fortran/104908 * trans-array.cc (gfc_conv_array_ref): Restrict use of transformed descriptor (sym->backend_decl) to the unlimited polymorphic case. gcc/testsuite/ChangeLog: PR fortran/104908 * gfortran.dg/pr104908.f90: New test. --- gcc/fortran/trans-array.cc | 5 +++- gcc/testsuite/gfortran.dg/pr104908.f90 | 32 ++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr104908.f90 diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 878a92aff18..1e0d698a949 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -4063,7 +4063,10 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar, gfc_expr *expr, } decl = se->expr; - if (IS_CLASS_ARRAY (sym) && sym->attr.dummy && ar->as->type != AS_DEFERRED) + if (UNLIMITED_POLY(sym) + && IS_CLASS_ARRAY (sym) + && sym->attr.dummy + && ar->as->type != AS_DEFERRED) decl = sym->backend_decl; cst_offset = offset = gfc_index_zero_node; diff --git a/gcc/testsuite/gfortran.dg/pr104908.f90 b/gcc/testsuite/gfortran.dg/pr104908.f90 new file mode 100644 index 000..c3a30b0003c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr104908.f90 @@ -0,0 +1,32 @@ +! { dg-do compile } +! { dg-additional-options "-fcheck=bounds -fdump-tree-original" } +! +! PR fortran/104908 - incorrect out-of-bounds runtime error + +program test + implicit none + type vec + integer :: x(3) = [2,4,6] + end type vec + type(vec) :: w(2) + call sub(w) +contains + subroutine sub (v) +class(vec), intent(in) :: v(:) +integer :: k, q(3) +q = [ (v(1)%x(k), k = 1, 3) ] ! <-- was failing here after r11-1235 +print *, q + end +end + +subroutine sub2 (zz) + implicit none + type vec + integer :: x(2,1) + end type vec + class(vec), intent(in) :: zz(:) ! used to ICE after r11-1235 + integer :: k + k = zz(1)%x(2,1) +end + +! { dg-final { scan-tree-dump-times " above upper bound " 4 "original" } } -- 2.35.3
Go patch committed: Don't pass iota value to lowering pass
This patch to the Go frontend stops passing the iota value to the lowering pass. It is no longer used. The iota value is now handled in the determine-types pass. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 896148947b9ff4845c8bc334f8eff30f91ff3c9a diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index b41ac99f7a8..c2a6032ae80 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -61b29a99dadf33c48a0a063f50f61e877fb419b8 +ddf3758e4a45ca2816fb68f3e4224501a3c4c438 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index a09d33b868e..51ff0206129 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -1007,7 +1007,7 @@ Expression::make_type(Type* type, Location location) Expression* Var_expression::do_lower(Gogo* gogo, Named_object* function, -Statement_inserter* inserter, int) +Statement_inserter* inserter) { if (this->variable_->is_variable()) { @@ -1158,7 +1158,7 @@ Enclosed_var_expression::do_traverse(Traverse*) Expression* Enclosed_var_expression::do_lower(Gogo* gogo, Named_object* function, - Statement_inserter* inserter, int) + Statement_inserter* inserter) { gogo->lower_expression(function, inserter, >reference_); return this; @@ -2097,7 +2097,7 @@ Unknown_expression::do_is_addressable() const // Lower a reference to an unknown name. Expression* -Unknown_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int) +Unknown_expression::do_lower(Gogo*, Named_object*, Statement_inserter*) { if (this->is_error_expression()) return Expression::make_error(this->location()); @@ -3642,7 +3642,7 @@ Const_expression::do_is_zero_value() const // predeclared constant iota into an integer value. Expression* -Const_expression::do_lower(Gogo* gogo, Named_object*, Statement_inserter*, int) +Const_expression::do_lower(Gogo* gogo, Named_object*, Statement_inserter*) { Location loc = this->location(); @@ -4120,7 +4120,7 @@ class Iota_expression : public Parser_expression { } Expression* - do_lower(Gogo*, Named_object*, Statement_inserter*, int) + do_lower(Gogo*, Named_object*, Statement_inserter*) { go_unreachable(); } // There should only ever be one of these. @@ -4171,7 +4171,7 @@ Type_conversion_expression::do_type() Expression* Type_conversion_expression::do_lower(Gogo* gogo, Named_object*, -Statement_inserter* inserter, int) +Statement_inserter* inserter) { Type* type = this->type_; Expression* val = this->expr_; @@ -4997,7 +4997,7 @@ Unary_expression::check_operand_address_taken(Gogo*) // instead. Expression* -Unary_expression::do_lower(Gogo* gogo, Named_object*, Statement_inserter*, int) +Unary_expression::do_lower(Gogo* gogo, Named_object*, Statement_inserter*) { Location loc = this->location(); @@ -6677,7 +6677,7 @@ Binary_expression::eval_complex(Operator op, const Numeric_constant* left_nc, Expression* Binary_expression::do_lower(Gogo* gogo, Named_object*, - Statement_inserter* inserter, int) + Statement_inserter* inserter) { Location location = this->location(); @@ -8955,7 +8955,7 @@ class Selector_expression : public Parser_expression do_issue_nil_check(); Expression* - do_lower(Gogo*, Named_object*, Statement_inserter*, int); + do_lower(Gogo*, Named_object*, Statement_inserter*); Expression* do_copy() @@ -9030,7 +9030,7 @@ Selector_expression::do_issue_nil_check() // Lower a selector expression to the resolved value. Expression* -Selector_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int) +Selector_expression::do_lower(Gogo*, Named_object*, Statement_inserter*) { if (this->is_error_expression() || this->resolved_ == NULL) return Expression::make_error(this->location()); @@ -9360,7 +9360,7 @@ Builtin_call_expression::do_set_recover_arg(Expression* arg) Expression* Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function, - Statement_inserter* inserter, int) + Statement_inserter* inserter) { if (this->is_error_expression()) return this; @@ -12564,7 +12564,7 @@ Call_expression::do_discarding_value() Expression* Call_expression::do_lower(Gogo* gogo, Named_object*, - Statement_inserter* inserter, int) + Statement_inserter* inserter) { if (this->lowered_ != NULL) return this->lowered_; @@ -14836,7 +14836,7 @@ Index_expression::do_issue_nil_check() // expression into an array index, a string index, or a map index.
[PATCH, committed] Fortran: fix wrong array bounds check [PR113471]
Dear all, I've pushed the attached obvious patch for a regression due to a wrong array bounds check after regtesting on x86_64-pc-linux-gnu and verification of the fix by the reporter in the PR. https://gcc.gnu.org/g:94b2e6cb1cc4feb122bf77f19a657c97bffa9b42 Thanks, Harald From 94b2e6cb1cc4feb122bf77f19a657c97bffa9b42 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Fri, 19 Jan 2024 21:20:44 +0100 Subject: [PATCH] Fortran: fix wrong array bounds check [PR113471] gcc/fortran/ChangeLog: PR fortran/113471 * trans-array.cc (array_bound_check_elemental): Array bounds check shall apply here to elemental dimensions of an array section only. gcc/testsuite/ChangeLog: PR fortran/113471 * gfortran.dg/bounds_check_24.f90: New test. --- gcc/fortran/trans-array.cc| 2 +- gcc/testsuite/gfortran.dg/bounds_check_24.f90 | 28 +++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/bounds_check_24.f90 diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 26e7adaa03f..878a92aff18 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -3600,7 +3600,7 @@ array_bound_check_elemental (gfc_se * se, gfc_ss * ss, gfc_expr * expr) continue; } - if (ref->type == REF_ARRAY && ref->u.ar.dimen > 0) + if (ref->type == REF_ARRAY && ref->u.ar.type == AR_SECTION) { ar = >u.ar; for (dim = 0; dim < ar->dimen; dim++) diff --git a/gcc/testsuite/gfortran.dg/bounds_check_24.f90 b/gcc/testsuite/gfortran.dg/bounds_check_24.f90 new file mode 100644 index 000..d0251e8455b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/bounds_check_24.f90 @@ -0,0 +1,28 @@ +! { dg-do compile } +! { dg-additional-options "-fcheck=bounds -fdump-tree-original" } +! +! PR fortran/113471 - wrong array bounds check + +program pr113471 + implicit none + type t + integer, dimension(2) :: c1 = 0 + end type t + type(t) :: cc(7), bb(7) + integer :: kk = 1 + + ! no bounds check (can be determined at compile time): + call foo (cc(7)% c1) + + ! bounds check involving kk, but no "outside of expected range" + call foo (bb(kk)% c1) + +contains + subroutine foo (c) +integer, intent(in) :: c(:) + end +end + +! { dg-final { scan-tree-dump-times "below lower bound" 2 "original" } } +! { dg-final { scan-tree-dump-times "above upper bound" 2 "original" } } +! { dg-final { scan-tree-dump-not "outside of expected range" "original" } } -- 2.35.3
Re: Go patch committed: Move lowering pass after check types pass
On Mon, Dec 18, 2023 at 5:32 PM Ian Lance Taylor wrote: > > This Go frontend patch moves the lowering pass after the type > determination and the type checking passes. This lets us simplify > some of the code that determines the type of an expression, which > previously had to work correctly both before and after type > determination. > > I'm doing this to help with future generic support. For example, with > generics, we can see code like > > func ident[T any](v T) T { return v } > > func F() int32 { > s := int32(1) > return ident(s) > } > > Before this change, we would type check return statements in the > lowering pass (see Return_statement::do_lower). With a generic > example like the above, that means we have to determine the type of s, > and use that to infer the type arguments passed to ident, and use that > to determine the result type of ident. That is too much to do at > lowering time. Of course we can change the way that return statements > work, but similar issues arise with index expressions, the types of > closures for function literals, and probably other cases as well. > > Rather than try to deal with all those cases, we move the lowering > pass after type checking. This requires a bunch of changes, notably > for determining constant types. We have to add type checking for > various constructs that formerly disappeared in the lowering pass. So > it's a lot of shuffling. Sorry for the size of the patch. > > Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed > to mainline. Sorry, I forgot to commit the changes to some of the test files. I've committed this patch to fix them. This fixes PR 113447. Ian 3d7820c58f9466a80916dfa50dcdfde457b4c597 diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue20185.go b/gcc/testsuite/go.test/test/fixedbugs/issue20185.go index 9065868d7f2..24d74f09126 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue20185.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue20185.go @@ -10,7 +10,7 @@ package p func F() { - switch t := nil.(type) { // ERROR "cannot type switch on non-interface value" + switch t := nil.(type) { // ERROR "cannot type switch on non-interface value|defined to nil type" default: _ = t } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue33386.go b/gcc/testsuite/go.test/test/fixedbugs/issue33386.go index 7b2f565285e..c5073910a4c 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue33386.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue33386.go @@ -18,7 +18,7 @@ func _() { func _() { defer func() { // no error here about deferred function - 1 +// GCCGO_ERROR "value computed is not used" + 1 + }()// ERROR "expecting expression|expected operand" } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4085a.go b/gcc/testsuite/go.test/test/fixedbugs/issue4085a.go index 200290a081d..f457fcf2b12 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4085a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4085a.go @@ -10,9 +10,9 @@ type T []int func main() { _ = make(T, -1)// ERROR "negative" - _ = make(T, 0.5) // ERROR "constant 0.5 truncated to integer|non-integer len argument" + _ = make(T, 0.5) // ERROR "truncated to integer|non-integer len argument" _ = make(T, 1.0) // ok - _ = make(T, 1<<63) // ERROR "len argument too large" + _ = make(T, 1<<63) // ERROR "integer constant overflow|len argument too large" _ = make(T, 0, -1) // ERROR "negative cap" _ = make(T, 10, 0) // ERROR "len larger than cap" } diff --git a/gcc/testsuite/go.test/test/shift1.go b/gcc/testsuite/go.test/test/shift1.go index d6a6c38839f..3b1aa9e6900 100644 --- a/gcc/testsuite/go.test/test/shift1.go +++ b/gcc/testsuite/go.test/test/shift1.go @@ -189,12 +189,12 @@ func _() { var m1 map[int]string delete(m1, 1<
[PATCH][committed][c++ frontend]: initialize ivdep value
Hi All, Should control enter the switch from one of the cases other than the IVDEP one then the variable remains uninitialized. This fixes it by initializing it to false. Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu and no issues Committed as obvious. Thanks, Tamar gcc/cp/ChangeLog: * parser.cc (cp_parser_pragma): Initialize to false. --- inline copy of patch -- diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 379aeb56b152b9b29606ba4d75ad4c49dfe92aac..1b4ce1497e893d6463350eecf5ef4e88957f5f00 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -50625,7 +50625,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_UNROLL: case PRAGMA_NOVECTOR: { - bool ivdep; + bool ivdep = false; tree unroll = NULL_TREE; bool novector = false; const char *pragma_str; -- diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 379aeb56b152b9b29606ba4d75ad4c49dfe92aac..1b4ce1497e893d6463350eecf5ef4e88957f5f00 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -50625,7 +50625,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_UNROLL: case PRAGMA_NOVECTOR: { - bool ivdep; + bool ivdep = false; tree unroll = NULL_TREE; bool novector = false; const char *pragma_str;
[PATCH][committed]middle-end: removed unused variable in vectorizable_live_operation_1
Hi All, It looks like the previous patch had an unused variable. It's odd that my bootstrap didn't catch it (I'm assuming -Werror is still on for O3 bootstraps) but this fixes it. Committed to fix bootstrap. Thanks, Tamar gcc/ChangeLog: * tree-vect-loop.cc (vectorizable_live_operation_1): Drop unused restart_loop. (vectorizable_live_operation): Likewise. --- inline copy of patch -- diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 39b1161309d8ff8bfe88ee26df9147df0af0a58c..c218d514fe4be57fca97a85a36be7240d3e84edf 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -10575,13 +10575,12 @@ vectorizable_induction (loop_vec_info loop_vinfo, helper function for vectorizable_live_operation. */ -tree +static tree vectorizable_live_operation_1 (loop_vec_info loop_vinfo, stmt_vec_info stmt_info, basic_block exit_bb, tree vectype, int ncopies, slp_tree slp_node, tree bitsize, tree bitstart, tree vec_lhs, - tree lhs_type, bool restart_loop, - gimple_stmt_iterator *exit_gsi) + tree lhs_type, gimple_stmt_iterator *exit_gsi) { gcc_assert (single_pred_p (exit_bb) || LOOP_VINFO_EARLY_BREAKS (loop_vinfo)); @@ -10597,7 +10596,7 @@ vectorizable_live_operation_1 (loop_vec_info loop_vinfo, if (integer_zerop (bitstart)) { tree scalar_res = gimple_build (, BIT_FIELD_REF, TREE_TYPE (vectype), - vec_lhs_phi, bitsize, bitstart); + vec_lhs_phi, bitsize, bitstart); /* Convert the extracted vector element to the scalar type. */ new_tree = gimple_convert (, lhs_type, scalar_res); @@ -10958,8 +10957,7 @@ vectorizable_live_operation (vec_info *vinfo, stmt_vec_info stmt_info, dest, vectype, ncopies, slp_node, bitsize, tmp_bitstart, tmp_vec_lhs, -lhs_type, restart_loop, -_gsi); +lhs_type, _gsi); if (gimple_phi_num_args (use_stmt) == 1) { -- diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 39b1161309d8ff8bfe88ee26df9147df0af0a58c..c218d514fe4be57fca97a85a36be7240d3e84edf 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -10575,13 +10575,12 @@ vectorizable_induction (loop_vec_info loop_vinfo, helper function for vectorizable_live_operation. */ -tree +static tree vectorizable_live_operation_1 (loop_vec_info loop_vinfo, stmt_vec_info stmt_info, basic_block exit_bb, tree vectype, int ncopies, slp_tree slp_node, tree bitsize, tree bitstart, tree vec_lhs, - tree lhs_type, bool restart_loop, - gimple_stmt_iterator *exit_gsi) + tree lhs_type, gimple_stmt_iterator *exit_gsi) { gcc_assert (single_pred_p (exit_bb) || LOOP_VINFO_EARLY_BREAKS (loop_vinfo)); @@ -10597,7 +10596,7 @@ vectorizable_live_operation_1 (loop_vec_info loop_vinfo, if (integer_zerop (bitstart)) { tree scalar_res = gimple_build (, BIT_FIELD_REF, TREE_TYPE (vectype), - vec_lhs_phi, bitsize, bitstart); + vec_lhs_phi, bitsize, bitstart); /* Convert the extracted vector element to the scalar type. */ new_tree = gimple_convert (, lhs_type, scalar_res); @@ -10958,8 +10957,7 @@ vectorizable_live_operation (vec_info *vinfo, stmt_vec_info stmt_info, dest, vectype, ncopies, slp_node, bitsize, tmp_bitstart, tmp_vec_lhs, -lhs_type, restart_loop, -_gsi); +lhs_type, _gsi); if (gimple_phi_num_args (use_stmt) == 1) {
[PATCH, committed] Fortran: fix FE memleak
Dear all, I've committed the attached, simple & obvious patch for a gmp memory leak in gfc_get_nodesc_array_type that shows up when running f951 under valgrind e.g. on testcase gfortran.dg/class_optional_2.f90, after regtesting on x86_64-pc-linux-gnu. (Note that this does not address the underlying issues of pr55978). Thanks, Harald From 93c96e3ad0024a397115aa17bf29c7efc6b535a1 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 3 Jan 2024 20:21:00 +0100 Subject: [PATCH] Fortran: fix FE memleak gcc/fortran/ChangeLog: * trans-types.cc (gfc_get_nodesc_array_type): Clear used gmp variables. --- gcc/fortran/trans-types.cc | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index e6db1c95450..676014e9b98 100644 --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -1795,7 +1795,7 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed, TYPE_LANG_SPECIFIC (type) = TYPE_LANG_SPECIFIC (TREE_TYPE (type)); } - return type; + goto array_type_done; } if (known_stride) @@ -1814,10 +1814,6 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed, layout_type (type); - mpz_clear (offset); - mpz_clear (stride); - mpz_clear (delta); - /* Represent packed arrays as multi-dimensional if they have rank > 1 and with proper bounds, instead of flat arrays. This makes for better debug info. */ @@ -1848,6 +1844,12 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed, GFC_ARRAY_TYPE_P (type) = 1; TYPE_LANG_SPECIFIC (type) = TYPE_LANG_SPECIFIC (TREE_TYPE (type)); } + +array_type_done: + mpz_clear (offset); + mpz_clear (stride); + mpz_clear (delta); + return type; } -- 2.35.3
[PATCH][committed]middle-end: explicitly initialize vec_stmts [PR113132]
Hi All, when configured with --enable-checking=release we get a false positive on the use of vec_stmts as the compiler seems unable to notice it gets initialized through the pass-by-reference. This explicitly initializes the local. Bootstrapped Regtested on x86_64-pc-linux-gnu and no issues. Committed under the obvious rule. Thanks, Tamar gcc/ChangeLog: PR bootstrap/113132 * tree-vect-loop.cc (vect_create_epilog_for_reduction): Initialize vec_stmts; --- inline copy of patch -- diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 88261a3a4f57d5e2124939b069b0e92c57d9abba..f51ae3e719e753059389cf9495b6d65b3b1191cb 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -6207,7 +6207,7 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, exit_bb = loop_exit->dest; exit_gsi = gsi_after_labels (exit_bb); reduc_inputs.create (slp_node ? vec_num : ncopies); - vec vec_stmts; + vec vec_stmts = vNULL; for (unsigned i = 0; i < vec_num; i++) { gimple_seq stmts = NULL; -- diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 88261a3a4f57d5e2124939b069b0e92c57d9abba..f51ae3e719e753059389cf9495b6d65b3b1191cb 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -6207,7 +6207,7 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, exit_bb = loop_exit->dest; exit_gsi = gsi_after_labels (exit_bb); reduc_inputs.create (slp_node ? vec_num : ncopies); - vec vec_stmts; + vec vec_stmts = vNULL; for (unsigned i = 0; i < vec_num; i++) { gimple_seq stmts = NULL;
Go patch committed: Move lowering pass after check types pass
This Go frontend patch moves the lowering pass after the type determination and the type checking passes. This lets us simplify some of the code that determines the type of an expression, which previously had to work correctly both before and after type determination. I'm doing this to help with future generic support. For example, with generics, we can see code like func ident[T any](v T) T { return v } func F() int32 { s := int32(1) return ident(s) } Before this change, we would type check return statements in the lowering pass (see Return_statement::do_lower). With a generic example like the above, that means we have to determine the type of s, and use that to infer the type arguments passed to ident, and use that to determine the result type of ident. That is too much to do at lowering time. Of course we can change the way that return statements work, but similar issues arise with index expressions, the types of closures for function literals, and probably other cases as well. Rather than try to deal with all those cases, we move the lowering pass after type checking. This requires a bunch of changes, notably for determining constant types. We have to add type checking for various constructs that formerly disappeared in the lowering pass. So it's a lot of shuffling. Sorry for the size of the patch. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian patch.txt.bz2 Description: application/bzip
[PATCH COMMITTED] gcc.c-torture/execute/931004-13.c: Fix declaration of main
gcc/testsuite/ * gcc.c-torture/execute/931004-13.c (main): Fix mistakenly swapped int/void types. --- gcc/testsuite/gcc.c-torture/execute/931004-13.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-13.c b/gcc/testsuite/gcc.c-torture/execute/931004-13.c index 8b79679087c..e8c0c81076c 100644 --- a/gcc/testsuite/gcc.c-torture/execute/931004-13.c +++ b/gcc/testsuite/gcc.c-torture/execute/931004-13.c @@ -43,8 +43,8 @@ f (int n, struct tiny x, struct tiny y, struct tiny z, long l) abort (); } -void -main (int) +int +main (void) { struct tiny x[3]; x[0].c = 10; base-commit: 5f1105612b592650566a54846dd5f9ccdfed01a9
Go patch committed: Move Selector_expression up in file
This patch to the Go frontend just moves Selector_expression up in file. This is a mechanical change to expressions.cc. This will make Selector_expression visible to Builtin_call_expression for later work. This produces a very large "git --diff", but "git diff --minimal" is clear. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 02aa322c8cfd3f60fa5a3a0eee4340bb644261fe diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 35b9cd780da..aff74bd74dc 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -3c2a441ef6cafb018bb3cc16f8403ae3d1daf2e1 +e997b0201512110e9c20b1fdfd40014830031047 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index f218731041b..c9177b71174 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -8426,6 +8426,287 @@ Expression::make_bound_method(Expression* expr, const Method* method, return new Bound_method_expression(expr, method, function, location); } +// A general selector. This is a Parser_expression for LEFT.NAME. It +// is lowered after we know the type of the left hand side. + +class Selector_expression : public Parser_expression +{ + public: + Selector_expression(Expression* left, const std::string& name, + Location location) +: Parser_expression(EXPRESSION_SELECTOR, location), + left_(left), name_(name) + { } + + protected: + int + do_traverse(Traverse* traverse) + { return Expression::traverse(>left_, traverse); } + + Expression* + do_lower(Gogo*, Named_object*, Statement_inserter*, int); + + Expression* + do_copy() + { +return new Selector_expression(this->left_->copy(), this->name_, + this->location()); + } + + void + do_dump_expression(Ast_dump_context* ast_dump_context) const; + + private: + Expression* + lower_method_expression(Gogo*); + + // The expression on the left hand side. + Expression* left_; + // The name on the right hand side. + std::string name_; +}; + +// Lower a selector expression once we know the real type of the left +// hand side. + +Expression* +Selector_expression::do_lower(Gogo* gogo, Named_object*, Statement_inserter*, + int) +{ + Expression* left = this->left_; + if (left->is_type_expression()) +return this->lower_method_expression(gogo); + return Type::bind_field_or_method(gogo, left->type(), left, this->name_, + this->location()); +} + +// Lower a method expression T.M or (*T).M. We turn this into a +// function literal. + +Expression* +Selector_expression::lower_method_expression(Gogo* gogo) +{ + Location location = this->location(); + Type* left_type = this->left_->type(); + Type* type = left_type; + const std::string& name(this->name_); + + bool is_pointer; + if (type->points_to() == NULL) +is_pointer = false; + else +{ + is_pointer = true; + type = type->points_to(); +} + + Named_type* nt = type->named_type(); + Struct_type* st = type->struct_type(); + bool is_ambiguous; + Method* method = NULL; + if (nt != NULL) +method = nt->method_function(name, _ambiguous); + else if (st != NULL) +method = st->method_function(name, _ambiguous); + const Typed_identifier* imethod = NULL; + if (method == NULL && !is_pointer) +{ + Interface_type* it = type->interface_type(); + if (it != NULL) + imethod = it->find_method(name); +} + + if ((method == NULL && imethod == NULL) + || (left_type->named_type() != NULL && left_type->points_to() != NULL)) +{ + if (nt != NULL) + { + if (!is_ambiguous) + go_error_at(location, "type %<%s%s%> has no method %<%s%>", + is_pointer ? "*" : "", + nt->message_name().c_str(), + Gogo::message_name(name).c_str()); + else + go_error_at(location, "method %<%s%s%> is ambiguous in type %<%s%>", + Gogo::message_name(name).c_str(), + is_pointer ? "*" : "", + nt->message_name().c_str()); + } + else + { + if (!is_ambiguous) + go_error_at(location, "type has no method %<%s%>", + Gogo::message_name(name).c_str()); + else + go_error_at(location, "method %<%s%> is ambiguous", + Gogo::message_name(name).c_str()); + } + return Expression::make_error(location); +} + + if (method != NULL && !is_pointer && !method->is_value_method()) +{ + go_error_at(location, "method requires pointer (use %<(*%s).%s%>)", + nt->message_name().c_str(), + Gogo::message_name(name).c_str()); + return Expression::make_error(location); +
Go patch committed: Make xx_constant_value methods non-const
This patch to the Go frontend changes the Expression {numeric,string,boolean}_constant_value methods to be non-const. This does not affect anything immediately, but will be useful for later CLs in this series. The only real effect is to Builtin_call_expression::do_export, which remains const and can no longer call numeric_constant_value. But it never needed to call it, as do_export runs after do_lower, and do_lower replaces a constant expression with the actual constant. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 597dba85b3e66a0836dd7442edcc2fda7e0703fc diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index d962c4f5770..35b9cd780da 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -806217827fe30553d535f876f182a9e92f5f648e +3c2a441ef6cafb018bb3cc16f8403ae3d1daf2e1 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index c7b442d3a03..f218731041b 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -846,7 +846,7 @@ class Error_expression : public Expression { return false; } bool - do_numeric_constant_value(Numeric_constant* nc) const + do_numeric_constant_value(Numeric_constant* nc) { nc->set_unsigned_long(NULL, 0); return true; @@ -1992,7 +1992,7 @@ class Boolean_expression : public Expression { return this->val_ == false; } bool - do_boolean_constant_value(bool* val) const + do_boolean_constant_value(bool* val) { *val = this->val_; return true; @@ -2537,7 +2537,7 @@ class Integer_expression : public Expression { return true; } bool - do_numeric_constant_value(Numeric_constant* nc) const; + do_numeric_constant_value(Numeric_constant* nc); Type* do_type(); @@ -2602,7 +2602,7 @@ Integer_expression::do_traverse(Traverse* traverse) // this as a character when appropriate. bool -Integer_expression::do_numeric_constant_value(Numeric_constant* nc) const +Integer_expression::do_numeric_constant_value(Numeric_constant* nc) { if (this->is_character_constant_) nc->set_rune(this->type_, this->val_); @@ -2983,7 +2983,7 @@ class Float_expression : public Expression { return true; } bool - do_numeric_constant_value(Numeric_constant* nc) const + do_numeric_constant_value(Numeric_constant* nc) { nc->set_float(this->type_, this->val_); return true; @@ -3219,7 +3219,7 @@ class Complex_expression : public Expression { return true; } bool - do_numeric_constant_value(Numeric_constant* nc) const + do_numeric_constant_value(Numeric_constant* nc) { nc->set_complex(this->type_, this->val_); return true; @@ -3480,7 +3480,7 @@ Const_expression::do_lower(Gogo* gogo, Named_object*, // Return a numeric constant value. bool -Const_expression::do_numeric_constant_value(Numeric_constant* nc) const +Const_expression::do_numeric_constant_value(Numeric_constant* nc) { if (this->seen_) return false; @@ -3508,7 +3508,7 @@ Const_expression::do_numeric_constant_value(Numeric_constant* nc) const } bool -Const_expression::do_string_constant_value(std::string* val) const +Const_expression::do_string_constant_value(std::string* val) { if (this->seen_) return false; @@ -3523,7 +3523,7 @@ Const_expression::do_string_constant_value(std::string* val) const } bool -Const_expression::do_boolean_constant_value(bool* val) const +Const_expression::do_boolean_constant_value(bool* val) { if (this->seen_) return false; @@ -4180,7 +4180,7 @@ Type_conversion_expression::do_is_static_initializer() const bool Type_conversion_expression::do_numeric_constant_value( -Numeric_constant* nc) const +Numeric_constant* nc) { if (!this->type_->is_numeric_type()) return false; @@ -4192,7 +4192,7 @@ Type_conversion_expression::do_numeric_constant_value( // Return the constant string value if there is one. bool -Type_conversion_expression::do_string_constant_value(std::string* val) const +Type_conversion_expression::do_string_constant_value(std::string* val) { if (this->type_->is_string_type() && this->expr_->type()->is_string_type()) return this->expr_->string_constant_value(val); @@ -4229,7 +4229,7 @@ Type_conversion_expression::do_string_constant_value(std::string* val) const // Return the constant boolean value if there is one. bool -Type_conversion_expression::do_boolean_constant_value(bool* val) const +Type_conversion_expression::do_boolean_constant_value(bool* val) { if (!this->type_->is_boolean_type()) return false; @@ -5141,7 +5141,7 @@ Unary_expression::eval_constant(Operator op, const Numeric_constant* unc, // Return the integral constant value of a unary expression, if it has one. bool -Unary_expression::do_numeric_constant_value(Numeric_constant* nc) const
Go patch committed: Pass Gogo to Runtime::make_call
This Go frontend patches passes the Gogo IR pointer to Runtime::make_call. This is a boilerplate change that doesn't affect compiler output. It's not currently used but will be used by later CLs in this series. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 45a5ab0503569e57883dca4d8e76d83dc3a60ff6 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index d4095637cea..d962c4f5770 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -1c0a7c9338801d15afba7e39109554ed3406654e +806217827fe30553d535f876f182a9e92f5f648e The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 5bea6238def..c7b442d3a03 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -305,8 +305,8 @@ Expression::convert_for_assignment(Gogo* gogo, Type* lhs_type, { // Type to interface conversions have been made explicit early. go_assert(rhs_type->interface_type() != NULL); - return Expression::convert_interface_to_interface(lhs_type, rhs, false, -location); + return Expression::convert_interface_to_interface(gogo, lhs_type, rhs, + false, location); } else if (!are_identical && rhs_type->interface_type() != NULL) return Expression::convert_interface_to_type(gogo, lhs_type, rhs, location); @@ -525,7 +525,8 @@ Expression::get_interface_type_descriptor(Expression* rhs) // interface type. Expression* -Expression::convert_interface_to_interface(Type *lhs_type, Expression* rhs, +Expression::convert_interface_to_interface(Gogo* gogo, Type *lhs_type, + Expression* rhs, bool for_type_guard, Location location) { @@ -558,7 +559,7 @@ Expression::convert_interface_to_interface(Type *lhs_type, Expression* rhs, if (for_type_guard) { // A type assertion fails when converting a nil interface. - first_field = Runtime::make_call(Runtime::ASSERTITAB, location, 2, + first_field = Runtime::make_call(gogo, Runtime::ASSERTITAB, location, 2, lhs_type_expr, rhs_type_expr); } else if (lhs_is_empty) @@ -571,7 +572,7 @@ Expression::convert_interface_to_interface(Type *lhs_type, Expression* rhs, { // A conversion to a non-empty interface may fail, but unlike a // type assertion converting nil will always succeed. - first_field = Runtime::make_call(Runtime::REQUIREITAB, location, 2, + first_field = Runtime::make_call(gogo, Runtime::REQUIREITAB, location, 2, lhs_type_expr, rhs_type_expr); } @@ -610,7 +611,7 @@ Expression::convert_interface_to_type(Gogo* gogo, Type *lhs_type, Expression* rh Expression* cond; if (gogo->need_eqtype()) { -cond = Runtime::make_call(Runtime::EQTYPE, location, +cond = Runtime::make_call(gogo, Runtime::EQTYPE, location, 2, lhs_type_expr, rhs_descriptor); } else { @@ -619,7 +620,7 @@ Expression::convert_interface_to_type(Gogo* gogo, Type *lhs_type, Expression* rh } rhs_descriptor = Expression::get_interface_type_descriptor(rhs); - Expression* panic = Runtime::make_call(Runtime::PANICDOTTYPE, location, + Expression* panic = Runtime::make_call(gogo, Runtime::PANICDOTTYPE, location, 3, lhs_type_expr->copy(), rhs_descriptor, rhs_inter_expr); @@ -719,7 +720,8 @@ Expression::backend_numeric_constant_expression(Translate_context* context, // functions, which will panic. void -Expression::check_bounds(Expression* val, Operator op, Expression* bound, +Expression::check_bounds(Gogo* gogo, Expression* val, Operator op, +Expression* bound, Runtime::Function code, Runtime::Function code_u, Runtime::Function code_extend, @@ -813,7 +815,7 @@ Expression::check_bounds(Expression* val, Operator op, Expression* bound, } Expression* ignore = Expression::make_boolean(true, loc); - Expression* crash = Runtime::make_call(c, loc, 2, + Expression* crash = Runtime::make_call(gogo, c, loc, 2, val->copy(), bound->copy()); Expression* cond = Expression::make_conditional(check, ignore, crash, loc); inserter->insert(Statement::make_statement(cond, true)); @@ -3916,7 +3918,7 @@ Type_conversion_expression::do_traverse(Traverse* traverse) // from slice to pointer-to-array, as they can panic. Expression*
Go patch committed: Add Expression::is_untyped method
This Go frontend patches adds an Expression::is_untyped method. This method is not currently used by anything, but it will be used by later changes in this series. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian ac50e9b72bf9bb6d5b28096bb164fb050db6e290 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 0f961157dfd..d4095637cea 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -081ec9824a74ec9d82628d8d2f6b9a7a4c35a529 +1c0a7c9338801d15afba7e39109554ed3406654e The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 273831fabf3..5bea6238def 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -201,6 +201,19 @@ Expression::report_error(const char* msg) this->set_is_error(); } +// A convenience function for handling a type in do_is_untyped. If +// TYPE is not abstract, return false. Otherwise set *PTYPE to TYPE +// and return true. + +bool +Expression::is_untyped_type(Type* type, Type** ptype) +{ + if (!type->is_abstract()) +return false; + *ptype = type; + return true; +} + // Set types of variables and constants. This is implemented by the // child class. @@ -826,6 +839,10 @@ class Error_expression : public Expression do_is_constant() const { return true; } + bool + do_is_untyped(Type**) const + { return false; } + bool do_numeric_constant_value(Numeric_constant* nc) const { @@ -1965,6 +1982,9 @@ class Boolean_expression : public Expression do_is_constant() const { return true; } + bool + do_is_untyped(Type**) const; + bool do_is_zero_value() const { return this->val_ == false; } @@ -2023,6 +2043,15 @@ Boolean_expression::do_traverse(Traverse* traverse) return TRAVERSE_CONTINUE; } +bool +Boolean_expression::do_is_untyped(Type** ptype) const +{ + if (this->type_ != NULL) +return Expression::is_untyped_type(this->type_, ptype); + *ptype = Type::make_boolean_type(); + return true; +} + // Get the type. Type* @@ -2096,6 +2125,15 @@ String_expression::do_traverse(Traverse* traverse) return TRAVERSE_CONTINUE; } +bool +String_expression::do_is_untyped(Type** ptype) const +{ + if (this->type_ != NULL) +return Expression::is_untyped_type(this->type_, ptype); + *ptype = Type::make_string_type(); + return true; +} + // Get the type. Type* @@ -2485,6 +2523,9 @@ class Integer_expression : public Expression do_is_constant() const { return true; } + bool + do_is_untyped(Type**) const; + bool do_is_zero_value() const { return mpz_sgn(this->val_) == 0; } @@ -2568,6 +2609,18 @@ Integer_expression::do_numeric_constant_value(Numeric_constant* nc) const return true; } +bool +Integer_expression::do_is_untyped(Type** ptype) const +{ + if (this->type_ != NULL) +return Expression::is_untyped_type(this->type_, ptype); + if (this->is_character_constant_) +*ptype = Type::make_abstract_character_type(); + else +*ptype = Type::make_abstract_integer_type(); + return true; +} + // Return the current type. If we haven't set the type yet, we return // an abstract integer type. @@ -2913,6 +2966,9 @@ class Float_expression : public Expression do_is_constant() const { return true; } + bool + do_is_untyped(Type**) const; + bool do_is_zero_value() const { @@ -2979,6 +3035,15 @@ Float_expression::do_traverse(Traverse* traverse) return TRAVERSE_CONTINUE; } +bool +Float_expression::do_is_untyped(Type** ptype) const +{ + if (this->type_ != NULL) +return Expression::is_untyped_type(this->type_, ptype); + *ptype = Type::make_abstract_float_type(); + return true; +} + // Return the current type. If we haven't set the type yet, we return // an abstract float type. @@ -3135,6 +3200,9 @@ class Complex_expression : public Expression do_is_constant() const { return true; } + bool + do_is_untyped(Type**) const; + bool do_is_zero_value() const { @@ -3205,6 +3273,15 @@ Complex_expression::do_traverse(Traverse* traverse) return TRAVERSE_CONTINUE; } +bool +Complex_expression::do_is_untyped(Type** ptype) const +{ + if (this->type_ != NULL) +return Expression::is_untyped_type(this->type_, ptype); + *ptype = Type::make_abstract_complex_type(); + return true; +} + // Return the current type. If we haven't set the type yet, we return // an abstract complex type. @@ -3458,6 +3535,21 @@ Const_expression::do_boolean_constant_value(bool* val) const return ok; } +// Whether this is untyped. + +bool +Const_expression::do_is_untyped(Type** ptype) const +{ + if (this->type_ != NULL) +return Expression::is_untyped_type(this->type_, ptype); + + Named_constant* nc = this->constant_->const_value(); + if (nc->type() != NULL) +return Expression::is_untyped_type(nc->type(), ptype); + +
libgo patch committed: Add missing type conversion
This libgo patch adds a missing type conversion. The gofrontend incorrectly accepted code that was missing a type conversion. The test case for this is bug518.go in https://go.dev/cl/536537. Future CLs in this series will detect the type error. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 2621bd1bac614b63e52d0deb4ab2ff287a9fafa8 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 398d2671b64..0f961157dfd 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -c201fa2a684ada551ca9a0825a3075a0a69498de +081ec9824a74ec9d82628d8d2f6b9a7a4c35a529 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/go/syscall/errstr.go b/libgo/go/syscall/errstr.go index 9f688e2a0c7..02f228adc59 100644 --- a/libgo/go/syscall/errstr.go +++ b/libgo/go/syscall/errstr.go @@ -24,7 +24,7 @@ func Errstr(errnum int) string { } return string(b[:i]) } - if errno != ERANGE { + if Errno(errno) != ERANGE { return "strerror_r failure" } }
Go patch committed: Remove the traverse_assignments code
This patch to the Go frontend removes the traverse_assignments support. The last caller was removed in https://go.dev/cl/18261 in 2016. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian a6e74b0b3316f3f0b2096d6a175c31bed58ae4ed diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index d31fb336e41..398d2671b64 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -75b08794cb1485c955d13784c53a89174764af55 +c201fa2a684ada551ca9a0825a3075a0a69498de The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc index b43f1393e33..91c7627a0e3 100644 --- a/gcc/go/gofrontend/statements.cc +++ b/gcc/go/gofrontend/statements.cc @@ -64,16 +64,6 @@ Statement::traverse_contents(Traverse* traverse) return this->do_traverse(traverse); } -// Traverse assignments. - -bool -Statement::traverse_assignments(Traverse_assignments* tassign) -{ - if (this->classification_ == STATEMENT_ERROR) -return false; - return this->do_traverse_assignments(tassign); -} - // Traverse an expression in a statement. This is a helper function // for child classes. @@ -288,17 +278,6 @@ Variable_declaration_statement::do_traverse(Traverse*) return TRAVERSE_CONTINUE; } -// Traverse the assignments in a variable declaration. Note that this -// traversal is different from the usual traversal. - -bool -Variable_declaration_statement::do_traverse_assignments( -Traverse_assignments* tassign) -{ - tassign->initialize_variable(this->var_); - return true; -} - // Lower the variable's initialization expression. Statement* @@ -510,17 +489,6 @@ Temporary_statement::do_traverse(Traverse* traverse) return this->traverse_expression(traverse, >init_); } -// Traverse assignments. - -bool -Temporary_statement::do_traverse_assignments(Traverse_assignments* tassign) -{ - if (this->init_ == NULL) -return false; - tassign->value(>init_, true, true); - return true; -} - // Determine types. void @@ -889,13 +857,6 @@ Assignment_statement::do_traverse(Traverse* traverse) return this->traverse_expression(traverse, >rhs_); } -bool -Assignment_statement::do_traverse_assignments(Traverse_assignments* tassign) -{ - tassign->assignment(>lhs_, >rhs_); - return true; -} - // Lower an assignment to a map index expression to a runtime function // call. Mark some slice assignments as not requiring a write barrier. @@ -1212,10 +1173,6 @@ class Assignment_operation_statement : public Statement int do_traverse(Traverse*); - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -1365,10 +1322,6 @@ class Tuple_assignment_statement : public Statement int do_traverse(Traverse* traverse); - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -1511,10 +1464,6 @@ public: int do_traverse(Traverse* traverse); - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -1719,10 +1668,6 @@ class Tuple_receive_assignment_statement : public Statement int do_traverse(Traverse* traverse); - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -1862,10 +1807,6 @@ class Tuple_type_guard_assignment_statement : public Statement int do_traverse(Traverse*); - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -2277,10 +2218,6 @@ class Inc_dec_statement : public Statement do_traverse(Traverse* traverse) { return this->traverse_expression(traverse, >expr_); } - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -2412,18 +2349,6 @@ Thunk_statement::do_traverse(Traverse* traverse) return this->traverse_expression(traverse, >call_); } -// We implement traverse_assignment for a thunk statement because it -// effectively copies the function call. - -bool -Thunk_statement::do_traverse_assignments(Traverse_assignments* tassign) -{ - Expression* fn = this->call_->call_expression()->fn(); - Expression* fn2 = fn; - tassign->value(, true, false); - return true; -} - // Determine types in a thunk statement. void @@ -3148,23 +3073,6 @@ Statement::make_defer_statement(Call_expression* call, // Class Return_statement. -// Traverse assignments. We treat each return value as a top level -// RHS in an expression. - -bool
Go patch committed: Remove name_ field from Type_switch_statement
This patch to the Go frontend removes the name_ field from the Type_switch_statement class. It's not used for anything. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 1a1fba1e25779247a4969789885ce80b7b4a2359 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 28683d6852b..d31fb336e41 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -06ada1f2ab9b05e54641438db28c557c6900b2a3 +75b08794cb1485c955d13784c53a89174764af55 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index c93d82bba39..d7410588347 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -4932,7 +4932,7 @@ Parse::type_switch_body(Label* label, const Type_switch& type_switch, } Type_switch_statement* statement = - Statement::make_type_switch_statement(var_name, init, location); + Statement::make_type_switch_statement(init, location); this->push_break_statement(statement, label); Type_case_clauses* case_clauses = new Type_case_clauses(); diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc index 33b568e3eeb..b43f1393e33 100644 --- a/gcc/go/gofrontend/statements.cc +++ b/gcc/go/gofrontend/statements.cc @@ -5046,8 +5046,6 @@ Type_switch_statement::do_dump_statement(Ast_dump_context* ast_dump_context) { ast_dump_context->print_indent(); ast_dump_context->ostream() << "switch "; - if (!this->name_.empty()) -ast_dump_context->ostream() << this->name_ << " = "; ast_dump_context->dump_expression(this->expr_); ast_dump_context->ostream() << " .(type)"; if (ast_dump_context->dump_subblocks()) @@ -5062,10 +5060,9 @@ Type_switch_statement::do_dump_statement(Ast_dump_context* ast_dump_context) // Make a type switch statement. Type_switch_statement* -Statement::make_type_switch_statement(const std::string& name, Expression* expr, - Location location) +Statement::make_type_switch_statement(Expression* expr, Location location) { - return new Type_switch_statement(name, expr, location); + return new Type_switch_statement(expr, location); } // Class Send_statement. diff --git a/gcc/go/gofrontend/statements.h b/gcc/go/gofrontend/statements.h index eb795c4b920..9ef63cb9a61 100644 --- a/gcc/go/gofrontend/statements.h +++ b/gcc/go/gofrontend/statements.h @@ -253,7 +253,7 @@ class Statement // Make a type switch statement. static Type_switch_statement* - make_type_switch_statement(const std::string&, Expression*, Location); + make_type_switch_statement(Expression*, Location); // Make a send statement. static Send_statement* @@ -2191,10 +2191,9 @@ class Type_case_clauses class Type_switch_statement : public Statement { public: - Type_switch_statement(const std::string& name, Expression* expr, - Location location) + Type_switch_statement(Expression* expr, Location location) : Statement(STATEMENT_TYPE_SWITCH, location), - name_(name), expr_(expr), clauses_(NULL), break_label_(NULL) + expr_(expr), clauses_(NULL), break_label_(NULL) { } // Add the clauses. @@ -2227,10 +2226,7 @@ class Type_switch_statement : public Statement do_may_fall_through() const; private: - // The name of the variable declared in the type switch guard. Empty if there - // is no variable declared. - std::string name_; - // The expression we are switching on if there is no variable. + // The expression we are switching on. Expression* expr_; // The type case clauses. Type_case_clauses* clauses_;
Go patch committed: pass Gogo to more passes
This patch to the G frontend passes a pointer to the Gogo IR to the determine types pass and the type verification pass. This is a straight refactoring that does not change the compiler behavior. This is in preparation for future CLs that rearrange the pass ordering. This introduces one new call to go_get_gogo, which will be removed in a future CL. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian b513aa235d6e5d7e2a36ee789c60891fce873340 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index d24054e0d93..28683d6852b 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -967a215d6419c3db58f8f59a0c252c458abce395 +06ada1f2ab9b05e54641438db28c557c6900b2a3 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index d276bd811cc..273831fabf3 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -205,18 +205,18 @@ Expression::report_error(const char* msg) // child class. void -Expression::determine_type(const Type_context* context) +Expression::determine_type(Gogo* gogo, const Type_context* context) { - this->do_determine_type(context); + this->do_determine_type(gogo, context); } // Set types when there is no context. void -Expression::determine_type_no_context() +Expression::determine_type_no_context(Gogo* gogo) { Type_context context; - this->do_determine_type(); + this->do_determine_type(gogo, ); } // Return true if two expressions refer to the same variable or struct @@ -842,7 +842,7 @@ class Error_expression : public Expression { return Type::make_error_type(); } void - do_determine_type(const Type_context*) + do_determine_type(Gogo*, const Type_context*) { } Expression* @@ -897,7 +897,7 @@ Type_expression : public Expression { return this->type_; } void - do_determine_type(const Type_context*) + do_determine_type(Gogo*, const Type_context*) { } void @@ -998,10 +998,10 @@ Var_expression::do_type() // Determine the type of a reference to a variable. void -Var_expression::do_determine_type(const Type_context*) +Var_expression::do_determine_type(Gogo* gogo, const Type_context*) { if (this->variable_->is_variable()) -this->variable_->var_value()->determine_type(); +this->variable_->var_value()->determine_type(gogo); } // Something takes the address of this variable. This means that we @@ -1303,9 +1303,10 @@ Set_and_use_temporary_expression::do_type() void Set_and_use_temporary_expression::do_determine_type( +Gogo* gogo, const Type_context* context) { - this->expr_->determine_type(context); + this->expr_->determine_type(gogo, context); } // Take the address. @@ -1378,7 +1379,7 @@ class Sink_expression : public Expression do_type(); void - do_determine_type(const Type_context*); + do_determine_type(Gogo*, const Type_context*); Expression* do_copy() @@ -1410,7 +1411,7 @@ Sink_expression::do_type() // Determine the type of a sink expression. void -Sink_expression::do_determine_type(const Type_context* context) +Sink_expression::do_determine_type(Gogo*, const Type_context* context) { if (context->type != NULL) this->type_ = context->type; @@ -1805,7 +1806,7 @@ class Func_code_reference_expression : public Expression { return Type::make_pointer_type(Type::make_void_type()); } void - do_determine_type(const Type_context*) + do_determine_type(Gogo*, const Type_context*) { } Expression* @@ -1983,7 +1984,7 @@ class Boolean_expression : public Expression do_type(); void - do_determine_type(const Type_context*); + do_determine_type(Gogo*, const Type_context*); Expression* do_copy() @@ -2035,7 +2036,7 @@ Boolean_expression::do_type() // Set the type from the context. void -Boolean_expression::do_determine_type(const Type_context* context) +Boolean_expression::do_determine_type(Gogo*, const Type_context* context) { if (this->type_ != NULL && !this->type_->is_abstract()) ; @@ -2108,7 +2109,7 @@ String_expression::do_type() // Set the type from the context. void -String_expression::do_determine_type(const Type_context* context) +String_expression::do_determine_type(Gogo*, const Type_context* context) { if (this->type_ != NULL && !this->type_->is_abstract()) ; @@ -2278,7 +2279,7 @@ class String_info_expression : public Expression do_type(); void - do_determine_type(const Type_context*) + do_determine_type(Gogo*, const Type_context*) { go_unreachable(); } Expression* @@ -2390,7 +2391,7 @@ class String_value_expression : public Expression { return Type::make_string_type(); } void - do_determine_type(const Type_context*) + do_determine_type(Gogo*, const Type_context*) { go_unreachable(); } Expression* @@ -2499,7 +2500,7 @@ class Integer_expression :
[PATCH/committed] sim: add distclean dep for gnulib
ChangeLog: * Makefile.def: Add distclean-sim dependency on distclean-gnulib. * Makefile.in: Regenerate. --- Makefile.def | 1 + Makefile.in | 1 + 2 files changed, 2 insertions(+) diff --git a/Makefile.def b/Makefile.def index 870150183b9a..15c068e4ac40 100644 --- a/Makefile.def +++ b/Makefile.def @@ -612,6 +612,7 @@ dependencies = { module=check-libctf; on=all-ld; }; // gdb and gdbserver. dependencies = { module=distclean-gnulib; on=distclean-gdb; }; dependencies = { module=distclean-gnulib; on=distclean-gdbserver; }; +dependencies = { module=distclean-gnulib; on=distclean-sim; }; // Warning, these are not well tested. dependencies = { module=all-bison; on=all-intl; }; diff --git a/Makefile.in b/Makefile.in index e0e3c4c8fe80..1dda62a03032 100644 --- a/Makefile.in +++ b/Makefile.in @@ -66891,6 +66891,7 @@ check-stageautoprofile-libctf: maybe-all-stageautoprofile-ld check-stageautofeedback-libctf: maybe-all-stageautofeedback-ld distclean-gnulib: maybe-distclean-gdb distclean-gnulib: maybe-distclean-gdbserver +distclean-gnulib: maybe-distclean-sim all-bison: maybe-all-build-texinfo all-flex: maybe-all-build-bison all-flex: maybe-all-m4 -- 2.42.0
godump.cc patch committed: Handle _BitInt
This patch to godump.cc adds support for BITINT_TYPE. Bootstrapped and ran godump and Go tests on x86_64-pc-linux-gnu. Committed to mainline. Ian gcc/ PR go/111310 * godump.cc (go_format_type): Handle BITINT_TYPE. gcc/testsuite/ PR go/111310 * gcc.misc-tests/godump-1.c: Add _BitInt test cases. diff --git a/gcc/godump.cc b/gcc/godump.cc index 0893d5fbc97..bdd2d108d76 100644 --- a/gcc/godump.cc +++ b/gcc/godump.cc @@ -760,6 +760,25 @@ go_format_type (class godump_container *container, tree type, } break; +case BITINT_TYPE: + { + const char *s; + char buf[100]; + + s = go_get_uinttype_for_precision (TYPE_PRECISION (type), + TYPE_UNSIGNED (type)); + if (s == NULL) + { + snprintf (buf, sizeof buf, "INVALID-bitint-%u%s", + TYPE_PRECISION (type), + TYPE_UNSIGNED (type) ? "u" : ""); + s = buf; + ret = false; + } + obstack_grow (ob, s, strlen(s)); + } + break; + case REAL_TYPE: { const char *s; diff --git a/gcc/testsuite/gcc.misc-tests/godump-1.c b/gcc/testsuite/gcc.misc-tests/godump-1.c index 95dabdc0e4c..f359a657827 100644 --- a/gcc/testsuite/gcc.misc-tests/godump-1.c +++ b/gcc/testsuite/gcc.misc-tests/godump-1.c @@ -234,6 +234,17 @@ const char cc_v1; cc_t cc_v2; /* { dg-final { scan-file godump-1.out "(?n)^var _cc_v2 _cc_t$" } } */ +_BitInt(32) b32_v; +/* { dg-final { scan-file godump-1.out "(?n)^var _b32_v int32$" } } */ + +_BitInt(64) b64_v; +/* { dg-final { scan-file godump-1.out "(?n)^var _b64_v int64$" } } */ + +unsigned _BitInt(32) b32u_v; +/* { dg-final { scan-file godump-1.out "(?n)^var _b32u_v uint32$" } } */ + +_BitInt(33) b33_v; +/* { dg-final { scan-file godump-1.out "(?n)^// var _b33_v INVALID-bitint-33$" } } */ /*** pointer and array types ***/ typedef void *vp_t;
libgo patch committed: permit $AR to include options
This libgo patch changes the go tool to permit the AR environment variable to include options. This mirrors the way it already handles the CC environment variable. This ports https://go.dev/cl/526275 to the gofrontend repo. This is needed for gccgo testing because the top-level GCC Makefile now passes a --plugin option to ar if it supports one. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian dab7163feedc99bd94549ee490031f86f8d0a6ca diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 83ab3e2d64c..30710e856cb 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -d04b024021bb7dbaa434a6d902bd12beb08e315f +53cdfab53ce79d8dfc1df01a696d4ffc43f17c3d The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/go/cmd/go/internal/work/gccgo.go b/libgo/go/cmd/go/internal/work/gccgo.go index c1026c71e01..3e07f8791eb 100644 --- a/libgo/go/cmd/go/internal/work/gccgo.go +++ b/libgo/go/cmd/go/internal/work/gccgo.go @@ -45,12 +45,8 @@ func (gccgoToolchain) linker() string { return GccgoBin } -func (gccgoToolchain) ar() string { - ar := cfg.Getenv("AR") - if ar == "" { - ar = "ar" - } - return ar +func (gccgoToolchain) ar() []string { + return envList("AR", "ar") } func checkGccgoBin() {
Re: [PATCH][committed] RISC-V: Add multiarch support on riscv-linux-gnu
On 8/22/23 12:03, Palmer Dabbelt wrote: On Tue, 22 Aug 2023 10:39:38 PDT (-0700), Jeff Law wrote: The docs seem to suggest that we should have a multarch-compatible MULTILIB_OSDIRNAMES as we support both multilib and multiarch: @code{MULTIARCH_DIRNAME} is not used for configurations that support both multilib and multiarch. In that case, multiarch names are encoded in @code{MULTILIB_OSDIRNAMES} instead. It's not clear if "supports" there actually means "enabled", as IIUC none of the distros actually ship multilib. So maybe this can't manifest and we should fix the docs? Debian explicitly disables multilibs for RISC-V, Ubuntu almost certainly just follows that. Fedora and its relatives don't use multiarch. Or maybe something like this just does it? Maybe, but we'd really want/need to test it :-) diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux index a6f64f88d25..00e382db0f8 100644 --- a/gcc/config/riscv/t-linux +++ b/gcc/config/riscv/t-linux @@ -1,5 +1,5 @@ # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/ MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) -MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) +MULTILIB_OSDIRNAMES := $(patsubst lib64%:rv64%-linux-gnu,$(patsubst lib32%:rv32%-linux-gnu,../lib32,$(MULTILIB_DIRNAMES))) MULTIARCH_DIRNAME := $(call if_multiarch,$(firstword $(subst -, ,$(target)))-linux-gnu) I have no idea how to test multiarch+multilib, though. Is there a way to just autoconf error that out as unsupported until someone wants it? I'm not sure either. It might be as simple as bootstrapping on a Debian native with a small set of rv64 multilibs. Jeff
Re: [PATCH][committed] RISC-V: Add multiarch support on riscv-linux-gnu
On Tue, 22 Aug 2023 10:39:38 PDT (-0700), Jeff Law wrote: This adds multiarch support to the RISC-V port so that bootstraps work with Debian out-of-the-box. Without this patch the stage1 compiler is unable to find headers/libraries when building the stage1 runtime. This is functionally (and possibly textually) equivalent to Debian's fix for the same problem. gcc/ * config/riscv/t-linux: Add MULTIARCH_DIRNAME. Pushed to the trunk on Raphael's behalf. Jeff commit 47f95bc4be4eb14730ab3eaaaf8f6e71fda47690 Author: Raphael Moreira Zinsly Date: Tue Aug 22 11:37:04 2023 -0600 RISC-V: Add multiarch support on riscv-linux-gnu This adds multiarch support to the RISC-V port so that bootstraps work with Debian out-of-the-box. Without this patch the stage1 compiler is unable to find headers/libraries when building the stage1 runtime. This is functionally (and possibly textually) equivalent to Debian's fix for the same problem. gcc/ * config/riscv/t-linux: Add MULTIARCH_DIRNAME. diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux index 216d2776a18..a6f64f88d25 100644 --- a/gcc/config/riscv/t-linux +++ b/gcc/config/riscv/t-linux @@ -1,3 +1,5 @@ # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/ MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) + +MULTIARCH_DIRNAME := $(call if_multiarch,$(firstword $(subst -, ,$(target)))-linux-gnu) The docs seem to suggest that we should have a multarch-compatible MULTILIB_OSDIRNAMES as we support both multilib and multiarch: @code{MULTIARCH_DIRNAME} is not used for configurations that support both multilib and multiarch. In that case, multiarch names are encoded in @code{MULTILIB_OSDIRNAMES} instead. It's not clear if "supports" there actually means "enabled", as IIUC none of the distros actually ship multilib. So maybe this can't manifest and we should fix the docs? Or maybe something like this just does it? diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux index a6f64f88d25..00e382db0f8 100644 --- a/gcc/config/riscv/t-linux +++ b/gcc/config/riscv/t-linux @@ -1,5 +1,5 @@ # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/ MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) -MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) +MULTILIB_OSDIRNAMES := $(patsubst lib64%:rv64%-linux-gnu,$(patsubst lib32%:rv32%-linux-gnu,../lib32,$(MULTILIB_DIRNAMES))) MULTIARCH_DIRNAME := $(call if_multiarch,$(firstword $(subst -, ,$(target)))-linux-gnu) I have no idea how to test multiarch+multilib, though. Is there a way to just autoconf error that out as unsupported until someone wants it?
[PATCH][committed] RISC-V: Add multiarch support on riscv-linux-gnu
This adds multiarch support to the RISC-V port so that bootstraps work with Debian out-of-the-box. Without this patch the stage1 compiler is unable to find headers/libraries when building the stage1 runtime. This is functionally (and possibly textually) equivalent to Debian's fix for the same problem. gcc/ * config/riscv/t-linux: Add MULTIARCH_DIRNAME. Pushed to the trunk on Raphael's behalf. Jeff commit 47f95bc4be4eb14730ab3eaaaf8f6e71fda47690 Author: Raphael Moreira Zinsly Date: Tue Aug 22 11:37:04 2023 -0600 RISC-V: Add multiarch support on riscv-linux-gnu This adds multiarch support to the RISC-V port so that bootstraps work with Debian out-of-the-box. Without this patch the stage1 compiler is unable to find headers/libraries when building the stage1 runtime. This is functionally (and possibly textually) equivalent to Debian's fix for the same problem. gcc/ * config/riscv/t-linux: Add MULTIARCH_DIRNAME. diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux index 216d2776a18..a6f64f88d25 100644 --- a/gcc/config/riscv/t-linux +++ b/gcc/config/riscv/t-linux @@ -1,3 +1,5 @@ # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/ MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) + +MULTIARCH_DIRNAME := $(call if_multiarch,$(firstword $(subst -, ,$(target)))-linux-gnu)
[PATCH, committed] Testsuite, darwin: Fix analyzer testcases
Committed as obvious, fixing three more darwin-specific failures in analyzer testsuite. This fixes: FAIL: gcc.dg/plugin/taint-CVE-2011-0521-5.c -fplugin=./analyzer_kernel_plugin.so (test for warnings, line 39) FAIL: gcc.dg/plugin/taint-CVE-2011-0521-6.c -fplugin=./analyzer_kernel_plugin.so (test for warnings, line 36) XPASS: gcc.dg/plugin/taint-CVE-2011-0521-5-fixed.c -fplugin=./analyzer_kernel_plugin.so (test for bogus messages, line 39) Committed to trunk, FX 0001-Testsuite-darwin-Fix-analyzer-testcases.patch Description: Binary data
[PATCH,committed] Fortran: fix memleak for character,value dummy of bind(c) procedure [PR110360]
Dear all, the attached simple patch fixes a memleak in the frontend when a character literal is passed to a character,value dummy of a bind(c) procedure, by relying on gfc_replace_expr to do the cleanup. (This can be tested e.g. with gfortran.dg/bind_c_usage_13.f03 and running f951 under valgrind). The patch was OK'ed in the PR by Mikael. Pushed as r14-3254-g9ade70bb86c874 after partial regtesting on x86_64-pc-linux-gnu. Thanks, Harald From 9ade70bb86c8744f4416a48bb69cf4705f00905a Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 16 Aug 2023 22:00:49 +0200 Subject: [PATCH] Fortran: fix memleak for character,value dummy of bind(c) procedure [PR110360] Testcase gfortran.dg/bind_c_usage_13.f03 exhibited a memleak in the frontend occuring when passing a character literal to a character,value dummy of a bind(c) procedure, due to a missing cleanup in the conversion of the actual argument expression. Reduced testcase: program p interface subroutine val_c (c) bind(c) use iso_c_binding, only: c_char character(len=1,kind=c_char), value :: c end subroutine val_c end interface call val_c ("A") end gcc/fortran/ChangeLog: PR fortran/110360 * trans-expr.cc (conv_scalar_char_value): Use gfc_replace_expr to avoid leaking replaced gfc_expr. --- gcc/fortran/trans-expr.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 52cd88f5b00..6e9e76cd5c9 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -4044,8 +4044,9 @@ conv_scalar_char_value (gfc_symbol *sym, gfc_se *se, gfc_expr **expr) gfc_typespec ts; gfc_clear_ts (); - *expr = gfc_get_int_expr (gfc_default_character_kind, NULL, -(*expr)->value.character.string[0]); + gfc_expr *tmp = gfc_get_int_expr (gfc_default_character_kind, NULL, + (*expr)->value.character.string[0]); + gfc_replace_expr (*expr, tmp); } else if (se != NULL && (*expr)->expr_type == EXPR_VARIABLE) { -- 2.35.3
[PATCH][COMMITTED] doc: Fix spelling in arm_v8_1m_main_cde_mve_fp
Fix spelling mistakes introduced by my previous patch in this area. Committed as obvious. 2023-08-01 Christophe Lyon gcc/ * doc/sourcebuild.texi (arm_v8_1m_main_cde_mve_fp): Fix spelling. --- gcc/doc/sourcebuild.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index e5d15d67253..1a78b3c1abb 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2186,12 +2186,12 @@ the Custom Datapath Extension (CDE) and floating-point (VFP). Some multilibs may be incompatible with these options. @item arm_v8_1m_main_cde_mve -Arm target supports options to generate instructions from Arm.1-M with +Arm target supports options to generate instructions from Armv8.1-M with the Custom Datapath Extension (CDE) and M-Profile Vector Extension (MVE). Some multilibs may be incompatible with these options. @item arm_v8_1m_main_cde_mve_fp -ARM target supports options to generate instructions from ARMv8.1-M +Arm target supports options to generate instructions from Armv8.1-M with the Custom Datapath Extension (CDE) and M-Profile Vector Extension (MVE) with floating-point support. Some multilibs may be incompatible with these options. -- 2.34.1
libbacktrace patch committed
This libbacktrace patch, based on one by Andres Freund, uses the _pgmptr variable declared on Windows to find the executable file name if none is specified. Bootstrapped and ran libbacktrace testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Patch from Andres Freund: * configure.ac: Check for _pgmptr declaration. * fileline.c (fileline_initialize): Check for _pgmfptr before /proc/self/exec. * configure, config.h.in: Regenerate. a349ba16f18b66b70c7a1bdb1ab5c5b6247676da diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac index 39e6bf41e35..72ff2b30053 100644 --- a/libbacktrace/configure.ac +++ b/libbacktrace/configure.ac @@ -407,6 +407,9 @@ if test "$have_getexecname" = "yes"; then AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.]) fi +# Check for _pgmptr variable, contains the executable filename on windows +AC_CHECK_DECLS([_pgmptr]) + # Check for sysctl definitions. AC_CACHE_CHECK([for KERN_PROC], diff --git a/libbacktrace/fileline.c b/libbacktrace/fileline.c index 674bf33cdcf..0e560b44e7a 100644 --- a/libbacktrace/fileline.c +++ b/libbacktrace/fileline.c @@ -155,6 +155,16 @@ macho_get_executable_path (struct backtrace_state *state, #endif /* !defined (HAVE_MACH_O_DYLD_H) */ +#if HAVE_DECL__PGMPTR + +#define windows_executable_filename() _pgmptr + +#else /* !HAVE_DECL__PGMPTR */ + +#define windows_executable_filename() NULL + +#endif /* !HAVE_DECL__PGMPTR */ + /* Initialize the fileline information from the executable. Returns 1 on success, 0 on failure. */ @@ -192,7 +202,7 @@ fileline_initialize (struct backtrace_state *state, descriptor = -1; called_error_callback = 0; - for (pass = 0; pass < 8; ++pass) + for (pass = 0; pass < 9; ++pass) { int does_not_exist; @@ -205,23 +215,28 @@ fileline_initialize (struct backtrace_state *state, filename = getexecname (); break; case 2: - filename = "/proc/self/exe"; + /* Test this before /proc/self/exe, as the latter exists but points +to the wine binary (and thus doesn't work). */ + filename = windows_executable_filename (); break; case 3: - filename = "/proc/curproc/file"; + filename = "/proc/self/exe"; break; case 4: + filename = "/proc/curproc/file"; + break; + case 5: snprintf (buf, sizeof (buf), "/proc/%ld/object/a.out", (long) getpid ()); filename = buf; break; - case 5: + case 6: filename = sysctl_exec_name1 (state, error_callback, data); break; - case 6: + case 7: filename = sysctl_exec_name2 (state, error_callback, data); break; - case 7: + case 8: filename = macho_get_executable_path (state, error_callback, data); break; default:
Go patch committed: Support -fgo-importcfg
The gc Go compiler has a -importcfg option that takes a file that provides a mapping from import paths to the files that satisfy those imports. This is used by the go build tool to let the compiler read imported packages directly out of the build cache. Without this option the go build tool has to construct a tree of files to provide the same mapping in the file system. This patch to the Go frontend adds a -fgo-importcfg option that does the same thing. The go build tool already uses this option if it is supported; with this patch, it is supported. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian * lang.opt (fgo-importcfg): New option. * go-c.h (struct go_create_gogo_args): Add importcfg field. * go-lang.cc (go_importcfg): New static variable. (go_langhook_init): Set args.importcfg. (go_langhook_handle_option): Handle -fgo-importcfg. * gccgo.texi (Invoking gccgo): Document -fgo-importcfg. cd4f91ed9786caf207d6d68bf2e64f986ed19735 diff --git a/gcc/go/gccgo.texi b/gcc/go/gccgo.texi index 4ab1a76818f..90651af8384 100644 --- a/gcc/go/gccgo.texi +++ b/gcc/go/gccgo.texi @@ -271,6 +271,14 @@ pattern to a list of file names, and @code{Files} maps each file name to a full path to the file. This option is intended for use by the @command{go} command to implement @code{//go:embed}. +@cindex @option{-fgo-importcfg} +@item -fgo-importcfg=@var{file} +Identify a file that provides mappings for import package paths found +in the Go source files. The file can contain two commands: +@code{importpath} to rename import paths for vendoring and +@code{packagefile} to map from package path to files containing export +data. This option is intended for use by the @command{go} command. + @cindex @option{-g for gccgo} @item -g This is the standard @command{gcc} option (@pxref{Debugging Options, , diff --git a/gcc/go/go-c.h b/gcc/go/go-c.h index c6050382aa8..6a2b57b3b44 100644 --- a/gcc/go/go-c.h +++ b/gcc/go/go-c.h @@ -41,6 +41,7 @@ struct go_create_gogo_args const char* prefix; const char* relative_import_path; const char* c_header; + const char* importcfg; const char* embedcfg; Backend* backend; Linemap* linemap; diff --git a/gcc/go/go-lang.cc b/gcc/go/go-lang.cc index c6c147b20a5..e85a4bfe949 100644 --- a/gcc/go/go-lang.cc +++ b/gcc/go/go-lang.cc @@ -90,6 +90,7 @@ static const char *go_prefix = NULL; static const char *go_relative_import_path = NULL; static const char *go_c_header = NULL; static const char *go_embedcfg = NULL; +static const char *go_importcfg = NULL; /* Language hooks. */ @@ -111,6 +112,7 @@ go_langhook_init (void) args.relative_import_path = go_relative_import_path; args.c_header = go_c_header; args.embedcfg = go_embedcfg; + args.importcfg = go_importcfg; args.check_divide_by_zero = go_check_divide_zero; args.check_divide_overflow = go_check_divide_overflow; args.compiling_runtime = go_compiling_runtime; @@ -286,6 +288,10 @@ go_langhook_handle_option ( go_embedcfg = arg; break; +case OPT_fgo_importcfg_: + go_importcfg = arg; + break; + default: /* Just return 1 to indicate that the option is valid. */ break; diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index ff07b1a1fa6..c44cdc2baac 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -68a756b6aadc901534cfad2b1e73fae9e34f +92152c88ea8e2dd9e8c67e91bf4ae5e3edf1b506 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/embed.cc b/gcc/go/gofrontend/embed.cc index 0584f707ce6..6dada5efc2a 100644 --- a/gcc/go/gofrontend/embed.cc +++ b/gcc/go/gofrontend/embed.cc @@ -19,8 +19,8 @@ // Read a file into *DATA. Returns false on error. -static bool -read_file(const char* filename, Location loc, std::string* data) +bool +Gogo::read_file(const char* filename, Location loc, std::string* data) { int fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) @@ -346,7 +346,8 @@ Gogo::read_embedcfg(const char *filename) bool Embedcfg_reader::initialize_from_file() { - if (!read_file(this->filename_, Linemap::unknown_location(), >data_)) + if (!Gogo::read_file(this->filename_, Linemap::unknown_location(), + >data_)) return false; if (this->data_.empty()) { @@ -849,7 +850,7 @@ Gogo::initializer_for_embeds(Type* type, } std::string data; - if (!read_file(this->embed_files_[paths[0]].c_str(), loc, )) + if (!Gogo::read_file(this->embed_files_[paths[0]].c_str(), loc, )) return Expression::make_error(loc); Expression* e = Expression::make_string(data, loc); @@ -909,7 +910,7 @@ Gogo::initializer_for_embeds(Type* type, std::string data; if ((*pp)[pp->size() - 1] != '/') { - if (!read_file(this->embed_files_[*pp].c_str(), loc, )) + if
[PATCH][committed] aarch64: Use instead of in scalar SQRSHRUN pattern
Hi all, In the scalar pattern for SQRSHRUN it's a bit clearer to use DWI instead of V2XWIDE to make it more clear that no vector modes are involved. No behavioural change intended. Bootstrapped and tested on aarch64-none-linux-gnu. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64-simd.md (aarch64_sqrshrun_n_insn): Use instead of . (aarch64_sqrshrun_n): Likewise. dwi.patch Description: dwi.patch
[PATCH][committed] aarch64: Clean up some rounding immediate predicates
Hi all, aarch64_simd_rsra_rnd_imm_vec is now used for more than just RSRA and accepts more than just vectors so rename it to make it more truthful. The aarch64_simd_rshrn_imm_vec is now unused and can be deleted. No behavioural change intended. Bootstrapped and tested on aarch64-none-linux-gnu. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64-protos.h (aarch64_const_vec_rsra_rnd_imm_p): Rename to... (aarch64_rnd_imm_p): ... This. * config/aarch64/predicates.md (aarch64_simd_rsra_rnd_imm_vec): Rename to... (aarch64_int_rnd_operand): ... This. (aarch64_simd_rshrn_imm_vec): Delete. * config/aarch64/aarch64-simd.md (aarch64_rsra_n_insn): Adjust for the above. (aarch64_rshr_n_insn): Likewise. (*aarch64_rshrn_n_insn): Likewise. (*aarch64_sqrshrun_n_insn): Likewise. (aarch64_sqrshrun_n_insn): Likewise. (aarch64_rshrn2_n_insn_le): Likewise. (aarch64_rshrn2_n_insn_be): Likewise. (aarch64_sqrshrun2_n_insn_le): Likewise. (aarch64_sqrshrun2_n_insn_be): Likewise. * config/aarch64/aarch64.cc (aarch64_const_vec_rsra_rnd_imm_p): Rename to... (aarch64_rnd_imm_p): ... This. rnd-imm.patch Description: rnd-imm.patch
Go patch committed: Support bootstrapping Go 1.21
compiler, libgo: support bootstrapping gc compiler In the Go 1.21 release the package internal/profile imports internal/lazyregexp. That works when bootstrapping with Go 1.17, because that compiler has internal/lazyregep and permits importing it. We also have internal/lazyregexp in libgo, but since it is not installed it is not available for importing. This patch adds internal/lazyregexp to the list of internal packages that are installed for bootstrapping. The Go 1.21, and earlier, releases have a couple of functions in the internal/abi package that are always fully intrinsified. The Go frontend recognizes and intrinsifies those functions as well. However, the Go frontend was also building function descriptors for references to the functions without calling them, which failed because there was nothing to refer to. That is OK for the gc compiler, which guarantees that the functions are only called, not referenced. This patch arranges to not generate function descriptors for these functions. This helps address https://go.dev/issue/60913. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline and GCC 12 and 13 branches. Ian 2ad5553091d8afbc21bbd3a29a419df359e7aacc diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index a028350ba8e..ff07b1a1fa6 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -195060166e6045408a2cb95e6aa88c6f0b98f20b +68a756b6aadc901534cfad2b1e73fae9e34f The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 2112de6abfc..d276bd811cc 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -12272,7 +12272,8 @@ Call_expression::intrinsify(Gogo* gogo, return Runtime::make_call(code, loc, 3, a1, a2, a3); } } - else if (package == "internal/abi") + else if (package == "internal/abi" + || package == "bootstrap/internal/abi") // for bootstrapping gc { if (is_method) return NULL; diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index 9197eef3e38..980db1ea07e 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -3296,6 +3296,9 @@ class Create_function_descriptors : public Traverse int expression(Expression**); + static bool + skip_descriptor(Gogo* gogo, const Named_object*); + private: Gogo* gogo_; }; @@ -3306,6 +3309,9 @@ class Create_function_descriptors : public Traverse int Create_function_descriptors::function(Named_object* no) { + if (Create_function_descriptors::skip_descriptor(this->gogo_, no)) +return TRAVERSE_CONTINUE; + if (no->is_function() && no->func_value()->enclosing() == NULL && !no->func_value()->is_method() @@ -3393,6 +3399,28 @@ Create_function_descriptors::expression(Expression** pexpr) return TRAVERSE_CONTINUE; } +// The gc compiler has some special cases that it always compiles as +// intrinsics. For those we don't want to generate a function +// descriptor, as there will be no code for it to refer to. + +bool +Create_function_descriptors::skip_descriptor(Gogo* gogo, +const Named_object* no) +{ + const std::string& pkgpath(no->package() == NULL +? gogo->pkgpath() +: no->package()->pkgpath()); + + // internal/abi is the standard library package, + // bootstrap/internal/abi is the name used when bootstrapping the gc + // compiler. + + return ((pkgpath == "internal/abi" + || pkgpath == "bootstrap/internal/abi") + && (no->name() == "FuncPCABI0" + || no->name() == "FuncPCABIInternal")); +} + // Create function descriptors as needed. We need a function // descriptor for all exported functions and for all functions that // are referenced without being called. @@ -3414,7 +3442,8 @@ Gogo::create_function_descriptors() if (no->is_function_declaration() && !no->func_declaration_value()->type()->is_method() && !Linemap::is_predeclared_location(no->location()) - && !Gogo::is_hidden_name(no->name())) + && !Gogo::is_hidden_name(no->name()) + && !Create_function_descriptors::skip_descriptor(this, no)) fndecls.push_back(no); } for (std::vector::const_iterator p = fndecls.begin(); diff --git a/libgo/Makefile.am b/libgo/Makefile.am index 920f8cc7071..c95dc2106cd 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -417,6 +417,7 @@ toolexeclibgounicode_DATA = \ # Some internal packages are needed to bootstrap the gc toolchain. toolexeclibgointernaldir = $(toolexeclibgodir)/internal toolexeclibgointernal_DATA = \ + internal/lazyregexp.gox \ internal/reflectlite.gox \ internal/unsafeheader.gox diff --git a/libgo/go/internal/abi/abi.go
Go patch committed: Determine types of Slice_{value, info} expressions
This patch to the Go frontend determines the types of a couple of expressions types that accidentally failed to recurse into their subexpressions. The test case for this is https://go.dev/cl/505015. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian f42544e04a131cee886cb7cdc65df1e2f09baf8c diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index dbb2d68f909..a028350ba8e 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -6a1d165c2218cd127ee937a1f45599075762f716 +195060166e6045408a2cb95e6aa88c6f0b98f20b The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 4ac55af7433..2112de6abfc 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -18307,6 +18307,16 @@ Slice_value_expression::do_traverse(Traverse* traverse) return TRAVERSE_CONTINUE; } +// Determine type of a slice value. + +void +Slice_value_expression::do_determine_type(const Type_context*) +{ + this->valmem_->determine_type_no_context(); + this->len_->determine_type_no_context(); + this->cap_->determine_type_no_context(); +} + Expression* Slice_value_expression::do_copy() { diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index 3d7e78711bd..bdb7ccd010d 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -4364,8 +4364,7 @@ class Slice_value_expression : public Expression { return this->type_; } void - do_determine_type(const Type_context*) - { } + do_determine_type(const Type_context*); Expression* do_copy(); @@ -4419,7 +4418,7 @@ class Slice_info_expression : public Expression void do_determine_type(const Type_context*) - { } + { this->slice_->determine_type_no_context(); } Expression* do_copy()
[PATCH][committed] aarch64: Avoid same input and output Z register for gather loads
Hi all, The architecture recommends that load-gather instructions avoid using the same Z register for the load address and the destination, and the Software Optimization Guides for Arm cores recommend that as well. This means that for code like: #include svuint64_t food (svbool_t p, uint64_t *in, svint64_t offsets, svuint64_t a) { return svadd_u64_x (p, a, svld1_gather_offset(p, in, offsets)); } we'll want to avoid generating the current: food: ld1dz0.d, p0/z, [x0, z0.d] // Z0 reused as input and output. add z0.d, z1.d, z0.d ret However, we still want to avoid generating extra moves where there were none before, so the tight aarch64-sve-acle.exp tests for load gathers should still pass as they are. This patch implements that recommendation for the load gather patterns by: * duplicating the alternatives * marking the output operand as early clobber * Tying the input Z register operand in the original alternatives to 0 * Penalising the original alternatives with '?' This results in a large-ish patch in terms of diff lines but the new compact syntax (thanks Tamar) makes it quite a readable an regular change. The benchmark numbers on a Neoverse V1 on fprate look okay: diff 503.bwaves_r0.00% 507.cactuBSSN_r 0.00% 508.namd_r 0.00% 510.parest_r0.55% 511.povray_r0.22% 519.lbm_r 0.00% 521.wrf_r 0.00% 526.blender_r 0.00% 527.cam4_r 0.56% 538.imagick_r 0.00% 544.nab_r 0.00% 549.fotonik3d_r 0.00% 554.roms_r 0.00% fprate 0.10% Bootstrapped and tested on aarch64-none-linux-gnu. Pushing to trunk. Thanks, Kyrill P.S. I had messed up my previous commit of https://gcc.gnu.org/pipermail/gcc-patches/2023-June/622456.html by squashing the config/aarch64 changes with this patch. I have reverted that one commit and reapplied it properly (as it should have been a no-op) and am pushing this commit on top of that. Sorry for the churn in the repo. gcc/ChangeLog: * config/aarch64/aarch64-sve.md (mask_gather_load): Add alternatives to prefer to avoid same input and output Z register. (mask_gather_load): Likewise. (*mask_gather_load_xtw_unpacked): Likewise. (*mask_gather_load_sxtw): Likewise. (*mask_gather_load_uxtw): Likewise. (@aarch64_gather_load_): Likewise. (@aarch64_gather_load_): Likewise. (*aarch64_gather_load_ _xtw_unpacked): Likewise. (*aarch64_gather_load_ _sxtw): Likewise. (*aarch64_gather_load_ _uxtw): Likewise. (@aarch64_ldff1_gather): Likewise. (@aarch64_ldff1_gather): Likewise. (*aarch64_ldff1_gather_sxtw): Likewise. (*aarch64_ldff1_gather_uxtw): Likewise. (@aarch64_ldff1_gather_ ): Likewise. (@aarch64_ldff1_gather_ ): Likewise. (*aarch64_ldff1_gather_ _sxtw): Likewise. (*aarch64_ldff1_gather_ _uxtw): Likewise. * config/aarch64/aarch64-sve2.md (@aarch64_gather_ldnt): Likewise. (@aarch64_gather_ldnt_ ): Likewise. gcc/testsuite/ChangeLog: * gcc.target/aarch64/sve/gather_earlyclobber.c: New test. * gcc.target/aarch64/sve2/gather_earlyclobber.c: New test. gather-earlyclobber.patch Description: gather-earlyclobber.patch
[PATCH][committed] aarch64: Convert SVE gather patterns to compact syntax
Hi all, This patch converts the SVE load gather patterns to the new compact syntax that Tamar introduced. This allows for a future patch I want to contribute to add more alternatives that are better viewed in the more compact form. The lines in some patterns are >80 long now, but I think that's unavoidable and those patterns already had overly long constraint strings. No functional change intended. Bootstrapped and tested on aarch64-none-linux-gnu. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64-sve.md (mask_gather_load): Convert to compact alternatives syntax. (mask_gather_load): Likewise. (*mask_gather_load_xtw_unpacked): Likewise. (*mask_gather_load_sxtw): Likewise. (*mask_gather_load_uxtw): Likewise. (@aarch64_gather_load_): Likewise. (@aarch64_gather_load_): Likewise. (*aarch64_gather_load_ _xtw_unpacked): Likewise. (*aarch64_gather_load_ _sxtw): Likewise. (*aarch64_gather_load_ _uxtw): Likewise. (@aarch64_ldff1_gather): Likewise. (@aarch64_ldff1_gather): Likewise. (*aarch64_ldff1_gather_sxtw): Likewise. (*aarch64_ldff1_gather_uxtw): Likewise. (@aarch64_ldff1_gather_ ): Likewise. (@aarch64_ldff1_gather_ ): Likewise. (*aarch64_ldff1_gather_ _sxtw): Likewise. (*aarch64_ldff1_gather_ _uxtw): Likewise. * config/aarch64/aarch64-sve2.md (@aarch64_gather_ldnt): Likewise. (@aarch64_gather_ldnt_ ): Likewise. gather-compact.patch Description: gather-compact.patch
[PATCH][committed][docs]: replace backslashchar [PR 110329].
Hi All, It seems like @blackslashchar{} is a relatively new addition to texinfo. Other parts of the docs use @samp{\} so use it here too so older distros work. Bootstrapped on aarch64-none-linux-gnu and no issues. committed under obvious rule. Thanks, Tamar gcc/ChangeLog: PR other/110329 * doc/md.texi: Replace backslashchar. --- inline copy of patch -- diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index 052375b1a31b829303e75417c400024f084aef44..9648fdc846abf1700effe3272d5523538ce9b50f 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -837,7 +837,7 @@ blocks on the line. @item Within an @samp{@{@@} block, any iterators that do not get expanded will result in an error. If for some reason it is required to have @code{<} or @code{>} in -the output then these must be escaped using @backslashchar{}. +the output then these must be escaped using @samp{\}. @item It is possible to use the @samp{attrs} list to specify some attributes and to -- diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index 052375b1a31b829303e75417c400024f084aef44..9648fdc846abf1700effe3272d5523538ce9b50f 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -837,7 +837,7 @@ blocks on the line. @item Within an @samp{@{@@} block, any iterators that do not get expanded will result in an error. If for some reason it is required to have @code{<} or @code{>} in -the output then these must be escaped using @backslashchar{}. +the output then these must be escaped using @samp{\}. @item It is possible to use the @samp{attrs} list to specify some attributes and to
Re: [gofrontend-dev] Re: libgo patch committed: Use a C function to call mmap
On Tue, Jun 20, 2023 at 3:37 PM Ian Lance Taylor wrote: > On Tue, Jun 20, 2023 at 11:35 AM Andreas Schwab > wrote: > > > > On Jun 20 2023, Ian Lance Taylor via Gcc-patches wrote: > > > > > This libgo patches changes the runtime pacakge to use a C function to > call mmap. > > > > > > The final argument to mmap, of type off_t, varies. In > > > https://go.dev/cl/445375 > > > (https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604158.html) > > > we changed it to always use the C off_t type, but that broke 32-bit > > > big-endian Linux systems. > > > > This has nothing to do with big-endian, armv7 isn't big-endian. > > OK, but I think that it does have something to do with big-endian. > The bug was that on some 32-bit systems it was passing a 64-bit value > to a function that expected a 32-bit value. The problem didn't show > up on 32-bit x86 because it is little-endian, and did show up on > 32-bit PPC because it is big-endian. I guess the armv7 case was > failing for a different reason. I think there is a calling convention issue. On 32-bit ARM, for the case of mmap, if the last argument is 32-bit, it is passed 4 bytes at sp+4. If it is 64-bit, the offset is aligned and it is stored as 8 bytes at sp+8. So if the callee tries to read at sp+4, it gets the wrong value, even for little endian. On 32-bit x86 it doesn't seem to have that alignment padding.
Re: libgo patch committed: Use a C function to call mmap
On Jun 20 2023, Ian Lance Taylor wrote: > OK, but I think that it does have something to do with big-endian. > The bug was that on some 32-bit systems it was passing a 64-bit value > to a function that expected a 32-bit value. The problem didn't show > up on 32-bit x86 because it is little-endian, and did show up on > 32-bit PPC because it is big-endian. I guess the armv7 case was > failing for a different reason. Not failing is no proof for correctness. It fails everywhere for the same reason. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Re: libgo patch committed: Use a C function to call mmap
On Tue, Jun 20, 2023 at 11:35 AM Andreas Schwab wrote: > > On Jun 20 2023, Ian Lance Taylor via Gcc-patches wrote: > > > This libgo patches changes the runtime pacakge to use a C function to call > > mmap. > > > > The final argument to mmap, of type off_t, varies. In > > https://go.dev/cl/445375 > > (https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604158.html) > > we changed it to always use the C off_t type, but that broke 32-bit > > big-endian Linux systems. > > This has nothing to do with big-endian, armv7 isn't big-endian. OK, but I think that it does have something to do with big-endian. The bug was that on some 32-bit systems it was passing a 64-bit value to a function that expected a 32-bit value. The problem didn't show up on 32-bit x86 because it is little-endian, and did show up on 32-bit PPC because it is big-endian. I guess the armv7 case was failing for a different reason. Ian
Re: libgo patch committed: Use a C function to call mmap
On Jun 20 2023, Ian Lance Taylor via Gcc-patches wrote: > This libgo patches changes the runtime pacakge to use a C function to call > mmap. > > The final argument to mmap, of type off_t, varies. In > https://go.dev/cl/445375 > (https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604158.html) > we changed it to always use the C off_t type, but that broke 32-bit > big-endian Linux systems. This has nothing to do with big-endian, armv7 isn't big-endian. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
libgo patch committed: Use a C function to call mmap
This libgo patches changes the runtime pacakge to use a C function to call mmap. The final argument to mmap, of type off_t, varies. In https://go.dev/cl/445375 (https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604158.html) we changed it to always use the C off_t type, but that broke 32-bit big-endian Linux systems. On those systems, using the C off_t type requires calling the mmap64 function. In C this is automatically handled by the file. In Go, we would have to change the magic //extern comment to call mmap64 when appropriate. Rather than try to get that right, we instead go through a C function that uses C implicit type conversions to pick the right type. This fixes https://gcc.gnu.org/PR110297. Bootstrapped and tested on x86_64-pc-linux-gnu and powerpc-pc-linux-gnu (32-bit and 64-bit). Committed to trunk and GCC 13 branch. Ian 7f5a6c8a27190daf9daadf5e9f14ef5f4ece diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 1191a8d663d..dbb2d68f909 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -a3a3c3a2d1bc6a8ca51b302d08c94ef27cdd8f0f +6a1d165c2218cd127ee937a1f45599075762f716 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/Makefile.am b/libgo/Makefile.am index 207d5a98127..920f8cc7071 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -462,6 +462,7 @@ runtime_files = \ runtime/go-memclr.c \ runtime/go-memmove.c \ runtime/go-memequal.c \ + runtime/go-mmap.c \ runtime/go-nanotime.c \ runtime/go-now.c \ runtime/go-nosys.c \ diff --git a/libgo/go/runtime/mem_gccgo.go b/libgo/go/runtime/mem_gccgo.go index 1e84f4f5c56..e7b51ff37cc 100644 --- a/libgo/go/runtime/mem_gccgo.go +++ b/libgo/go/runtime/mem_gccgo.go @@ -14,8 +14,8 @@ import ( //go:linkname sysAlloc //go:linkname sysFree -//extern mmap -func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off _libgo_off_t_type) unsafe.Pointer +//extern __go_mmap +func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer //extern munmap func munmap(addr unsafe.Pointer, length uintptr) int32 @@ -38,7 +38,7 @@ func init() { } func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) { - p := sysMmap(addr, n, prot, flags, fd, _libgo_off_t_type(off)) + p := sysMmap(addr, n, prot, flags, fd, off) if uintptr(p) == _MAP_FAILED { return nil, errno() } diff --git a/libgo/runtime/go-mmap.c b/libgo/runtime/go-mmap.c new file mode 100644 index 000..b2327ba68f5 --- /dev/null +++ b/libgo/runtime/go-mmap.c @@ -0,0 +1,21 @@ +/* go-mmap.c -- functions for calling C mmap functions. + + Copyright 2023 The Go Authors. All rights reserved. + Use of this source code is governed by a BSD-style + license that can be found in the LICENSE file. */ + +#include "config.h" + +#include +#include + +/* The exact C function to call varies between mmap and mmap64, and + the size of the off_t argument also varies. Here we provide a + function that Go code can call with consistent types. */ + +void * +__go_mmap(void *addr, uintptr_t length, int32_t prot, int32_t flags, + int32_t fd, uintptr_t offset) +{ + return mmap(addr, length, prot, flags, fd, offset); +} diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h index b3dc4fd2414..699770d53ad 100644 --- a/libgo/runtime/runtime.h +++ b/libgo/runtime/runtime.h @@ -355,9 +355,6 @@ boolruntime_notetsleepg(Note*, int64) // false - timeout /* * low level C-called */ -#define runtime_mmap mmap -#define runtime_munmap munmap -#define runtime_madvise madvise #define runtime_memclr(buf, size) __builtin_memset((buf), 0, (size)) #define runtime_getcallerpc() __builtin_return_address(0)
[PATCH][committed] aarch64: Optimise ADDP with same source operands
Hi all, We've been asked to optimise the testcase in this patch of a 64-bit ADDP with the low and high halves of the same 128-bit vector. This can be done by a single .4s ADDP followed by just reading the bottom 64 bits. A splitter for this is quite straightforward now that all the vec_concat stuff is collapsed by simplify-rtx. With this patch we generate a single: addpv0.4s, v0.4s, v0.4s instead of: dup d31, v0.d[1] addpv0.2s, v0.2s, v31.2s ret Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64-simd.md (*aarch64_addp_same_reg): New define_insn_and_split. gcc/testsuite/ChangeLog: * gcc.target/aarch64/simd/addp-same-low_1.c: New test. addp-q.patch Description: addp-q.patch
[PATCH][committed]AArch64 remove test comment from *mov_aarch64
Hi All, I accidentally left a test comment in the final version of the patch. This removes the comment. Regtested on aarch64-none-linux-gnu and no issues. Committed under the obvious rule. Thanks, Tamar gcc/ChangeLog: * config/aarch64/aarch64.md (*mov_aarch64): Drop test comment. --- inline copy of patch -- diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 97e5a59d30ca17c26c0951e9a7c62a7934af8d4f..25f7905c6a0b3b7dd860a1346b8e1d4e1b04164b 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -1224,7 +1224,7 @@ (define_insn "*mov_aarch64" [m, r Z ; store_4, * ] str\\t%w1, %0 [m, w; store_4, * ] str\t%1, %0 [r, w; neon_to_gp , simd ] umov\t%w0, %1.[0] - [r, w; neon_to_gp , nosimd] fmov\t%w0, %s1 /*foo */ + [r, w; neon_to_gp , nosimd] fmov\t%w0, %s1 [w, r Z ; neon_from_gp, simd ] dup\t%0., %w1 [w, r Z ; neon_from_gp, nosimd] fmov\t%s0, %w1 [w, w; neon_dup , simd ] dup\t%0, %1.[0] -- diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 97e5a59d30ca17c26c0951e9a7c62a7934af8d4f..25f7905c6a0b3b7dd860a1346b8e1d4e1b04164b 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -1224,7 +1224,7 @@ (define_insn "*mov_aarch64" [m, r Z ; store_4, * ] str\\t%w1, %0 [m, w; store_4, * ] str\t%1, %0 [r, w; neon_to_gp , simd ] umov\t%w0, %1.[0] - [r, w; neon_to_gp , nosimd] fmov\t%w0, %s1 /*foo */ + [r, w; neon_to_gp , nosimd] fmov\t%w0, %s1 [w, r Z ; neon_from_gp, simd ] dup\t%0., %w1 [w, r Z ; neon_from_gp, nosimd] fmov\t%s0, %w1 [w, w; neon_dup , simd ] dup\t%0, %1.[0]
libgo patch committed: Add benchmarks and examples to test list
In https://go.dev/cl/384695 (https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590289.html) I simplified the code that built lists of benchmarks, examples, and fuzz tests, and managed to break it. This patch corrects the code to once again make the benchmarks available, and to run the examples with output and the fuzz targets. Doing this revealed a test failure in internal/fuzz on 32-bit x86: a signalling NaN is turned into a quiet NaN on the 387 floating-point stack that GCC uses by default. This CL skips the test. This fixes https://go.dev/issue/60826. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian bc6bd0d608da1609c1caeb04ab795a83720add55 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 702257009d2..1191a8d663d 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -737de90a63002d4872b19772a7116404ee5815b4 +a3a3c3a2d1bc6a8ca51b302d08c94ef27cdd8f0f The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/go/internal/fuzz/encoding_test.go b/libgo/go/internal/fuzz/encoding_test.go index 8e3800eb77f..53fc5b8dc71 100644 --- a/libgo/go/internal/fuzz/encoding_test.go +++ b/libgo/go/internal/fuzz/encoding_test.go @@ -6,6 +6,7 @@ package fuzz import ( "math" + "runtime" "strconv" "testing" "unicode" @@ -330,6 +331,14 @@ func FuzzFloat64RoundTrip(f *testing.F) { f.Add(math.Float64bits(math.Inf(-1))) f.Fuzz(func(t *testing.T, u1 uint64) { + // The signaling NaN test fails on 32-bit x86 with gccgo, + // which uses the 387 floating-point stack by default. + // Converting a signaling NaN in and out of the stack + // changes the NaN to a quiet NaN. + if runtime.GOARCH == "386" && u1 == 0x7FF1 { + t.Skip("skipping signalling NaN test on 386 with gccgo") + } + x1 := math.Float64frombits(u1) b := marshalCorpusFile(x1) diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest index 0a0a7e14d74..33c98d804d6 100755 --- a/libgo/testsuite/gotest +++ b/libgo/testsuite/gotest @@ -577,13 +577,13 @@ symtogo() { # Find Go benchmark/fuzz/example functions. # The argument is the function name prefix. findfuncs() { - pattern='$1([^a-z].*)?' + pattern="$1([^a-z].*)?" syms=$($NM -p -v _gotest_.o | egrep " $text .*\."$pattern'$' | fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //') if $havex; then xsyms=$($NM -p -v $xofile | egrep " $text .*\."$pattern'$' | fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //') syms="$syms $xsyms" fi -$(symtogo "$benchmarksyms") +symtogo "$syms" } # Takes an example name and puts any output into the file example.txt. @@ -643,11 +643,13 @@ exampleoutput() { fi if $havex; then needxtest=false - if test -n "$testxsyms" -o -n "$benchmarkxsyms"; then + if test -n "$testxsyms"; then + needxtest=true + elif echo "$benchmarks" | grep '_test\.' >/dev/null; then needxtest=true else # Check whether any example has output. - for i in $(symtogo "$examplexsyms"); do + for i in $(echo "$examples" | grep '_test\.'); do exampleoutput $i if test -f example.txt; then rm -f example.txt
[PATCH][committed] arm: Extend -mtp= arguments
Hi all, After discussing the -mtp= option with Arm's LLVM developers we'd like to extend the functionality of the option somewhat. There are actually 3 system registers that can be accessed for the thread pointer in aarch32: tpidrurw, tpidruro, tpidrprw. They are all read through the CP15 co-processor mechanism. The current -mtp=cp15 option reads the tpidruro register. This patch extends -mtp to allow for the above three explicit tpidr names and keeps -mtp=cp15 as an alias of -mtp=tpidruro for backwards compatibility. There is more relevant discussion of the options at https://reviews.llvm.org/D152433 if you're interested. Bootstrapped and tested on arm-none-linux-gnueabihf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/arm/arm-opts.h (enum arm_tp_type): Remove TP_CP15. Add TP_TPIDRURW, TP_TPIDRURO, TP_TPIDRPRW values. * config/arm/arm-protos.h (arm_output_load_tpidr): Declare prototype. * config/arm/arm.cc (arm_option_reconfigure_globals): Replace TP_CP15 with TP_TPIDRURO. (arm_output_load_tpidr): Define. * config/arm/arm.h (TARGET_HARD_TP): Define in terms of TARGET_SOFT_TP. * config/arm/arm.md (load_tp_hard): Call arm_output_load_tpidr to output assembly. (reload_tp_hard): Likewise. * config/arm/arm.opt (tpidrurw, tpidruro, tpidrprw): New values for arm_tp_type. * doc/invoke.texi (Arm Options, mtp): Document new values. gcc/testsuite/ChangeLog: * gcc.target/arm/mtp.c: New test. * gcc.target/arm/mtp_1.c: New test. * gcc.target/arm/mtp_2.c: New test. * gcc.target/arm/mtp_3.c: New test. * gcc.target/arm/mtp_4.c: New test. mtp-arm.patch Description: mtp-arm.patch
[PATCH][committed] aarch64: Extend -mtp= arguments
Hi all, After discussing the -mtp= option with Arm's LLVM developers we'd like to extend the functionality of the option somewhat. First of all, there is another TPIDR register that can be used to read the thread pointer: TPIDRRO_EL0 (which can also be accessed by AArch32 under another name) so it makes sense to add -mtp=tpidrr0_el0. This makes the existing arguments el0, el1, el2, el3 somewhat inconsistent in their naming so this patch introduces the more "full" names tpidr_el0, tpidr_el1, tpidr_el2, tpidr_el3 and makes the above short names alias of these new ones. Long story short, we preserve backwards compatibility and add a new TPIDR register to access through -mtp that wasn't available previously. There is more relevant discussion of the options at https://reviews.llvm.org/D152433 if you're interested. Bootstrapped and tested on aarch64-none-linux-gnu. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: PR target/108779 * config/aarch64/aarch64-opts.h (enum aarch64_tp_reg): Add AARCH64_TPIDRRO_EL0 value. * config/aarch64/aarch64.cc (aarch64_output_load_tp): * config/aarch64/aarch64.opt (tpidr_el0, tpidr_el1, tpidr_el2, tpidr_el3, tpidrro_el3): New accepted values to -mtp=. * doc/invoke.texi (AArch64 Options): Document new -mtp= options. gcc/testsuite/ChangeLog: PR target/108779 * gcc.target/aarch64/mtp_5.c: New test. * gcc.target/aarch64/mtp_6.c: New test. * gcc.target/aarch64/mtp_7.c: New test. * gcc.target/aarch64/mtp_8.c: New test. * gcc.target/aarch64/mtp_9.c: New test. mtp-a64.patch Description: mtp-a64.patch
[PATCH, committed] testsuite: Check int128 effective target for pr109932-{1,2}.c [PR110230]
Hi, This patch is to make newly added test cases pr109932-{1,2}.c check int128 effective target to avoid unsupported type error on 32-bit. I did hit this failure during testing and fixed it, but made a stupid mistake not updating the local formatted patch which was actually out of date. Pushed as obvious in r14-1776-g16eb9d69079d76. BR, Kewen - PR testsuite/110230 PR target/109932 gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr109932-1.c: Adjust with int128 effective target. * gcc.target/powerpc/pr109932-2.c: Ditto. --- gcc/testsuite/gcc.target/powerpc/pr109932-1.c | 1 + gcc/testsuite/gcc.target/powerpc/pr109932-2.c | 1 + 2 files changed, 2 insertions(+) diff --git a/gcc/testsuite/gcc.target/powerpc/pr109932-1.c b/gcc/testsuite/gcc.target/powerpc/pr109932-1.c index 3e3f9eaa65e..374d9f60618 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr109932-1.c +++ b/gcc/testsuite/gcc.target/powerpc/pr109932-1.c @@ -1,3 +1,4 @@ +/* { dg-require-effective-target int128 } */ /* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx" } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr109932-2.c b/gcc/testsuite/gcc.target/powerpc/pr109932-2.c index 3e3f9eaa65e..374d9f60618 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr109932-2.c +++ b/gcc/testsuite/gcc.target/powerpc/pr109932-2.c @@ -1,3 +1,4 @@ +/* { dg-require-effective-target int128 } */ /* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx" } */ -- 2.34.1
RE: [PATCH][committed] Regenerate config.in
> > Do you use the DEFAULT_MATCHPD_PARTITIONS macro anywhere? > If not, why the AC_DEFINE_UNQUOTED at all and not just the AC_SUBST? > It used to be used to change the default of genmatch.cc, but the default is now not to split anymore. So guess I can remove it. Will follow up...
Re: [PATCH][committed] Regenerate config.in
On Mon, Jun 12, 2023 at 11:20:00AM +0100, Tamar Christina via Gcc-patches wrote: > Hi All, > > Looks like I forgot to regenerate config.in which > causes updates when you enable maintainer mode. > > Bootstrapped aarch64-none-linux-gnu. > > Committed under obvious rule. Do you use the DEFAULT_MATCHPD_PARTITIONS macro anywhere? If not, why the AC_DEFINE_UNQUOTED at all and not just the AC_SUBST? Jakub
[PATCH][committed] Regenerate config.in
Hi All, Looks like I forgot to regenerate config.in which causes updates when you enable maintainer mode. Bootstrapped aarch64-none-linux-gnu. Committed under obvious rule. Thanks, Tamar gcc/ChangeLog: * config.in: Regenerate. --- inline copy of patch -- diff --git a/gcc/config.in b/gcc/config.in index 4cad077bfbed7fd73b3c04ce6405fd2f49178412..cf2f284378447c8f8e2f838a786dba23d6086fe3 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -67,6 +67,12 @@ #endif +/* Define to larger than one set the number of match.pd partitions to make. */ +#ifndef USED_FOR_TARGET +#undef DEFAULT_MATCHPD_PARTITIONS +#endif + + /* Define to larger than zero set the default stack clash protector size. */ #ifndef USED_FOR_TARGET #undef DEFAULT_STK_CLASH_GUARD_SIZE @@ -2239,8 +2245,7 @@ #endif -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ +/* Define to the sub-directory where libtool stores uninstalled libraries. */ #ifndef USED_FOR_TARGET #undef LT_OBJDIR #endif -- diff --git a/gcc/config.in b/gcc/config.in index 4cad077bfbed7fd73b3c04ce6405fd2f49178412..cf2f284378447c8f8e2f838a786dba23d6086fe3 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -67,6 +67,12 @@ #endif +/* Define to larger than one set the number of match.pd partitions to make. */ +#ifndef USED_FOR_TARGET +#undef DEFAULT_MATCHPD_PARTITIONS +#endif + + /* Define to larger than zero set the default stack clash protector size. */ #ifndef USED_FOR_TARGET #undef DEFAULT_STK_CLASH_GUARD_SIZE @@ -2239,8 +2245,7 @@ #endif -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ +/* Define to the sub-directory where libtool stores uninstalled libraries. */ #ifndef USED_FOR_TARGET #undef LT_OBJDIR #endif
[PATCH][committed] aarch64: Represent SQXTUN with RTL operations
Hi all, This patch removes UNSPEC_SQXTUN and uses organic RTL codes to represent the operation. SQXTUN is an odd one. It's described in the architecture as "Signed saturating extract Unsigned Narrow". It's not a straightforward ss_truncate nor a us_truncate. It is a sort of truncating signed clamp operation with limits derived from the unsigned extrema of the narrow mode: (truncate:N (smin:M (smax:M (reg:M) (const_int 0)) (const_int ))) This patch implements these semantics. I've checked that the vqmovun tests in advsimd-intrinsics.exp now get constant-folded and still pass validation, so I'm pretty confident in the semantics. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64-simd.md (aarch64_sqmovun): Rename to... (*aarch64_sqmovun_insn): ... This. Reimplement with RTL codes. (aarch64_sqmovun [SD_HSDI]): Reimplement with RTL codes. (aarch64_sqxtun2_le): Likewise. (aarch64_sqxtun2_be): Likewise. (aarch64_sqxtun2): Adjust for the above. (aarch64_sqmovun): New define_expand. * config/aarch64/iterators.md (UNSPEC_SQXTUN): Delete. (half_mask): New mode attribute. * config/aarch64/predicates.md (aarch64_simd_umax_half_mode): New predicate. sqxtun.patch Description: sqxtun.patch
[PATCH][committed] aarch64: Improve RTL representation of ADDP instructions
Hi all, Similar to the ADDLP instructions the non-widening ADDP ones can be represented by adding the odd lanes with the even lanes of a vector. These instructions take two vector inputs and the architecture spec describes the operation as concatenating them together before going through it with pairwise additions. This patch chooses to represent ADDP on 64-bit and 128-bit input vectors slightly differently, reasons explained in the comments in aarhc64-simd.md. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64-simd.md (aarch64_addp): Reimplement as... (aarch64_addp_insn): ... This... (aarch64_addp_insn): ... And this. (aarch64_addp): New define_expand. addp-r.patch Description: addp-r.patch
[PATCH][committed] aarch64: Improve representation of vpaddd intrinsics
Hi all, The aarch64_addpdi pattern is redundant as the reduc_plus_scal_ pattern can already generate the required form of the ADDP instruction, and is mostly folded to GIMPLE early on so can benefit from more optimisations. Though it turns out that we were missing the folding for the unsigned variants. This patch adds that and wires up the vpaddd_u64 and vpaddd_s64 intrinsics through the above pattern instead so that we can remove a redundant pattern and get more optimisation earlier. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64-builtins.cc (aarch64_general_gimple_fold_builtin): Handle unsigned reduc_plus_scal_ builtins. * config/aarch64/aarch64-simd-builtins.def (addp): Delete DImode instances. * config/aarch64/aarch64-simd.md (aarch64_addpdi): Delete. * config/aarch64/arm_neon.h (vpaddd_s64): Reimplement with __builtin_aarch64_reduc_plus_scal_v2di. (vpaddd_u64): Reimplement with __builtin_aarch64_reduc_plus_scal_v2di_uu. vpaddd.patch Description: vpaddd.patch
[PATCH][committed] aarch64: Reimplement URSHR,SRSHR patterns with standard RTL codes
Hi all, Having converted the patterns for the URSRA,SRSRA instructions to standard RTL codes we can also easily convert the non-accumulating forms URSHR,SRSHR. This patch does that, reusing the various helpers and predicates from that patch in a straightforward way. This allows GCC to perform the optimisations in the testcase, matching what Clang does. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64-simd.md (aarch64_shr_n): Delete. (aarch64_rshr_n_insn): New define_insn. (aarch64_rshr_n): New define_expand. gcc/testsuite/ChangeLog: * gcc.target/aarch64/simd/vrshr_1.c: New test. rshr.patch Description: rshr.patch
[PATCH][committed] aarch64: Simplify SHRN, RSHRN expanders and patterns
Hi all, Now that we've got the annotations we can get rid of explicit !BYTES_BIG_ENDIAN and BYTES_BIG_ENDIAN patterns for the narrowing shift instructions. This allows us to clean up the expanders as well. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64-simd.md (aarch64_shrn_insn_le): Delete. (aarch64_shrn_insn_be): Delete. (*aarch64_shrn_vect): Rename to... (*aarch64_shrn): ... This. (aarch64_shrn): Remove reference to the above deleted patterns. (aarch64_rshrn_insn_le): Delete. (aarch64_rshrn_insn_be): Delete. (aarch64_rshrn_insn): New define_insn. (aarch64_rshrn): Remove references to the above deleted patterns. gcc/testsuite/ChangeLog: * gcc.target/aarch64/simd/pr99195_5.c: Add testing for shrn_n, rshrn_n intrinsics. shrn-clean.patch Description: shrn-clean.patch
[PATCH][committed] aarch64: Improve representation of ADDLV instructions
Hi all, We've received requests to optimise the attached intrinsics testcase. We currently generate: foo_1: uaddlp v0.4s, v0.8h uaddlv d31, v0.4s fmovx0, d31 ret foo_2: uaddlp v0.4s, v0.8h addvs31, v0.4s fmovw0, s31 ret foo_3: saddlp v0.4s, v0.8h addvs31, v0.4s fmovw0, s31 ret The widening pair-wise addition addlp instructions can be omitted if we're just doing an ADDV afterwards. Making this optimisation would be quite simple if we had a standard RTL PLUS vector reduction code. As we don't, we can use UNSPEC_ADDV as a stand in. This patch expresses the SADDLV and UADDLV instructions as an UNSPEC_ADDV over a widened input, thus removing the need for separate UNSPEC_SADDLV and UNSPEC_UADDLV codes. To optimise the testcases involved we add two splitters that match a vector addition where all participating elements are taken and widened from the same vector and then fed into an UNSPEC_ADDV. In that case we can just remove the vector PLUS and just emit the simple RTL for SADDLV/UADDLV. Bootstrapped and tested on aarch64-none-linux-gnu. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64-protos.h (aarch64_parallel_select_half_p): Define prototype. (aarch64_pars_overlap_p): Likewise. * config/aarch64/aarch64-simd.md (aarch64_addlv): Express in terms of UNSPEC_ADDV. (*aarch64_addlv_ze): Likewise. (*aarch64_addlv_reduction): Define. (*aarch64_uaddlv_reduction_2): Likewise. * config/aarch64/aarch64.cc (aarch64_parallel_select_half_p): Define. (aarch64_pars_overlap_p): Likewise. * config/aarch64/iterators.md (UNSPEC_SADDLV, UNSPEC_UADDLV): Delete. (VQUADW): New mode attribute. (VWIDE2X_S): Likewise. (USADDLV): Delete. (su): Delete handling of UNSPEC_SADDLV, UNSPEC_UADDLV. * config/aarch64/predicates.md (vect_par_cnst_select_half): Define. gcc/testsuite/ChangeLog: * gcc.target/aarch64/simd/addlv_1.c: New test. addlv2.patch Description: addlv2.patch
Re: [PATCH, committed] Fortran: fix diagnostics for SELECT RANK [PR100607]
Hi Paul, On 6/3/23 07:48, Paul Richard Thomas via Gcc-patches wrote: Hi Harald, It looks good to me. Thanks to you and Steve for the fix. I suggest that it is such and obvious one that it deserved back-porting. alright, I'll check how far this makes sense. Cheers, Harald Cheers Paul On Fri, 2 Jun 2023 at 19:06, Harald Anlauf via Fortran wrote: Dear all, I've committed that attached simple patch on behalf of Steve after discussion in the PR and regtesting on x86_64-pc-linux-gnu. It fixes a duplicate error message and an ICE. Pushed as r14-1505-gfae09dfc0e6bf4cfe35d817558827aea78c6426f . Thanks, Harald
Re: [PATCH, committed] Fortran: fix diagnostics for SELECT RANK [PR100607]
Hi Harald, It looks good to me. Thanks to you and Steve for the fix. I suggest that it is such and obvious one that it deserved back-porting. Cheers Paul On Fri, 2 Jun 2023 at 19:06, Harald Anlauf via Fortran wrote: > > Dear all, > > I've committed that attached simple patch on behalf of Steve > after discussion in the PR and regtesting on x86_64-pc-linux-gnu. > > It fixes a duplicate error message and an ICE. > > Pushed as r14-1505-gfae09dfc0e6bf4cfe35d817558827aea78c6426f . > > Thanks, > Harald > -- "If you can't explain it simply, you don't understand it well enough" - Albert Einstein
[PATCH, committed] Fortran: fix diagnostics for SELECT RANK [PR100607]
Dear all, I've committed that attached simple patch on behalf of Steve after discussion in the PR and regtesting on x86_64-pc-linux-gnu. It fixes a duplicate error message and an ICE. Pushed as r14-1505-gfae09dfc0e6bf4cfe35d817558827aea78c6426f . Thanks, Harald From fae09dfc0e6bf4cfe35d817558827aea78c6426f Mon Sep 17 00:00:00 2001 From: Steve Kargl Date: Fri, 2 Jun 2023 19:44:11 +0200 Subject: [PATCH] Fortran: fix diagnostics for SELECT RANK [PR100607] gcc/fortran/ChangeLog: PR fortran/100607 * resolve.cc (resolve_select_rank): Remove duplicate error. (resolve_fl_var_and_proc): Prevent NULL pointer dereference and suppress error message for temporary. gcc/testsuite/ChangeLog: PR fortran/100607 * gfortran.dg/select_rank_6.f90: New test. --- gcc/fortran/resolve.cc | 10 ++--- gcc/testsuite/gfortran.dg/select_rank_6.f90 | 48 + 2 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/select_rank_6.f90 diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 2ba3101f1fe..fd059dddf05 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -10020,11 +10020,6 @@ resolve_select_rank (gfc_code *code, gfc_namespace *old_ns) || gfc_expr_attr (code->expr1).pointer)) gfc_error ("RANK (*) at %L cannot be used with the pointer or " "allocatable selector at %L", >where, >expr1->where); - - if (case_value == -1 && (gfc_expr_attr (code->expr1).allocatable - || gfc_expr_attr (code->expr1).pointer)) - gfc_error ("RANK (*) at %L cannot be used with the pointer or " - "allocatable selector at %L", >where, >expr1->where); } /* Add EXEC_SELECT to switch on rank. */ @@ -13262,7 +13257,10 @@ resolve_fl_var_and_proc (gfc_symbol *sym, int mp_flag) if (allocatable) { - if (dimension && as->type != AS_ASSUMED_RANK) + if (dimension + && as + && as->type != AS_ASSUMED_RANK + && !sym->attr.select_rank_temporary) { gfc_error ("Allocatable array %qs at %L must have a deferred " "shape or assumed rank", sym->name, >declared_at); diff --git a/gcc/testsuite/gfortran.dg/select_rank_6.f90 b/gcc/testsuite/gfortran.dg/select_rank_6.f90 new file mode 100644 index 000..d0121777bb5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/select_rank_6.f90 @@ -0,0 +1,48 @@ +! { dg-do compile } +! PR fortran/100607 - fix diagnostics for SELECT RANK +! Contributed by T.Burnus + +program p + implicit none + integer, allocatable :: A(:,:,:) + + allocate(a(5:6,-2:2, 99:100)) + call foo(a) + call bar(a) + +contains + + subroutine foo(x) +integer, allocatable :: x(..) +if (rank(x) /= 3) stop 1 +if (any (lbound(x) /= [5, -2, 99])) stop 2 + +select rank (x) +rank(3) + if (any (lbound(x) /= [5, -2, 99])) stop 3 +end select + +select rank (x) ! { dg-error "pointer or allocatable selector at .2." } +rank(*) ! { dg-error "pointer or allocatable selector at .2." } + if (rank(x) /= 1) stop 4 + if (lbound(x, 1) /= 1) stop 5 +end select + end + + subroutine bar(x) +integer :: x(..) +if (rank(x) /= 3) stop 6 +if (any (lbound(x) /= 1)) stop 7 + +select rank (x) +rank(3) + if (any (lbound(x) /= 1)) stop 8 +end select + +select rank (x) +rank(*) + if (rank(x) /= 1) stop 9 + if (lbound(x, 1) /= 1) stop 10 +end select + end +end -- 2.35.3
Re: [PATCH][committed] btf: Fix -Wformat errors
On 02/06/2023 18:45, Jakub Jelinek wrote: > On Fri, Jun 02, 2023 at 06:18:38PM +0200, Rainer Orth wrote: > > Hi Alex, > > > > > g:7aae58b04b92303ccda3ead600be98f0d4b7f462 introduced -Wformat errors > > > breaking bootstrap on some targets. This patch fixes that. > > > > > > Committed as obvious. > > > > > > Thanks, > > > Alex > > > > > > gcc/ChangeLog: > > > > > > * btfout.cc (btf_asm_type): Use PRIu64 instead of %lu for uint64_t. > > > (btf_asm_datasec_type): Likewise. > > > > This is PR libstdc++/110077. Btw., your fix is incomplete: it needs > > another change (%lu -> %zu) in btf_asm_func_type. > > Can we rely on %zu working? Sure, it is in C99 and so in C++11 as well, > but I don't see it being used inside of gcc/ at all and not sure if all host > C libraries support it. Looks like the follow-up patch from David fixes this without relying on %zu: https://gcc.gnu.org/pipermail/gcc-patches/2023-June/620524.html Alex > > Jakub >
Re: [PATCH][committed] btf: Fix -Wformat errors
On Fri, Jun 02, 2023 at 06:18:38PM +0200, Rainer Orth wrote: > Hi Alex, > > > g:7aae58b04b92303ccda3ead600be98f0d4b7f462 introduced -Wformat errors > > breaking bootstrap on some targets. This patch fixes that. > > > > Committed as obvious. > > > > Thanks, > > Alex > > > > gcc/ChangeLog: > > > > * btfout.cc (btf_asm_type): Use PRIu64 instead of %lu for uint64_t. > > (btf_asm_datasec_type): Likewise. > > This is PR libstdc++/110077. Btw., your fix is incomplete: it needs > another change (%lu -> %zu) in btf_asm_func_type. Can we rely on %zu working? Sure, it is in C99 and so in C++11 as well, but I don't see it being used inside of gcc/ at all and not sure if all host C libraries support it. Jakub
[PATCH][committed] btf: fix bootstrap -Wformat errors [PR110073]
Commit 7aae58b04b9 "btf: improve -dA comments for testsuite" broke bootstrap on a number of architectures because it introduced some new -Wformat errors. Fix those errors by properly using PRIu64 and a small refactor to the offending code. Based on the suggested patch from Rainer Orth. Committed as obvious. PR debug/110073 gcc/ChangeLog: * btfout.cc (btf_absolute_func_id): New function. (btf_asm_func_type): Call it here. Change index parameter from size_t to ctf_id_t. Use PRIu64 formatter. --- gcc/btfout.cc | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gcc/btfout.cc b/gcc/btfout.cc index 1ea68b9e8ba..e07fed302c2 100644 --- a/gcc/btfout.cc +++ b/gcc/btfout.cc @@ -192,6 +192,14 @@ btf_relative_var_id (ctf_id_t abs) return abs - (num_types_added + 1); } +/* Return the final BTF ID of the func record at relative index REL. */ + +static ctf_id_t +btf_absolute_func_id (ctf_id_t rel) +{ + return rel + (num_types_added + 1) + num_vars_added; +} + /* Return the relative index of the func record with final BTF ID ABS. */ static ctf_id_t @@ -937,13 +945,12 @@ btf_asm_func_arg (ctf_container_ref ctfc, ctf_func_arg_t * farg, /* Asm'out a BTF_KIND_FUNC type. */ static void -btf_asm_func_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd, size_t i) +btf_asm_func_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd, ctf_id_t id) { ctf_id_t ref_id = dtd->dtd_data.ctti_type; dw2_asm_output_data (4, dtd->dtd_data.ctti_name, - "TYPE %lu BTF_KIND_FUNC '%s'", - num_types_added + num_vars_added + 1 + i, - dtd->dtd_name); + "TYPE %" PRIu64 " BTF_KIND_FUNC '%s'", + btf_absolute_func_id (id), dtd->dtd_name); dw2_asm_output_data (4, BTF_TYPE_INFO (BTF_KIND_FUNC, 0, dtd->linkage), "btt_info: kind=%u, kflag=%u, linkage=%u", BTF_KIND_FUNC, 0, dtd->linkage); -- 2.40.1
Re: [PATCH][committed] btf: Fix -Wformat errors
> On 2 Jun 2023, at 17:18, Rainer Orth wrote: > > Hi Alex, > >> g:7aae58b04b92303ccda3ead600be98f0d4b7f462 introduced -Wformat errors >> breaking bootstrap on some targets. This patch fixes that. >> >> Committed as obvious. >> >> Thanks, >> Alex >> >> gcc/ChangeLog: >> >> * btfout.cc (btf_asm_type): Use PRIu64 instead of %lu for uint64_t. >> (btf_asm_datasec_type): Likewise. > > This is PR libstdc++/110077. Btw., your fix is incomplete: it needs > another change (%lu -> %zu) in btf_asm_func_type. I think there’s a typo in the PR ref? https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110073 Iain
Re: [PATCH][committed] btf: Fix -Wformat errors
Hi Alex, > g:7aae58b04b92303ccda3ead600be98f0d4b7f462 introduced -Wformat errors > breaking bootstrap on some targets. This patch fixes that. > > Committed as obvious. > > Thanks, > Alex > > gcc/ChangeLog: > > * btfout.cc (btf_asm_type): Use PRIu64 instead of %lu for uint64_t. > (btf_asm_datasec_type): Likewise. This is PR libstdc++/110077. Btw., your fix is incomplete: it needs another change (%lu -> %zu) in btf_asm_func_type. Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
[PATCH][committed] btf: Fix -Wformat errors
Hi, g:7aae58b04b92303ccda3ead600be98f0d4b7f462 introduced -Wformat errors breaking bootstrap on some targets. This patch fixes that. Committed as obvious. Thanks, Alex gcc/ChangeLog: * btfout.cc (btf_asm_type): Use PRIu64 instead of %lu for uint64_t. (btf_asm_datasec_type): Likewise. commit e2dc586ecadd2399d5ebb14094d78fff1e6caf55 Author: Alex Coplan Date: Fri Jun 2 16:50:45 2023 btf: Fix -Wformat errors in btfout.cc diff --git a/gcc/btfout.cc b/gcc/btfout.cc index f51ccf73242..1ea68b9e8ba 100644 --- a/gcc/btfout.cc +++ b/gcc/btfout.cc @@ -799,7 +799,7 @@ btf_asm_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd) } dw2_asm_output_data (4, dtd->dtd_data.ctti_name, - "TYPE %lu BTF_KIND_%s '%s'", + "TYPE %" PRIu64 " BTF_KIND_%s '%s'", get_btf_id (dtd->dtd_type), btf_kind_name (btf_kind), dtd->dtd_name); dw2_asm_output_data (4, BTF_TYPE_INFO (btf_kind, btf_kflag, btf_vlen), @@ -967,7 +967,7 @@ btf_asm_datasec_type (ctf_container_ref ctfc, btf_datasec_t ds, ctf_id_t id, size_t stroffset) { dw2_asm_output_data (4, ds.name_offset + stroffset, - "TYPE %lu BTF_KIND_DATASEC '%s'", + "TYPE %" PRIu64 " BTF_KIND_DATASEC '%s'", btf_absolute_datasec_id (id), ds.name); dw2_asm_output_data (4, BTF_TYPE_INFO (BTF_KIND_DATASEC, 0, ds.entries.length ()),
[PATCH][committed] aarch64: Add =r, m and =m, r alternatives to 64-bit vector move patterns
Hi all, We can use the X registers to load and store 64-bit vector modes, we just need to add the alternatives to the mov patterns. This straightforward patch does that and for the pair variants too. For the testcase in the code we now generate the optimal assembly without any superfluous GP<->SIMD moves. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64-simd.md (*aarch64_simd_mov): Add =r,m and =r,m alternatives. (load_pair): Likewise. (vec_store_pair): Likewise. gcc/testsuite/ChangeLog: * gcc.target/aarch64/xreg-vec-modes_1.c: New test. rm64.patch Description: rm64.patch
[PATCH][committed] aarch64: PR target/99195 Annotate dot-product patterns for vec-concat-zero
Hi all, This straightforward patch annotates the dotproduct instructions, including the i8mm ones. Tests included. Nothing unexpected here. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: PR target/99195 * config/aarch64/aarch64-simd.md (dot_prod): Rename to... (dot_prod): ... This. (usdot_prod): Rename to... (usdot_prod): ... This. (aarch64_dot_lane): Rename to... (aarch64_dot_lane): ... This. (aarch64_dot_laneq): Rename to... (aarch64_dot_laneq): ... This. (aarch64_dot_lane): Rename to... (aarch64_dot_lane): ... This. gcc/testsuite/ChangeLog: PR target/99195 * gcc.target/aarch64/simd/pr99195_11.c: New test. dotprod.patch Description: dotprod.patch
[PATCH][committed] aarch64: PR target/99195 Annotate saturating mult patterns for vec-concat-zero
Hi all, This patch goes through the various alphabet soup saturating multiplication patterns, including those in TARGET_RDMA and annotates them with . Many other patterns are widening and always write the full 128-bit vectors so this annotation doesn't apply to them. Nothing out of the ordinary in this patch. Bootstrapped and tested on aarch64-none-linux and aarch64_be-none-elf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: PR target/99195 * config/aarch64/aarch64-simd.md (aarch64_sqdmulh): Rename to... (aarch64_sqdmulh): ... This. (aarch64_sqdmulh_n): Rename to... (aarch64_sqdmulh_n): ... This. (aarch64_sqdmulh_lane): Rename to... (aarch64_sqdmulh_lane): ... This. (aarch64_sqdmulh_laneq): Rename to... (aarch64_sqdmulh_laneq): ... This. (aarch64_sqrdmlh): Rename to... (aarch64_sqrdmlh): ... This. (aarch64_sqrdmlh_lane): Rename to... (aarch64_sqrdmlh_lane): ... This. (aarch64_sqrdmlh_laneq): Rename to... (aarch64_sqrdmlh_laneq): ... This. gcc/testsuite/ChangeLog: PR target/99195 * gcc.target/aarch64/simd/pr99195_1.c: Add tests for qdmulh, qrdmulh. * gcc.target/aarch64/simd/pr99195_10.c: New test. satmul.patch Description: satmul.patch
[PATCH][committed] aarch64: Convert ADDLP and ADALP patterns to standard RTL codes
Hi all, This patch converts the patterns for the integer widen and pairwise-add instructions to standard RTL operations. The pairwise addition withing a vector can be represented as an addition of two vec_selects, one selecting the even elements, and one selecting odd. Thus for the intrinsic vpaddlq_s8 we can generate: (set (reg:V8HI 92) (plus:V8HI (vec_select:V8HI (sign_extend:V16HI (reg/v:V16QI 93 [ a ])) (parallel [ (const_int 0 [0]) (const_int 2 [0x2]) (const_int 4 [0x4]) (const_int 6 [0x6]) (const_int 8 [0x8]) (const_int 10 [0xa]) (const_int 12 [0xc]) (const_int 14 [0xe]) ])) (vec_select:V8HI (sign_extend:V16HI (reg/v:V16QI 93 [ a ])) (parallel [ (const_int 1 [0x1]) (const_int 3 [0x3]) (const_int 5 [0x5]) (const_int 7 [0x7]) (const_int 9 [0x9]) (const_int 11 [0xb]) (const_int 13 [0xd]) (const_int 15 [0xf]) ] Similarly for the accumulating forms where there's an extra outer PLUS for the accumulation. We already have the handy helper functions aarch64_stepped_int_parallel_p and aarch64_gen_stepped_int_parallel defined in aarch64.cc that we can make use of to define the right predicate for the VEC_SELECT PARALLEL. This patch allows us to remove some code iterators and the UNSPEC definitions for SADDLP and UADDLP. UNSPEC_UADALP and UNSPEC_SADALP are retained because they are used by SVE2 patterns still. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64-simd.md (aarch64_adalp): Delete. (aarch64_adalp): New define_expand. (*aarch64_adalp_insn): New define_insn. (aarch64_addlp): Convert to define_expand. (*aarch64_addlp_insn): New define_insn. * config/aarch64/iterators.md (UNSPEC_SADDLP, UNSPEC_UADDLP): Delete. (ADALP): Likewise. (USADDLP): Likewise. * config/aarch64/predicates.md (vect_par_cnst_even_or_odd_half): Define. adalp.patch Description: adalp.patch
[PATCH][committed] aarch64: Reimplement v(r)hadd and vhsub intrinsics with RTL codes
Hi all, This patch reimplements the MD patterns for the UHADD,SHADD,UHSUB,SHSUB,URHADD,SRHADD instructions using standard RTL operations rather than unspecs. The correct RTL representations involves widening the inputs before adding them and halving, followed by a truncation back to the original mode. An unfortunate wart in the patch is that we end up having very similar expanders for the intrinsics through the aarch64_h and aarch64_rhadd names and the standard names for the vector averaging optabs avg3_floor and avg3_ceil. I'd like to reuse avg3_ceil for the intrinsics builtin as well but our scheme in aarch64-simd-builtins.def and aarch64-builtins.cc makes it awkward by only allowing mappings of entries in aarch64-simd-builtins.def to: 0 - CODE_FOR_aarch64_ 1-9 - CODE_FOR_<1-9> 10 - CODE_FOR_ whereas here we want a string after the i.e. CODE_FOR_uavg3_ceil. This patch adds a bit of remapping logic in aarch64-builtins.cc before the construction of the builtin info that remaps the CODE_FOR_* definitions in aarch64-simd-builtins.def to the optab-derived ones. CODE_FOR_aarch64_srhaddv4si gets remapped to CODE_FOR_avgv4si3_ceil, for example. It's a bit specific to this case, but this solution requires the least invasive changes while avoiding having duplicate expanders just for the sake of a different pattern name. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64-builtins.cc (VAR1): Move to after inclusion of aarch64-builtin-iterators.h. Add definition to remap shadd, uhadd, srhadd, urhadd builtin codes for standard optab ones. * config/aarch64/aarch64-simd.md (avg3_floor): Rename to... (avg3_floor): ... This. Expand to RTL codes rather than unspec. (avg3_ceil): Rename to... (avg3_ceil): ... This. Expand to RTL codes rather than unspec. (aarch64_hsub): New define_expand. (aarch64_h): Split into... (*aarch64_h_insn): ... This... (*aarch64_rhadd_insn): ... And this. vrhadd.patch Description: vrhadd.patch
[PATCH][committed] aarch64: PR target/99195 Annotate complex FP patterns for vec-concat-zero
Hi all, This patch annotates the complex add and mla patterns for vec-concat-zero. Testing showed an interesting bug in our MD patterns where they were defined to match: (plus:VHSDF (match_operand:VHSDF 1 "register_operand" "0") (unspec:VHSDF [(match_operand:VHSDF 2 "register_operand" "w") (match_operand:VHSDF 3 "register_operand" "w") (match_operand:SI 4 "const_int_operand" "n")] FCMLA)) but the canonicalisation rules for PLUS require the more "complex" operand to be first so during combine when the new substituted patterns were attempted to be formed combine/recog would try to match: (plus:V2SF (unspec:V2SF [ (reg:V2SF 100) (reg:V2SF 101) (const_int 0 [0]) ] UNSPEC_FCMLA270) (reg:V2SF 99)) instead. This patch fixes the operands of the PLUS RTX in these patterns. Similar patterns for the dot-product instructions already used the right order. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: PR target/99195 * config/aarch64/aarch64-simd.md (aarch64_fcadd): Rename to... (aarch64_fcadd): ... This. Fix canonicalization of PLUS operands. (aarch64_fcmla): Rename to... (aarch64_fcmla): ... This. Fix canonicalization of PLUS operands. (aarch64_fcmla_lane): Rename to... (aarch64_fcmla_lane): ... This. Fix canonicalization of PLUS operands. (aarch64_fcmla_laneqv4hf): Rename to... (aarch64_fcmla_laneqv4hf): ... This. Fix canonicalization of PLUS operands. (aarch64_fcmlaq_lane): Fix canonicalization of PLUS operands. gcc/testsuite/ChangeLog: PR target/99195 * gcc.target/aarch64/simd/pr99195_9.c: New test. cmplx-vcz.patch Description: cmplx-vcz.patch
[PATCH][committed] arm: Implement ACLE Data Intrinsics
Hi all, This patch implements a number of scalar data processing intrinsics from ACLE that were requested by some users. Some of these have fast single-instruction sequences for Armv6 and later, but even for earlier versions they can still emit an inline sequence or a call to libgcc (and ACLE recommends them being unconditionally available). Chris Sidebottom wrote most of the patch, I just cleaned it up, wired up some builtins and adjusted the tests. Bootstrapped and tested on arm-none-linux-gnueabihf. Pushing to trunk. Thanks, Kyrill Co-authored-by: Chris Sidebottom gcc/ChangeLog: 2023-05-24 Chris Sidebottom Kyrylo Tkachov * config/arm/arm.md (rbitsi2): Rename to... (arm_rbit): ... This. (ctzsi2): Adjust for the above. (arm_rev16si2): Convert to define_expand. (arm_rev16si2_alt1): New pattern. (arm_rev16si2_alt): Rename to... (*arm_rev16si2_alt2): ... This. * config/arm/arm_acle.h (__ror, __rorl, __rorll, __clz, __clzl, __clzll, __cls, __clsl, __clsll, __revsh, __rev, __revl, __revll, __rev16, __rev16l, __rev16ll, __rbit, __rbitl, __rbitll): Define intrinsics. * config/arm/arm_acle_builtins.def (rbit, rev16si2): Define builtins. gcc/testsuite/ChangeLog: * gcc.target/arm/acle/data-intrinsics-armv6.c: New test. * gcc.target/arm/acle/data-intrinsics-assembly.c: New test. * gcc.target/arm/acle/data-intrinsics-rbit.c: New test. * gcc.target/arm/acle/data-intrinsics.c: New test. arm-acle.patch Description: arm-acle.patch
[PATCH][committed] aarch64: PR target/99195 Annotate vector shift patterns for vec-concat-zero
Hi all, Continuing the series of straightforward annotations, this one handles the normal (not widening or narrowing) vector shifts. Tests included. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: PR target/99195 * config/aarch64/aarch64-simd.md (aarch64_simd_lshr): Rename to... (aarch64_simd_lshr): ... This. (aarch64_simd_ashr): Rename to... (aarch64_simd_ashr): ... This. (aarch64_simd_imm_shl): Rename to... (aarch64_simd_imm_shl): ... This. (aarch64_simd_reg_sshl): Rename to... (aarch64_simd_reg_sshl): ... This. (aarch64_simd_reg_shl_unsigned): Rename to... (aarch64_simd_reg_shl_unsigned): ... This. (aarch64_simd_reg_shl_signed): Rename to... (aarch64_simd_reg_shl_signed): ... This. (vec_shr_): Rename to... (vec_shr_): ... This. (aarch64_shl): Rename to... (aarch64_shl): ... This. (aarch64_qshl): Rename to... (aarch64_qshl): ... This. gcc/testsuite/ChangeLog: * gcc.target/aarch64/simd/pr99195_1.c: Add testing for shifts. * gcc.target/aarch64/simd/pr99195_6.c: Likewise. * gcc.target/aarch64/simd/pr99195_8.c: New test. shift.patch Description: shift.patch
[PATCH][committed] arm: PR target/109939 Correct signedness of return type of __ssat intrinsics
Hi all, As the PR says we shouldn't be using qualifier_unsigned for the return type of the __ssat intrinsics. UNSIGNED_SAT_BINOP_UNSIGNED_IMM_QUALIFIERS already exists for that. This was just a thinko. This patch fixes this and the warning with -Wconversion goes away. Bootstrapped and tested on arm-none-linux-gnueabihf. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: PR target/109939 * config/arm/arm-builtins.cc (SAT_BINOP_UNSIGNED_IMM_QUALIFIERS): Use qualifier_none for the return operand. gcc/testsuite/ChangeLog: PR target/109939 * gcc.target/arm/pr109939.c: New test. satsign.patch Description: satsign.patch
[PATCH][committed] aarch64: PR target/109855 Add predicate and constraints to define_subst in aarch64-simd.md
Hi all, In this PR we ICE because the substituted pattern for mla "lost" its predicate and constraint for operand 0 because the define_subst template: [(set (match_operand: 0) (vec_concat: (match_dup 1) (match_operand:VDZ 2 "aarch64_simd_or_scalar_imm_zero")))]) Uses match_operand instead of match_dup for operand 0. We can't use match_dup 0 for it because we need to specify the widened mode. The problem is fixed by adding a "register_operand" predicate and "=w" constraint to the match_operand. This makes sense conceptually too as the transformation we're targeting only applies to instructions that write a "w" register. With this change the mddump pattern that ICEs goes from: (define_insn ("aarch64_mlav4hi_vec_concatz_le") [ (set (match_operand:V8HI 0 ("") ("")) <<-- Missing constraint! (vec_concat:V8HI (plus:V4HI (mult:V4HI (match_operand:V4HI 2 ("register_operand") ("w")) (match_operand:V4HI 3 ("register_operand") ("w"))) (match_operand:V4HI 1 ("register_operand") ("0"))) (match_operand:V4HI 4 ("aarch64_simd_or_scalar_imm_zero") ("" ] ("(!BYTES_BIG_ENDIAN) && (TARGET_SIMD)") ("mla\t%0.4h, %2.4h, %3.4h") to the proper: (define_insn ("aarch64_mlav4hi_vec_concatz_le") [ (set (match_operand:V8HI 0 ("register_operand") ("=w")) << Constraint in the right place (vec_concat:V8HI (plus:V4HI (mult:V4HI (match_operand:V4HI 2 ("register_operand") ("w")) (match_operand:V4HI 3 ("register_operand") ("w"))) (match_operand:V4HI 1 ("register_operand") ("0"))) (match_operand:V4HI 4 ("aarch64_simd_or_scalar_imm_zero") ("" ] ("(!BYTES_BIG_ENDIAN) && (TARGET_SIMD)") ("mla\t%0.4h, %2.4h, %3.4h") This seems to do the right thing for multi-alternative patterns as well, the annotated pattern for aarch64_cmltv8qi is: (define_insn ("aarch64_cmltv8qi") [ (set (match_operand:V8QI 0 ("register_operand") ("=w,w")) (neg:V8QI (lt:V8QI (match_operand:V8QI 1 ("register_operand") ("w,w")) (match_operand:V8QI 2 ("aarch64_simd_reg_or_zero") ("w,ZDz") ] whereas the substituted version now looks like: (define_insn ("aarch64_cmltv8qi_vec_concatz_le") [ (set (match_operand:V16QI 0 ("register_operand") ("=w,w")) (vec_concat:V16QI (neg:V8QI (lt:V8QI (match_operand:V8QI 1 ("register_operand") ("w,w")) (match_operand:V8QI 2 ("aarch64_simd_reg_or_zero") ("w,ZDz" (match_operand:V8QI 3 ("aarch64_simd_or_scalar_imm_zero") ("" ] Bootstrapped and tested on aarch64-none-linux-gnu. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: PR target/109855 * config/aarch64/aarch64-simd.md (add_vec_concat_subst_le): Add predicate and constraint for operand 0. (add_vec_concat_subst_be): Likewise. gcc/testsuite/ChangeLog: PR target/109855 * gcc.target/aarch64/pr109855.c: New test. subst-pred.patch Description: subst-pred.patch
[PATCH][committed] aarch64: Cost vector comparisons more accurately
Hi all, We are missing cases for combining of FACGE/FACGT instructions. In the testcase of the patch we generate: foo: fabsv3.4s, v0.4s fabsv0.4s, v1.4s fabsv1.4s, v2.4s fcmgt v0.4s, v3.4s, v0.4s fcmgt v1.4s, v3.4s, v1.4s b g This is because combine is rejecting the pattern due to costs: Successfully matched this instruction: (set (reg:V4SI 106) (neg:V4SI (lt:V4SI (abs:V4SF (reg:V4SF 113)) (abs:V4SF (reg:V4SF 111) rejecting combination of insns 8, 9 and 10 original costs 8 + 8 + 12 = 28 replacement costs 8 + 28 = 36 It is obviously recursing in the various arms of the RTX and such. This patch teaches the aarch64 rtx costs routine that our vector comparisons are represented as a NEG of compare operators, with the FACGE/FAGT operations in particular having ABS on each arm. With this patch we get the much more reasonable dump: original costs 8 + 8 + 8 = 24 replacement costs 8 + 8 = 16 and generate the optimal assembly: foo: mov v31.16b, v0.16b facgt v0.4s, v0.4s, v1.4s facgt v1.4s, v31.4s, v2.4s b g Bootstrapped and tested on aarch64-none-linux-gnu. Pushing to trunk. Thanks, Kyrill gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_rtx_costs, NEG case): Add costing logic for vector modes. gcc/testsuite/ChangeLog: * gcc.target/aarch64/facg_1.c: New test. vcmpcst.patch Description: vcmpcst.patch