From c98bd673ef93836f03491201f1c63929ea429cd6 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 27 May 2020 09:44:07 -0400 Subject: jit: use deep unsharing of trees [PR 95314] PR jit/95314 reports a internal error inside verify_gimple, which turned out to be due to reusing the result of gcc_jit_lvalue_get_address in several functions, leading to tree nodes shared between multiple function bodies. This patch fixes the issue by adopting the "Deep unsharing" strategy described in the comment in gimplify.c preceding mostly_copy_tree_r: to mark all of the jit "frontend"'s expression tree nodes with TREE_VISITED, and to set LANG_HOOKS_DEEP_UNSHARING, so that "they are unshared on the first reference within functions when the regular unsharing algorithm runs". gcc/jit/ChangeLog: PR jit/95314 * dummy-frontend.c (LANG_HOOKS_DEEP_UNSHARING): Define to be true. * jit-playback.h (gcc::jit::playback::rvalue): Mark tree node with TREE_VISITED. gcc/testsuite/ChangeLog: PR jit/95314 * jit.dg/all-non-failing-tests.h: Add test-pr95314-rvalue-reuse.c. * jit.dg/test-pr95314-rvalue-reuse.c: New test. --- gcc/jit/dummy-frontend.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/jit/dummy-frontend.c') diff --git a/gcc/jit/dummy-frontend.c b/gcc/jit/dummy-frontend.c index 27fe9d3..6c7b799 100644 --- a/gcc/jit/dummy-frontend.c +++ b/gcc/jit/dummy-frontend.c @@ -269,6 +269,9 @@ jit_langhook_getdecls (void) #undef LANG_HOOKS_GETDECLS #define LANG_HOOKS_GETDECLS jit_langhook_getdecls +#undef LANG_HOOKS_DEEP_UNSHARING +#define LANG_HOOKS_DEEP_UNSHARING true + struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; #include "gt-jit-dummy-frontend.h" -- cgit v1.1