From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D9C383858025; Thu, 9 Dec 2021 14:03:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D9C383858025 From: "linkw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/103622] ICE: Segmentation fault (in altivec_resolve_new_overloaded_builtin) Date: Thu, 09 Dec 2021 14:03:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: error-recovery X-Bugzilla-Severity: normal X-Bugzilla-Who: linkw at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Dec 2021 14:03:09 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103622 --- Comment #3 from Kewen Lin --- > One thought seems to check instance->fntype first and take (skip) it as > mismatch if it's NULL. This looks like a bad idea, to use long double as the type instead of float= 128 when type float128 isn't supported might be better. diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c index d2e9c4ce547..2b87eef1412 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.c +++ b/gcc/config/rs6000/rs6000-gen-builtins.c @@ -2473,6 +2473,39 @@ write_fntype_init (char *str) fprintf (init_file, ",\n\t\t\t\t"); } fprintf (init_file, "NULL_TREE);\n"); + + /* Use long_double_type_node instead if float128_type_node isn't + supported, it's to avoid unexpected function types. */ + if (tf_found) + { + char *buf1 =3D strdup (str); + fprintf (init_file, " else\n "); + fprintf (init_file, " %s\n =3D build_function_type_list (", buf1= ); + tok =3D strtok (buf1, "_"); + if (!strcmp ("tf", tok)) + write_type_node ("ld", true); + else + write_type_node (tok, true); + tok =3D strtok (0, "_"); + tok =3D strtok (0, "_"); + if (tok) + fprintf (init_file, ",\n\t\t\t\t"); + + /* Note: A function with no arguments ends with '_ftype_v'. */ + while (tok && strcmp (tok, "v")) + { + if (!strcmp ("tf", tok)) + write_type_node ("ld", true); + else + write_type_node (tok, true); + tok =3D strtok (0, "_"); + fprintf (init_file, ",\n\t\t\t\t"); + } + fprintf (init_file, "NULL_TREE);\n"); + + free (buf1); + } + free (buf); } The above hacking make the segfault gone and it will emit: test.c: In function =E2=80=98get_float128_exponent=E2=80=99: test.c:6:5: error: =E2=80=98__builtin_vsx_scalar_extract_expq=E2=80=99 requ= ires ISA 3.0 IEEE 128-bit floating point 6 | return __builtin_vec_scalar_extract_exp (a); | ^~~~~~ test.c:6:5: note: overloaded builtin =E2=80=98__builtin_vec_scalar_extract_= exp=E2=80=99 is implemented by builtin =E2=80=98__builtin_vsx_scalar_extract_expq=E2=80=99=