https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95306
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by David Malcolm <dmalc...@gcc.gnu.org>: https://gcc.gnu.org/g:bf40f0ba95037f235b007a55a7682646a0578b26 commit r11-647-gbf40f0ba95037f235b007a55a7682646a0578b26 Author: David Malcolm <dmalc...@redhat.com> Date: Tue May 26 09:28:16 2020 -0400 jit: fix missing types for builtins [PR 95306] PR jit/95306 reports that attempts to use builtins __builtin_sadd_overflow" and "__builtin_memcpy" via gcc_jit_context_get_builtin_function lead to inscrutable error messages of the form: unimplemented primitive type for builtin: 42 and: unimplemented primitive type for builtin: 38 The root cause is that jit-builtins.c only implements a subset of the types defined via DEF_PRIMITIVE_TYPE in builtin-types.def. This patch: - implements enough types to enable the above two builtins to be referenced - documents gcc_jit_context_get_builtin_function, and notes the limitation that not all types are supported (supporting some of them would take a lot of extra work) - improves the error message for the unsupported cases - adds a testcase for __builtin_memcpy. This required jit_langhook_global_bindings_p to be implemented (otherwise the assertion there failed deep inside "expand" on the builtin) - adds test coverage for the above gcc/jit/ChangeLog: PR jit/95306 * docs/topics/functions.rst (gcc_jit_context_get_builtin_function): Document. * docs/_build/texinfo/libgccjit.texi: Regenerate. * dummy-frontend.c (jit_langhook_global_bindings_p): Remove gcc_unreachable. * jit-builtins.c (type_names): New array. (get_string_for_type_id): New function. (gcc::jit::builtins_manager::make_primitive_type): Show name of type in error messages. Update cases to reflect the order in builtin-types.def. Implement cases for BT_INT8, BT_INT16, BT_UINT8, BT_CONST_PTR, BT_VOLATILE_PTR, BT_INT_PTR, BT_FLOAT_PTR, BT_CONST_DOUBLE_PTR, BT_SIZE, BT_CONST_SIZE. gcc/testsuite/ChangeLog: PR jit/95306 * jit.dg/all-non-failing-tests.h: Add test-builtin-memcpy.c and test-pr95306-builtin-types.c. * jit.dg/test-builtin-memcpy.c: New test. * jit.dg/test-error-gcc_jit_context_get_builtin_function-unimplemented-type.c: New test. * jit.dg/test-pr95306-builtin-types.c: New test.