Hi. This is a patch for the bug 117886.I ran the jit tests on x86-64 and there are as much failures as on the master branch (4). I also ran the jit tests on Aarch64 with another patch and there are much less failures. Iains ran the tests with this patch on Darwin and this fixes the failures of a bunch of tests.
Thanks for the review.
From 4ea0377444f476f4cb1b5f07a3f92cf99d7e5af4 Mon Sep 17 00:00:00 2001 From: Antoni Boucher <boua...@zoho.com> Date: Wed, 4 Dec 2024 19:38:38 -0500 Subject: [PATCH] libgccjit: Fix crash on some targets
gcc/jit/ChangeLog: PR jit/117886 * dummy-frontend.cc: Return NULL_TREE in jit_langhook_pushdecl, handle missing types in tree_type_to_jit_type. --- gcc/jit/dummy-frontend.cc | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/gcc/jit/dummy-frontend.cc b/gcc/jit/dummy-frontend.cc index 773c0e101c0..fc4b21be23e 100644 --- a/gcc/jit/dummy-frontend.cc +++ b/gcc/jit/dummy-frontend.cc @@ -1280,6 +1280,37 @@ recording::type* tree_type_to_jit_type (tree type) recording::type* element_type = tree_type_to_jit_type (inner_type); return element_type->get_pointer (); } + else if (type == unsigned_intTI_type_node) + return new recording::memento_of_get_type (&target_builtins_ctxt, + GCC_JIT_TYPE_UINT128_T); + else if (INTEGRAL_TYPE_P (type)) + { + unsigned int size = tree_to_uhwi (TYPE_SIZE_UNIT (type)); + return target_builtins_ctxt.get_int_type (size, TYPE_UNSIGNED (type)); + } + else if (SCALAR_FLOAT_TYPE_P (type)) + { + unsigned int size = tree_to_uhwi (TYPE_SIZE_UNIT (type)); + enum gcc_jit_types type; + switch (size) + { + case 2: + /* FIXME: Wrong type. Update when Float16 is supported. */ + type = GCC_JIT_TYPE_FLOAT; + break; + case 4: + type = GCC_JIT_TYPE_FLOAT; + break; + case 8: + type = GCC_JIT_TYPE_DOUBLE; + break; + default: + fprintf (stderr, "Unexpected float size: %d\n", size); + abort (); + break; + } + return new recording::memento_of_get_type (&target_builtins_ctxt, type); + } else { // Attempt to find an unqualified type when the current type has qualifiers. @@ -1372,7 +1403,8 @@ jit_langhook_global_bindings_p (void) static tree jit_langhook_pushdecl (tree decl ATTRIBUTE_UNUSED) { - gcc_unreachable (); + /* Do nothing to avoid crashing on some targets. */ + return NULL_TREE; } static tree -- 2.47.1