Hi Richard, Unfortunately, I don't see any way that this will be useful for the ppc targets. We don't have a way to force resolution of a condition prior to continuing speculation, so this will just introduce another comparison that we would speculate past. For our mitigation we will have to introduce an instruction that halts all speculation at that point, and place it in front of all dangerous loads. I wish it were otherwise.
Thanks, Bill > On Jan 4, 2018, at 7:58 AM, Richard Earnshaw <richard.earns...@arm.com> wrote: > > > This patch adds generic support for the new builtin > __builtin_load_no_speculate. It provides the overloading of the > different access sizes and a default fall-back expansion for targets > that do not support a mechanism for inhibiting speculation. > > * builtin_types.def (BT_FN_I1_CONST_VPTR_CONST_VPTR_CONST_VPTR_VAR): > New builtin type signature. > (BT_FN_I2_CONST_VPTR_CONST_VPTR_CONST_VPTR_VAR): Likewise. > (BT_FN_I4_CONST_VPTR_CONST_VPTR_CONST_VPTR_VAR): Likewise. > (BT_FN_I8_CONST_VPTR_CONST_VPTR_CONST_VPTR_VAR): Likewise. > (BT_FN_I16_CONST_VPTR_CONST_VPTR_CONST_VPTR_VAR): Likewise. > * builtins.def (BUILT_IN_LOAD_NO_SPECULATE_N): New builtin. > (BUILT_IN_LOAD_NO_SPECULATE_1): Likewise. > (BUILT_IN_LOAD_NO_SPECULATE_2): Likewise. > (BUILT_IN_LOAD_NO_SPECULATE_4): Likewise. > (BUILT_IN_LOAD_NO_SPECULATE_8): Likewise. > (BUILT_IN_LOAD_NO_SPECULATE_16): Likewise. > * target.def (inhibit_load_speculation): New hook. > * doc/tm.texi.in (TARGET_INHIBIT_LOAD_SPECULATION): Add to > documentation. > * doc/tm.texi: Regenerated. > * doc/cpp.texi: Document __HAVE_LOAD_NO_SPECULATE. > * doc/extend.texi: Document __builtin_load_no_speculate. > * c-family/c-common.c (load_no_speculate_resolve_size): New function. > (load_no_speculate_resolve_params): New function. > (load_no_speculate_resolve_return): New function. > (resolve_overloaded_builtin): Handle overloading > __builtin_load_no_speculate. > * builtins.c (expand_load_no_speculate): New function. > (expand_builtin): Handle new no-speculation builtins. > * targhooks.h (default_inhibit_load_speculation): Declare. > * targhooks.c (default_inhibit_load_speculation): New function. > --- > gcc/builtin-types.def | 16 +++++ > gcc/builtins.c | 99 ++++++++++++++++++++++++++ > gcc/builtins.def | 22 ++++++ > gcc/c-family/c-common.c | 164 ++++++++++++++++++++++++++++++++++++++++++++ > gcc/c-family/c-cppbuiltin.c | 5 +- > gcc/doc/cpp.texi | 4 ++ > gcc/doc/extend.texi | 53 ++++++++++++++ > gcc/doc/tm.texi | 6 ++ > gcc/doc/tm.texi.in | 2 + > gcc/target.def | 20 ++++++ > gcc/targhooks.c | 69 +++++++++++++++++++ > gcc/targhooks.h | 3 + > 12 files changed, 462 insertions(+), 1 deletion(-) > > <0001-builtins-Generic-support-for-__builtin_load_no_specu.patch>