Fixed passing padded constant structs in registers on big-endian targets.
Corrects how GCC places padding bytes within constant structs passed in registers on big-endian architectures, resolving a code generation bug.
This commit fixes a code generation bug affecting big-endian targets when passing constant structs in registers. The compiler was incorrectly placing padding within structs narrower than a word size, leading to incorrect data alignment. The fix uses a right shift to correctly align the structure and padding. A new test case validates the fix on PowerPC.
In Details
The load_register_parameters function in calls.cc is responsible for loading function arguments into registers. This commit addresses PR middle-end/124637, where constant structs were being incorrectly laid out in registers on big-endian targets due to improper padding. store_constructor fills fields from the MSB, so padding was ending up in the wrong place. The fix uses a right shift to align the structure within the register. The new test case gcc.target/powerpc/pr124637.c exercises this code path.
For Context
When passing data to functions, compilers often use registers to improve performance. This commit fixes a bug in how GCC handles structures (collections of data) when they're passed in registers on 'big-endian' systems. Big-endian systems store the most significant byte of a multi-byte value first. The bug caused incorrect placement of padding bytes within these structures, leading to incorrect program behavior. The fix ensures data is correctly aligned in registers.