On 2026/10/26 18:39, Jonathan Wakely wrote: > On Mon, 26 Oct 2026 at 08:48, Richard Biener <[email protected]> > wrote: >> >> On Sun, Oct 25, 2026 at 8:27 AM Zhongteng Gui <[email protected]> >> wrote: >>> >>> On 2026/10/22 16:29, Zhongteng Gui wrote: >>>> From 7b974976c2245e8c230569fa356d031965a42c41 Mon Sep 17 00:00:00 2001 >>>> From: Zhongteng Gui <[email protected]> >>>> Date: Thu, 22 Oct 2026 00:58:17 +0800 >>>> Subject: [PATCH 1/4] i386: Remove outdated message from GCC 4.6 (passing >>>> aligned parameter) [PR128083] >>>> >>>> This removes "the ABI for passing parameters with %d-byte alignment has >>>> changed in GCC 4.6". It has been 15 years since then. >>>> >>>> gcc/ChangeLog: >>>> >>>> * config/i386/i386.cc (ix86_compat_function_arg_boundary): >>>> Removed. No longer used anywhere. >>>> (ix86_function_arg_boundary): Don't warn for ABI change from GCC >>>> 4.6. >>>> >>>> gcc/testsuite/ChangeLog: >>>> >>>> * gcc.target/i386/pr68657.c: Remove dg-message. >>>> >>>> Signed-off-by: Zhongteng Gui <[email protected]> >>>> --- >>>> gcc/config/i386/i386.cc | 50 ------------------------- >>>> gcc/testsuite/gcc.target/i386/pr68657.c | 1 - >>>> 2 files changed, 51 deletions(-) >>>> >>> From 25997652f50c71430f222f6c28349e9722b5f6e6 Mon Sep 17 00:00:00 2001 >>> From: Zhongteng Gui <[email protected]> >>> Date: Thu, 22 Oct 2026 00:58:17 +0800 >>> Subject: [PATCH v2 1/4] i386: Remove outdated message from GCC 4.6 (passing >>> aligned parameter) [PR128083] >>> >>> This removes "the ABI for passing parameters with %d-byte alignment has >>> changed in GCC 4.6". It has been 15 years since then. >>> >>> Also removes now-unused functions ix86_compat_function_arg_boundary and >>> ix86_compat_aligned_value_p. >> >> As indicated in the PR we should never prune those, instead a >> -Wpsabi=<version> >> option should handle the version to report ABI changes against and -Wpsabi >> might get a reasonable default version for that. > > Yes, adding controls for the diagnostics is the right approach, not > ripping them out.
Thanks, then how about the following patch? --- >From 4a7790ce12e952d981e3f4badb4f8e6a234fb726 Mon Sep 17 00:00:00 2001 From: Zhongteng Gui <[email protected]> Date: Thu, 22 Oct 2026 00:58:17 +0800 Subject: [PATCH v3] i386: Make historical GCC 4.x psABI notes opt-in [PR128083] The x86 backend still emits notes by default for ABI changes introduced in GCC 4.4 and GCC 4.6. These notes remain useful when checking compatibility with older compilers, but are unnecessarily noisy for users who do not need that information. Retain the compatibility checks and notes, but require warn_psabi to be explicitly set as well as enabled. This allows -Wpsabi and -Werror=psabi to enable the historical notes, while enabling -Wabi alone does not enable them. Other psABI diagnostics retain their existing defaults. Update the existing tests to explicitly enable the notes and add coverage for default suppression, explicit suppression, and implicit enablement by -Wabi. Also check that -Wpsabi re-enables the notes after -Wno-psabi. Tested on x86_64-pc-linux-gnu and x86_64-w64-mingw32 with RUNTESTFLAGS= "'i386.exp=pr128083*.c pr68657.c pr39678.c pr39545-*.c pr39082-1.c'" The regression tests were generated with LLM assistance. PR target/128083 gcc/ChangeLog: * config/i386/i386.cc (classify_argument): Require an explicitly enabled -Wpsabi for the GCC 4.4 ABI notes. (ix86_function_arg_boundary): Likewise for the GCC 4.6 ABI note. * doc/invoke.texi (Warning Options): Document explicit enablement of the historical x86 psABI notes. gcc/testsuite/ChangeLog: * gcc.target/i386/pr39082-1.c: Explicitly enable -Wpsabi. * gcc.target/i386/pr39545-1.c: Likewise. * gcc.target/i386/pr39545-2.c: Likewise. * gcc.target/i386/pr39678.c: Check that -Wpsabi re-enables the note after -Wno-psabi. * gcc.target/i386/pr68657.c: Add -mabi=sysv for mingw targets. * gcc.target/i386/pr128083-2.c: New test. * gcc.target/i386/pr128083-3.c: New test. * gcc.target/i386/pr128083.c: New test. Signed-off-by: Zhongteng Gui <[email protected]> --- gcc/config/i386/i386.cc | 7 +-- gcc/doc/invoke.texi | 5 ++ gcc/testsuite/gcc.target/i386/pr128083-2.c | 8 ++++ gcc/testsuite/gcc.target/i386/pr128083-3.c | 8 ++++ gcc/testsuite/gcc.target/i386/pr128083.c | 53 ++++++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr39082-1.c | 2 +- gcc/testsuite/gcc.target/i386/pr39545-1.c | 2 +- gcc/testsuite/gcc.target/i386/pr39545-2.c | 2 +- gcc/testsuite/gcc.target/i386/pr39678.c | 2 +- gcc/testsuite/gcc.target/i386/pr68657.c | 1 + 10 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr128083-2.c create mode 100644 gcc/testsuite/gcc.target/i386/pr128083-3.c create mode 100644 gcc/testsuite/gcc.target/i386/pr128083.c diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index fd664fae18e..23441e2a8a9 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -2378,7 +2378,7 @@ classify_argument (machine_mode mode, const_tree type, { static bool warned; - if (!warned && warn_psabi) + if (!warned && warn_psabi && OPTION_SET_P (warn_psabi)) { warned = true; inform (input_location, @@ -2508,7 +2508,7 @@ classify_argument (machine_mode mode, const_tree type, /* The first one should never be X86_64_X87UP_CLASS. */ gcc_assert (i != 0); - if (!warned && warn_psabi) + if (!warned && warn_psabi && OPTION_SET_P (warn_psabi)) { warned = true; inform (input_location, @@ -2643,7 +2643,7 @@ classify_argument (machine_mode mode, const_tree type, { static bool warned; - if (!warned && warn_psabi) + if (!warned && warn_psabi && OPTION_SET_P (warn_psabi)) { warned = true; inform (input_location, @@ -3883,6 +3883,7 @@ ix86_function_arg_boundary (machine_mode mode, const_tree type) } if (warn_psabi + && OPTION_SET_P (warn_psabi) && !warned && align != ix86_compat_function_arg_boundary (mode, type, saved_align)) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 41be82cb8a5..b68f9c157ac 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -7167,6 +7167,11 @@ incompatible usages and warn you about them. @option{-Wpsabi} is enabled by default, and is also implied by @option{-Wabi}. +On x86 targets, notes about the GCC 4.x ABI changes are only emitted +when @option{-Wpsabi} is explicitly enabled, including by +@option{-Werror=psabi}. Enabling @option{-Wabi} alone does not enable +these historical notes. @option{-Wno-psabi} suppresses them. + @opindex Wchanges-meaning @opindex Wno-changes-meaning @item -Wno-changes-meaning @r{(C++ and Objective-C++ only)} diff --git a/gcc/testsuite/gcc.target/i386/pr128083-2.c b/gcc/testsuite/gcc.target/i386/pr128083-2.c new file mode 100644 index 00000000000..fd88b2157c8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr128083-2.c @@ -0,0 +1,8 @@ +/* PR target/128083 */ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mno-avx -Wpsabi -Wno-psabi" } */ +/* { dg-additional-options "-mabi=sysv" { target x86_64-*-mingw* } } */ + +#include "pr128083.c" + +/* { dg-bogus "ABI .* has changed in GCC 4\\.(4|6)" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/i386/pr128083-3.c b/gcc/testsuite/gcc.target/i386/pr128083-3.c new file mode 100644 index 00000000000..26bb7d8b3b3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr128083-3.c @@ -0,0 +1,8 @@ +/* PR target/128083 */ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mno-avx -Wall -Wextra -Wabi=2" } */ +/* { dg-additional-options "-mabi=sysv" { target x86_64-*-mingw* } } */ + +#include "pr128083.c" + +/* { dg-bogus "ABI .* has changed in GCC 4\\.(4|6)" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/i386/pr128083.c b/gcc/testsuite/gcc.target/i386/pr128083.c new file mode 100644 index 00000000000..5c444f88ce1 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr128083.c @@ -0,0 +1,53 @@ +/* PR target/128083 */ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mno-avx" } */ +/* { dg-additional-options "-mabi=sysv" { target x86_64-*-mingw* } } */ + +struct aligned_value +{ + unsigned char bytes[32]; +} __attribute__((aligned(32))); + +int +aligned_arg (struct aligned_value value) +{ + return value.bytes[0]; +} + +struct complex_value +{ + char c; + __complex__ float value; +}; + +struct complex_value +complex_arg (struct complex_value value) +{ + return value; +} + +struct flexible_value +{ + int value; + int array[]; +}; + +int +flexible_arg (struct flexible_value value) +{ + return value.value; +} + +union long_double_value +{ + long double value; + int integer; +}; + +int +long_double_arg (union long_double_value value) +{ + return value.integer; +} + +/* { dg-bogus "ABI .* has changed in GCC 4\\.(4|6)" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/i386/pr39082-1.c b/gcc/testsuite/gcc.target/i386/pr39082-1.c index 85b5671e920..0a66fe28077 100644 --- a/gcc/testsuite/gcc.target/i386/pr39082-1.c +++ b/gcc/testsuite/gcc.target/i386/pr39082-1.c @@ -1,6 +1,6 @@ /* PR target/39082 */ /* { dg-do compile { target { ! ia32 } } } */ -/* { dg-options "-O2" } */ +/* { dg-options "-O2 -Wpsabi" } */ /* { dg-additional-options "-mabi=sysv" { target x86_64-*-mingw* } } */ union un diff --git a/gcc/testsuite/gcc.target/i386/pr39545-1.c b/gcc/testsuite/gcc.target/i386/pr39545-1.c index e7e41164b25..25d5c34d198 100644 --- a/gcc/testsuite/gcc.target/i386/pr39545-1.c +++ b/gcc/testsuite/gcc.target/i386/pr39545-1.c @@ -1,7 +1,7 @@ /* PR target/39545 */ /* { dg-do compile } */ /* { dg-require-effective-target lp64 } */ -/* { dg-options "-O2" } */ +/* { dg-options "-O2 -Wpsabi" } */ struct flex { diff --git a/gcc/testsuite/gcc.target/i386/pr39545-2.c b/gcc/testsuite/gcc.target/i386/pr39545-2.c index 46deecbe0b4..9f06dc81add 100644 --- a/gcc/testsuite/gcc.target/i386/pr39545-2.c +++ b/gcc/testsuite/gcc.target/i386/pr39545-2.c @@ -1,7 +1,7 @@ /* PR target/39545 */ /* { dg-do compile } */ /* { dg-require-effective-target lp64 } */ -/* { dg-options "-O2" } */ +/* { dg-options "-O2 -Wpsabi" } */ struct flex { diff --git a/gcc/testsuite/gcc.target/i386/pr39678.c b/gcc/testsuite/gcc.target/i386/pr39678.c index c94c002f14b..5b2be5411f9 100644 --- a/gcc/testsuite/gcc.target/i386/pr39678.c +++ b/gcc/testsuite/gcc.target/i386/pr39678.c @@ -1,7 +1,7 @@ /* PR target/39678 */ /* { dg-do compile } */ /* { dg-require-effective-target lp64 } */ -/* { dg-options "-O2" } */ +/* { dg-options "-O2 -Wno-psabi -Wpsabi" } */ struct X { char c; diff --git a/gcc/testsuite/gcc.target/i386/pr68657.c b/gcc/testsuite/gcc.target/i386/pr68657.c index 3480242760f..b73183f404d 100644 --- a/gcc/testsuite/gcc.target/i386/pr68657.c +++ b/gcc/testsuite/gcc.target/i386/pr68657.c @@ -1,5 +1,6 @@ /* PR c/68657 */ /* { dg-options "-mno-avx512f -Werror=psabi" } */ +/* { dg-additional-options "-mabi=sysv" { target x86_64-*-mingw* } } */ typedef int V __attribute__((vector_size (64))); -- 2.56.0.windows.3
