On Mon, Jan 9, 2017 at 11:43 AM, Eric Botcazou <ebotca...@adacore.com> wrote: > Hi, > > this is a regression present on all active branches for big-endian targets > returning small aggregate types in registers under certain circumstances and > when optimization is enabled: when the bitfield path of store_field is taken, > the function ends up calling store_bit_field to store the value. Now the > behavior of store_bit_field is awkward when the mode is BLKmode: it always > takes its value from the lsb up to the word size but expects it left justified > beyond it (see expmed.c:890 and below) and I missed that when I got rid of the > stack temporaries that were originally generated in that case. > > Of course that's OK for little-endian targets but not for big-endian targets, > and I have a couple of C++ testcases exposing the issue on SPARC 64-bit and a > couple of Ada testcases exposing the issue on PowerPC with the SVR4 ABI (the > Linux ABI is immune since it always returns on the stack); I think they cover > all the cases in the problematic code. > > The attached fix was tested on a bunch of platforms: x86/Linux, x86-64/Linux, > PowerPC/Linux, PowerPC64/Linux, PowerPC/VxWorks, Aarch64/Linux, SPARC/Solaris > and SPARC64/Solaris with no regressions. OK for the mainline? other branches?
Ok for trunk and branches after a short burn-in. Thanks, Richard. > > 2017-01-09 Eric Botcazou <ebotca...@adacore.com> > > * expr.c (store_field): In the bitfield case, if the value comes from > a function call and is of an aggregate type returned in registers, do > not modify the field mode; extract the value in all cases if the mode > is BLKmode and the size is not larger than a word. > > > 2017-01-09 Eric Botcazou <ebotca...@adacore.com> > > * g++.dg/opt/call2.C: New test. > * g++.dg/opt/call3.C: Likewise. > * gnat.dg/array26.adb: New test. > * gnat.dg/array26_pkg.ad[sb]: New helper. > * gnat.dg/array27.adb: New test. > * gnat.dg/array27_pkg.ad[sb]: New helper. > * gnat.dg/array28.adb: New test. > * gnat.dg/array28_pkg.ad[sb]: New helper. > > -- > Eric Botcazou