On 12/1/23 08:10, Alexandre Oliva wrote:
On Dec 1, 2023, Alexandre Oliva <ol...@adacore.com> wrote:
Also tested on arm-eabi, but it's *not* enough (or needed) to fix the
PR, there's another bug lurking there, with a separate patch coming
up.
Here it is.
----
The computation of apply_args_size and apply_result_size is saved in a
static variable, so that the corresponding _mode arrays are
initialized only once. That is not compatible with switchable
targets, and ARM's arm_set_current_function, by saving and restoring
target globals, exercises this problem with a testcase such as that in
the PR, in which more than one function in the translation unit calls
__builtin_apply or __builtin_return, respectively.
This patch moves the _size statics into the target_builtins array,
with a bit of ugliness over _plus_one so that zero initialization of
the struct does the right thing.
Regstrapped on x86_64-linux-gnu, tested on arm-eabi with and without the
upthread patch. It fixes the hardcfr fails either way. As for the
ugliness, there's a follow up patch below that attempts to alleviate it
a little (also regstrapped and tested), but I'm not sure we want to go
down that path. WDYT?
It's a wart, but doesn't seem too bad to me.
for gcc/ChangeLog
PR target/112334
* builtins.h (target_builtins): Add fields for apply_args_size
and apply_result_size.
* builtins.cc (apply_args_size, apply_result_size): Cache
results in fields rather than in static variables.
(get_apply_args_size, set_apply_args_size): New.
(get_apply_result_size, set_apply_result_size): New.
OK.
untyped calls: use wrapper class type for implicit plus_one
Instead of get and set macros to apply a delta, use a single macro
that resorts to a temporary wrapper class to apply it.
To be combined (or not) with the previous patch.
I'd be OK with this as well.
jeff