https://gcc.gnu.org/g:b1cb7a5e273eb3442259981216295d286a7892c7
commit r16-158-gb1cb7a5e273eb3442259981216295d286a7892c7 Author: Dimitar Dimitrov <dimi...@dinux.eu> Date: Sat Jan 11 18:03:15 2025 +0200 testsuite: Skip tests incompatible with generic thunk support Some backends do not define TARGET_ASM_OUTPUT_MI_THUNK. But the generic thunk support cannot emit code for calling variadic methods of multiple-inheritance classes. Example error for pru-unknown-elf: .../gcc/gcc/testsuite/g++.dg/ipa/pr83549.C:7:24: error: generic thunk code fails for method 'virtual void C::_ZThn4_N1C3fooEz(...)' which uses '...' Disable the affected tests for all targets which do not define TARGET_ASM_OUTPUT_MI_THUNK. Ensured that test results with and without this patch for x86_64-pc-linux-gnu are the same. gcc/ChangeLog: * doc/sourcebuild.texi: Document variadic_mi_thunk effective target check. gcc/testsuite/ChangeLog: * g++.dg/ipa/pr83549.C: Require effective target variadic_mi_thunk. * g++.dg/ipa/pr83667.C: Ditto. * g++.dg/torture/pr81812.C: Ditto. * g++.old-deja/g++.jason/thunk3.C: Ditto. * lib/target-supports.exp (check_effective_target_variadic_mi_thunk): New function. Signed-off-by: Dimitar Dimitrov <dimi...@dinux.eu> Diff: --- gcc/doc/sourcebuild.texi | 3 +++ gcc/testsuite/g++.dg/ipa/pr83549.C | 1 + gcc/testsuite/g++.dg/ipa/pr83667.C | 1 + gcc/testsuite/g++.dg/torture/pr81812.C | 1 + gcc/testsuite/g++.old-deja/g++.jason/thunk3.C | 3 ++- gcc/testsuite/lib/target-supports.exp | 31 +++++++++++++++++++++++++++ 6 files changed, 39 insertions(+), 1 deletion(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 0bd987371562..65eeeccb264c 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2957,6 +2957,9 @@ Target supports @code{sysconf}. @item trampolines Target supports trampolines. +@item variadic_mi_thunk +Target supports C++ virtual variadic function calls with multiple inheritance. + @item two_plus_gigs Target supports linking programs with 2+GiB of data. diff --git a/gcc/testsuite/g++.dg/ipa/pr83549.C b/gcc/testsuite/g++.dg/ipa/pr83549.C index 90cf8fe7e0d7..3b4547b71dfc 100644 --- a/gcc/testsuite/g++.dg/ipa/pr83549.C +++ b/gcc/testsuite/g++.dg/ipa/pr83549.C @@ -1,5 +1,6 @@ // PR ipa/83549 // { dg-do compile } +// { dg-require-effective-target variadic_mi_thunk } // { dg-options "-O2" } struct A { virtual ~A (); }; diff --git a/gcc/testsuite/g++.dg/ipa/pr83667.C b/gcc/testsuite/g++.dg/ipa/pr83667.C index a8a5a5adb3ad..ec91a2ebd33d 100644 --- a/gcc/testsuite/g++.dg/ipa/pr83667.C +++ b/gcc/testsuite/g++.dg/ipa/pr83667.C @@ -1,6 +1,7 @@ // { dg-require-alias "" } // { dg-options "-fdump-ipa-inline" } // c++/83667 ICE dumping a static thunk when TARGET_USE_LOCAL_THUNK_ALIAS_P +// { dg-require-effective-target variadic_mi_thunk } struct a diff --git a/gcc/testsuite/g++.dg/torture/pr81812.C b/gcc/testsuite/g++.dg/torture/pr81812.C index b5c621d2beb2..80aed8eb2b67 100644 --- a/gcc/testsuite/g++.dg/torture/pr81812.C +++ b/gcc/testsuite/g++.dg/torture/pr81812.C @@ -1,4 +1,5 @@ // { dg-xfail-if "PR108277" { arm_thumb1 } } +// { dg-require-effective-target variadic_mi_thunk } struct Error { virtual void error(... ) const; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C b/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C index 4e684f9367d3..e894194db1f9 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C @@ -1,5 +1,6 @@ // { dg-do run } -// { dg-skip-if "fails with generic thunk support" { rs6000-*-* powerpc-*-eabi v850-*-* sh-*-* h8*-*-* xtensa*-*-* m32r*-*-* lm32-*-* } } +// { dg-skip-if "fails with generic thunk support" { rs6000-*-* powerpc-*-eabi sh-*-* xtensa*-*-* } } +// { dg-require-effective-target variadic_mi_thunk } // Test that variadic function calls using thunks work right. // Note that this will break on any target that uses the generic thunk // support, because it doesn't support variadic functions. diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 16bb2ae44264..287e51bbfc66 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -659,6 +659,37 @@ proc check_effective_target_trampolines { } { return 1 } +# Return 1 if target supports calling virtual variadic methods +# of multi-inheritance classes. + +proc check_effective_target_variadic_mi_thunk { } { + # These targets do not implement TARGET_ASM_OUTPUT_MI_THUNK. + if { [istarget avr-*-*] + || [istarget bpf-*-*] + || [istarget fr30-*-*] + || [istarget ft32-*-*] + || [istarget amdgcn-*-*] + || [istarget h8300-*-*] + || [istarget iq2000-*-*] + || [istarget lm32-*-*] + || [istarget m32c-*-*] + || [istarget m32r-*-*] + || [istarget mcore-*-*] + || [istarget moxie-*-*] + || [istarget msp430-*-*] + || [istarget nvptx-*-*] + || [istarget pdp11-*-*] + || [istarget pru-*-*] + || [istarget rl78-*-*] + || [istarget rx-*-*] + || [istarget v850-*-*] + || [istarget visium-*-*] } { + + return 0; + } + return 1 +} + # Return 1 if target has limited stack size. proc check_effective_target_stack_size { } {