]> git.ipfire.org Git - thirdparty/gcc.git/commit
Disable a broken multiversioning optimisation
authorAndrew Carlotti <andrew.carlotti@arm.com>
Tue, 7 Jan 2025 18:32:23 +0000 (18:32 +0000)
committerAndrew Carlotti <andrew.carlotti@arm.com>
Fri, 10 Jan 2025 14:18:16 +0000 (14:18 +0000)
commitd0191d1631647436c4707ca6b915a46adf591d87
tree209cd834f0a2ec8965476b918e37b304f03bfaaf
parent02b1172dad4c444953868f411fc8dd4483f320e7
Disable a broken multiversioning optimisation

This patch skips redirect_to_specific clone for aarch64 and riscv,
because the optimisation has two flaws:

1. It checks the value of the "target" attribute, even on targets that
don't use this attribute for multiversioning.

2. The algorithm used is too aggressive, and will eliminate the
indirection in some cases where the runtime choice of callee version
can't be determined statically at compile time.  A correct would need to
verify that:
 - if the current caller version were selected at runtime, then the
   chosen callee version would be eligible for selection.
 - if any higher priority callee version were selected at runtime, then
   a higher priority caller version would have been eligble for
   selection (and hence the current caller version wouldn't have been
   selected).

The current checks only verify a more restrictive version of the first
condition, and don't check the second condition at all.

Fixing the optimisation properly would require implementing target hooks
to check for implications between version attributes, which is too
complicated for this stage.  However, I would like to see this hook
implemented in the future, since it could also help deduplicate other
multiversioning code.

Since this behavior has existed for x86 and powerpc for a while, I
think it's best to preserve the existing behavior on those targets,
unless any maintainer for those targets disagrees.

gcc/ChangeLog:

* multiple_target.cc
(redirect_to_specific_clone): Assert that "target" attribute is
used for FMV before checking it.
(ipa_target_clone): Skip redirect_to_specific_clone on some
targets.

gcc/testsuite/ChangeLog:

* g++.target/aarch64/mv-pragma.C: New test.
gcc/multiple_target.cc
gcc/testsuite/g++.target/aarch64/mv-pragma.C [new file with mode: 0644]