aboutsummaryrefslogtreecommitdiff
path: root/gcc/function.cc
diff options
context:
space:
mode:
authorLewis Hyatt <lhyatt@gmail.com>2024-10-29 16:57:12 -0400
committerLewis Hyatt <lhyatt@gcc.gnu.org>2024-11-23 13:44:38 -0500
commitaf6665e1fdcc6bcd42db51845d7cb2f19fbda650 (patch)
tree052afab9811c98cb4b1137f3655c655fdf6c43d1 /gcc/function.cc
parentc488e23f66388a684f4a7e7e38f97d3358225488 (diff)
downloadgcc-af6665e1fdcc6bcd42db51845d7cb2f19fbda650.zip
gcc-af6665e1fdcc6bcd42db51845d7cb2f19fbda650.tar.gz
gcc-af6665e1fdcc6bcd42db51845d7cb2f19fbda650.tar.bz2
gimple: Handle tail padding when computing gimple_ops_offset
The array gimple_ops_offset_[], which is used to find the trailing op[] array for a given gimple struct, is computed assuming that op[] will be found at sizeof(tree) bytes away from the end of the struct. This is only correct if the alignment requirement of a pointer is the same as the alignment requirement of the struct, otherwise there will be padding bytes that invalidate the calculation. On 64-bit platforms, this generally works fine because a pointer has 8-byte alignment and none of the structs make use of more than that. On 32-bit platforms, it also currently works fine because there are no 64-bit integers in the gimple structs. There are 32-bit platforms (e.g. sparc) on which a pointer has 4-byte alignment and a uint64_t has 8-byte alignment. On such platforms, adding a uint64_t to the gimple structs (as will take place when location_t is changed to be 64-bit) causes gimple_ops_offset_ to be 4 bytes too large. It would be nice to use offsetof() to compute the offset exactly, but offsetof() is not guaranteed to work for these types, because they use inheritance and so are not standard layout types. This patch attempts to detect the presence of tail padding by detecting when such padding is reused by inheritance; the padding should generally be reused for the same reason that offsetof() is not available, namely that all the relevant types use inheritance. One could envision systems on which this fix does not go far enough (e.g., if the ABI forbids reuse of tail padding), but it makes things better without affecting anything that currently works. gcc/ChangeLog: * gimple.cc (get_tail_padding_adjustment): New function. (DEFGSSTRUCT): Adjust the computation of gimple_ops_offset_ to be correct in the presence of tail padding.
Diffstat (limited to 'gcc/function.cc')
0 files changed, 0 insertions, 0 deletions