]> git.ipfire.org Git - thirdparty/gcc.git/commit
rs6000: Use default target option node for callee by default [PR111380]
authorKewen Lin <linkw@linux.ibm.com>
Mon, 25 Sep 2023 05:27:59 +0000 (00:27 -0500)
committerKewen Lin <linkw@linux.ibm.com>
Mon, 25 Sep 2023 05:27:59 +0000 (00:27 -0500)
commit266dfed68b881702e9660889f63408054b7fa9c0
tree4e5981bbd63b1e57ea283526077b4aee053fec7f
parent39bab88b42da134c9979ed995d1aa7d45694ef3d
rs6000: Use default target option node for callee by default [PR111380]

As PR111380 (and the discussion in related PRs) shows, for
now how function rs6000_can_inline_p treats the callee
without any target option node is wrong.  It considers it's
always safe to inline this kind of callee, but actually its
target flags are from the command line options
(target_option_default_node), it's possible that the flags
of callee don't satisfy the condition of inlining, but it
is still inlined, then result in unexpected consequence.

As the associated test case pr111380-1.c shows, the caller
main is attributed with power8, but the callee foo is
compiled with power9 from command line, it's unexpected to
make main inline foo since foo can contain something that
requires power9 capability.  Without this patch, for lto
(with -flto) we can get error message (as it forces the
callee to have a target option node), but for non-lto, it's
inlined unexpectedly.

This patch is to make callee adopt target_option_default_node
when it doesn't have a target option node, it can avoid wrong
inlining decision and fix the inconsistency between LTO and
non-LTO.  It also aligns with what the other ports do.

PR target/111380

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_can_inline_p): Adopt
target_option_default_node when the callee has no option
attributes, also simplify the existing code accordingly.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr111380-1.c: New test.
* gcc.target/powerpc/pr111380-2.c: New test.
gcc/config/rs6000/rs6000.cc
gcc/testsuite/gcc.target/powerpc/pr111380-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/pr111380-2.c [new file with mode: 0644]