diff options
author | David Malcolm <dmalcolm@redhat.com> | 2020-05-27 09:44:07 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2020-05-27 14:26:08 -0400 |
commit | c98bd673ef93836f03491201f1c63929ea429cd6 (patch) | |
tree | 90d7eb25aa472f26263211afd48bbc5efa65bb90 /gcc/jit | |
parent | ac43b32ce2e0e38848d06a1567f6db2bbeb678dc (diff) | |
download | gcc-c98bd673ef93836f03491201f1c63929ea429cd6.zip gcc-c98bd673ef93836f03491201f1c63929ea429cd6.tar.gz gcc-c98bd673ef93836f03491201f1c63929ea429cd6.tar.bz2 |
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.
Diffstat (limited to 'gcc/jit')
-rw-r--r-- | gcc/jit/dummy-frontend.c | 3 | ||||
-rw-r--r-- | gcc/jit/jit-playback.h | 7 |
2 files changed, 9 insertions, 1 deletions
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" diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h index 074434a..f9b3e67 100644 --- a/gcc/jit/jit-playback.h +++ b/gcc/jit/jit-playback.h @@ -576,7 +576,12 @@ public: rvalue (context *ctxt, tree inner) : m_ctxt (ctxt), m_inner (inner) - {} + { + /* Pre-mark tree nodes with TREE_VISITED so that they can be + deeply unshared during gimplification (including across + functions); this requires LANG_HOOKS_DEEP_UNSHARING to be true. */ + TREE_VISITED (inner) = 1; + } rvalue * as_rvalue () { return this; } |