https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128670
--- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> ---
Sashiko said:
--q--
In classify_argument in gcc/config/i386/i386.cc, this change introduces a
wrong-code x86-64 psABI calling-convention regression for aggregates
containing zero-sized arrays or arrays of zero-sized elements at a byte
offset not divisible by 8.
--/q--
A follow-on patch:
--cut here--
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 36443b499e7..e50d6654eed 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -2417,7 +2417,7 @@ classify_argument (machine_mode mode, const_tree type,
tree elt_type = TREE_TYPE (type);
HOST_WIDE_INT elt_bytes = int_size_in_bytes (elt_type);
- if (elt_bytes <= 0)
+ if (elt_bytes < 0)
return 0;
/* An array larger than two eightbytes is passed in registers
@@ -2426,7 +2426,10 @@ classify_argument (machine_mode mode, const_tree type,
if (words > 2 && elt_bytes != bytes)
return 0;
- for (HOST_WIDE_INT k = 0; k * elt_bytes < bytes; k++)
+ /* A zero-sized array is classified by classifying one element. */
+ HOST_WIDE_INT nelts = bytes > 0 ? bytes / elt_bytes : 1;
+
+ for (HOST_WIDE_INT k = 0; k < nelts; k++)
{
int elt_offset = k * elt_bytes * BITS_PER_UNIT;
int pos = (elt_offset + (bit_offset % 64)) / 8 / 8;
--cut here--