From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2063) id 8708F3858D28; Wed, 15 Dec 2021 08:05:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8708F3858D28 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Kewen Lin To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-9869] rs6000: Remove builtin mask check from builtin_decl [PR102347] X-Act-Checkin: gcc X-Git-Author: Kewen Lin X-Git-Refname: refs/heads/releases/gcc-9 X-Git-Oldrev: 0b868ebf6871d51bdb08c62fd700f8c313a3e910 X-Git-Newrev: 031d42adff2c958cd5bc8457fd89cc5b6f8b8c7b Message-Id: <20211215080503.8708F3858D28@sourceware.org> Date: Wed, 15 Dec 2021 08:05:03 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Dec 2021 08:05:03 -0000 https://gcc.gnu.org/g:031d42adff2c958cd5bc8457fd89cc5b6f8b8c7b commit r9-9869-g031d42adff2c958cd5bc8457fd89cc5b6f8b8c7b Author: Kewen Lin Date: Wed Dec 15 01:16:31 2021 -0600 rs6000: Remove builtin mask check from builtin_decl [PR102347] As the discussion in PR102347, currently builtin_decl is invoked so early, it's when making up the function_decl for builtin functions, at that time the rs6000_builtin_mask could be wrong for those builtins sitting in #pragma/attribute target functions, though it will be updated properly later when LTO processes all nodes. This patch is to align with the practice i386 port adopts, also align with r10-7462 by relaxing builtin mask checking in some places. gcc/ChangeLog: PR target/102347 * config/rs6000/rs6000.c (rs6000_builtin_decl): Remove builtin mask check. gcc/testsuite/ChangeLog: PR target/102347 * gcc.target/powerpc/pr102347.c: New test. (cherry picked from commit 6c7d489a1e6592bc73db03678c1231748fd7a126) Diff: --- gcc/config/rs6000/rs6000.c | 14 ++++---------- gcc/testsuite/gcc.target/powerpc/pr102347.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 62250433c16..a6e683fe2df 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -17110,23 +17110,17 @@ rs6000_init_builtins (void) #endif } -/* Returns the rs6000 builtin decl for CODE. */ +/* Returns the rs6000 builtin decl for CODE. Note that we don't check + the builtin mask here since there could be some #pragma/attribute + target functions and the rs6000_builtin_mask could be wrong when + this checking happens, though it will be updated properly later. */ static tree rs6000_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED) { - HOST_WIDE_INT fnmask; - if (code >= RS6000_BUILTIN_COUNT) return error_mark_node; - fnmask = rs6000_builtin_info[code].mask; - if ((fnmask & rs6000_builtin_mask) != fnmask) - { - rs6000_invalid_builtin ((enum rs6000_builtins)code); - return error_mark_node; - } - return rs6000_builtin_decls[code]; } diff --git a/gcc/testsuite/gcc.target/powerpc/pr102347.c b/gcc/testsuite/gcc.target/powerpc/pr102347.c new file mode 100644 index 00000000000..55e5374bfac --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr102347.c @@ -0,0 +1,19 @@ +/* { dg-do link } */ +/* { dg-skip-if "" { powerpc*-*-aix* } } */ +/* { dg-require-effective-target powerpc_p9modulo_ok } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-flto -mdejagnu-cpu=power8" } */ + +/* Verify there are no error messages in LTO mode. */ + +#pragma GCC target "cpu=power9" +int main () +{ + int res; +#ifdef __LP64__ + res = (int) __builtin_darn (); +#else + res = __builtin_darn_32 (); +#endif + return res; +}