aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorCupertino Miranda <cupertino.miranda@oracle.com>2023-10-31 18:47:03 +0000
committerCupertino Miranda <cupertino.miranda@oracle.com>2023-10-31 18:47:03 +0000
commit327d38f1018341b37f976ed6131a1e1fc4aae89f (patch)
tree851c70fc294c7d49ad9ce8bff4178aac7c9449e5 /libcpp
parent0f1727e25f4440bce00271b1e9cf7e7f9125acf0 (diff)
downloadgcc-327d38f1018341b37f976ed6131a1e1fc4aae89f.zip
gcc-327d38f1018341b37f976ed6131a1e1fc4aae89f.tar.gz
gcc-327d38f1018341b37f976ed6131a1e1fc4aae89f.tar.bz2
bpf: Improvements in CO-RE builtins implementation.
This patch moved the processing of attribute preserve_access_index to its own independent pass in a gimple lowering pass. This approach is more consistent with the implementation of the CO-RE builtins when used explicitly in the code. The attributed type accesses are now early converted to __builtin_core_reloc builtin instead of being kept as an expression in code through out all of the middle-end. This disables the compiler to optimize out or manipulate the expression using the local defined type, instead of assuming nothing is known about this expression, as it should be the case in all of the CO-RE relocations. In the process, also the __builtin_preserve_access_index has been improved to generate code for more complex expressions that would require more then one CO-RE relocation. This turned out to be a requirement, since bpf-next selftests would rely on loop unrolling in order to convert an undefined index array access into a defined one. This seemed extreme to expect for the unroll to happen, and for that reason GCC still generates correct code in such scenarios, even when index access is never predictable or unrolling does not occur. gcc/ChangeLog: * config/bpf/bpf-passes.def (pass_lower_bpf_core): Added pass. * config/bpf/bpf-protos.h: Added prototype for new pass. * config/bpf/bpf.cc (bpf_delegitimize_address): New function. * config/bpf/bpf.md (mov_reloc_core<MM:mode>): Prefixed name with '*'. * config/bpf/core-builtins.cc (cr_builtins) Added access_node to struct. (is_attr_preserve_access): Improved check. (core_field_info): Make use of root_for_core_field_info function. (process_field_expr): Adapted to new functions. (pack_type): Small improvement. (bpf_handle_plugin_finish_type): Adapted to GTY(()). (bpf_init_core_builtins): Changed to new function names. (construct_builtin_core_reloc): Improved implementation. (bpf_resolve_overloaded_core_builtin): Changed how __builtin_preserve_access_index is converted. (compute_field_expr): Corrected implementation. Added access_node argument. (bpf_core_get_index): Added valid argument. (root_for_core_field_info, pack_field_expr) (core_expr_with_field_expr_plus_base, make_core_safe_access_index) (replace_core_access_index_comp_expr, maybe_get_base_for_field_expr) (core_access_clean, core_is_access_index, core_mark_as_access_index) (make_gimple_core_safe_access_index, execute_lower_bpf_core) (make_pass_lower_bpf_core): Added functions. (pass_data_lower_bpf_core): New pass struct. (pass_lower_bpf_core): New gimple_opt_pass class. (pack_field_expr_for_preserve_field) (bpf_replace_core_move_operands): Removed function. (bpf_enum_value_kind): Added GTY(()). * config/bpf/core-builtins.h (bpf_field_info_kind, bpf_type_id_kind) (bpf_type_info_kind, bpf_enum_value_kind): New enum. * config/bpf/t-bpf: Added pass bpf-passes.def to PASSES_EXTRA. gcc/testsuite/ChangeLog: * gcc.target/bpf/core-attr-5.c: New test. * gcc.target/bpf/core-attr-6.c: New test. * gcc.target/bpf/core-builtin-1.c: Corrected * gcc.target/bpf/core-builtin-enumvalue-opt.c: Corrected regular expression. * gcc.target/bpf/core-builtin-enumvalue.c: Corrected regular expression. * gcc.target/bpf/core-builtin-exprlist-1.c: New test. * gcc.target/bpf/core-builtin-exprlist-2.c: New test. * gcc.target/bpf/core-builtin-exprlist-3.c: New test. * gcc.target/bpf/core-builtin-exprlist-4.c: New test. * gcc.target/bpf/core-builtin-fieldinfo-offset-1.c: Extra tests
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions