]> 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, 16 Oct 2023 02:05:47 +0000 (21:05 -0500)
committerKewen Lin <linkw@linux.ibm.com>
Mon, 16 Oct 2023 02:05:47 +0000 (21:05 -0500)
commitcc87aaeceea58389b681e3a6a63f95e54f2b59cd
tree371ae99837406e0bb2347fe00764f6f3005b3e15
parent4d22de945430e6f8c33ef98c90a4fad8de0ef41e
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.

(cherry picked from commit 266dfed68b881702e9660889f63408054b7fa9c0)
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]