jit: use deep unsharing of trees [PR 95314]
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 27 May 2020 13:44:07 +0000 (09:44 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 27 May 2020 18:26:08 +0000 (14:26 -0400)
commitc98bd673ef93836f03491201f1c63929ea429cd6
tree90d7eb25aa472f26263211afd48bbc5efa65bb90
parentac43b32ce2e0e38848d06a1567f6db2bbeb678dc
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
gcc/jit/jit-playback.h
gcc/testsuite/jit.dg/all-non-failing-tests.h
gcc/testsuite/jit.dg/test-pr95314-rvalue-reuse.c [new file with mode: 0644]