* [Bug jit/95314] Sharing a local reference to a global variable in multiple functions results in location references block not in block tree
2020-05-25 13:15 [Bug jit/95314] New: Sharing a local reference to a global variable in multiple functions results in location references block not in block tree bouanto at zoho dot com
@ 2020-05-25 13:20 ` dmalcolm at gcc dot gnu.org
2020-05-25 13:40 ` jakub at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-05-25 13:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95314
--- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Thanks for reporting it; this sounds like a bug.
Please can you use attach a reproducer (e.g. using
gcc_jit_context_dump_reproducer_to_file).
Looking at the backtrace, it looks like a bad interaction with inlining, FWIW.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/95314] Sharing a local reference to a global variable in multiple functions results in location references block not in block tree
2020-05-25 13:15 [Bug jit/95314] New: Sharing a local reference to a global variable in multiple functions results in location references block not in block tree bouanto at zoho dot com
2020-05-25 13:20 ` [Bug jit/95314] " dmalcolm at gcc dot gnu.org
@ 2020-05-25 13:40 ` jakub at gcc dot gnu.org
2020-05-25 14:17 ` dmalcolm at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-05-25 13:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95314
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Generally, most of the trees (with some exceptions) aren't shareable and
shouldn't be used by multiple different functions. During gimplifications the
function body is unshared, but not sure what the JIT FE does exactly.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/95314] Sharing a local reference to a global variable in multiple functions results in location references block not in block tree
2020-05-25 13:15 [Bug jit/95314] New: Sharing a local reference to a global variable in multiple functions results in location references block not in block tree bouanto at zoho dot com
2020-05-25 13:20 ` [Bug jit/95314] " dmalcolm at gcc dot gnu.org
2020-05-25 13:40 ` jakub at gcc dot gnu.org
@ 2020-05-25 14:17 ` dmalcolm at gcc dot gnu.org
2020-05-25 14:18 ` jakub at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-05-25 14:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95314
--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Thanks Jakub, that sounds like the problem: I'm creating a tree per
playback::rvalue (m_inner), and I need to unshare them.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/95314] Sharing a local reference to a global variable in multiple functions results in location references block not in block tree
2020-05-25 13:15 [Bug jit/95314] New: Sharing a local reference to a global variable in multiple functions results in location references block not in block tree bouanto at zoho dot com
` (2 preceding siblings ...)
2020-05-25 14:17 ` dmalcolm at gcc dot gnu.org
@ 2020-05-25 14:18 ` jakub at gcc dot gnu.org
2020-05-25 14:53 ` bouanto at zoho dot com
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-05-25 14:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95314
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
unshare_expr can handle that.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/95314] Sharing a local reference to a global variable in multiple functions results in location references block not in block tree
2020-05-25 13:15 [Bug jit/95314] New: Sharing a local reference to a global variable in multiple functions results in location references block not in block tree bouanto at zoho dot com
` (3 preceding siblings ...)
2020-05-25 14:18 ` jakub at gcc dot gnu.org
@ 2020-05-25 14:53 ` bouanto at zoho dot com
2020-05-25 15:57 ` dmalcolm at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: bouanto at zoho dot com @ 2020-05-25 14:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95314
--- Comment #5 from bouanto at zoho dot com ---
The reproducer generates a file where the function create_code only contains
this:
/* Replay of API calls for ctxt_0x7f8079128680. */
So, no code is actually generated and thus, does not reproduce this issue.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/95314] Sharing a local reference to a global variable in multiple functions results in location references block not in block tree
2020-05-25 13:15 [Bug jit/95314] New: Sharing a local reference to a global variable in multiple functions results in location references block not in block tree bouanto at zoho dot com
` (4 preceding siblings ...)
2020-05-25 14:53 ` bouanto at zoho dot com
@ 2020-05-25 15:57 ` dmalcolm at gcc dot gnu.org
2020-05-27 9:03 ` dmalcolm at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-05-25 15:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95314
--- Comment #6 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Sorry about that; thanks for trying. I think I can figure out a reproducer,
and will try tomorrow.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/95314] Sharing a local reference to a global variable in multiple functions results in location references block not in block tree
2020-05-25 13:15 [Bug jit/95314] New: Sharing a local reference to a global variable in multiple functions results in location references block not in block tree bouanto at zoho dot com
` (5 preceding siblings ...)
2020-05-25 15:57 ` dmalcolm at gcc dot gnu.org
@ 2020-05-27 9:03 ` dmalcolm at gcc dot gnu.org
2020-05-27 12:35 ` bouanto at zoho dot com
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-05-27 9:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95314
--- Comment #7 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Created attachment 48615
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48615&action=edit
Non-reproducing attempt at a reproducer
I attempted to reproduce this, but was unsuccessful. I'm attaching what I have
so far (for gcc/testsuite/jit.dg), but annoyingly this runs successfully.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/95314] Sharing a local reference to a global variable in multiple functions results in location references block not in block tree
2020-05-25 13:15 [Bug jit/95314] New: Sharing a local reference to a global variable in multiple functions results in location references block not in block tree bouanto at zoho dot com
` (6 preceding siblings ...)
2020-05-27 9:03 ` dmalcolm at gcc dot gnu.org
@ 2020-05-27 12:35 ` bouanto at zoho dot com
2020-05-27 12:36 ` bouanto at zoho dot com
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: bouanto at zoho dot com @ 2020-05-27 12:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95314
--- Comment #8 from bouanto at zoho dot com ---
Created attachment 48617
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48617&action=edit
Small example to reproduce the bug
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/95314] Sharing a local reference to a global variable in multiple functions results in location references block not in block tree
2020-05-25 13:15 [Bug jit/95314] New: Sharing a local reference to a global variable in multiple functions results in location references block not in block tree bouanto at zoho dot com
` (7 preceding siblings ...)
2020-05-27 12:35 ` bouanto at zoho dot com
@ 2020-05-27 12:36 ` bouanto at zoho dot com
2020-05-27 12:54 ` dmalcolm at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: bouanto at zoho dot com @ 2020-05-27 12:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95314
--- Comment #9 from bouanto at zoho dot com ---
Actually, it seems I was wrong on the conditions to reproduce this issue.
I managed to create a small example to reproduce the issue.
I attached it to the bug report.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/95314] Sharing a local reference to a global variable in multiple functions results in location references block not in block tree
2020-05-25 13:15 [Bug jit/95314] New: Sharing a local reference to a global variable in multiple functions results in location references block not in block tree bouanto at zoho dot com
` (8 preceding siblings ...)
2020-05-27 12:36 ` bouanto at zoho dot com
@ 2020-05-27 12:54 ` dmalcolm at gcc dot gnu.org
2020-05-27 18:30 ` cvs-commit at gcc dot gnu.org
2020-05-27 18:36 ` dmalcolm at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-05-27 12:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95314
David Malcolm <dmalcolm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2020-05-27
--- Comment #10 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Thanks; I'm seeing the crash with your reproducer.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/95314] Sharing a local reference to a global variable in multiple functions results in location references block not in block tree
2020-05-25 13:15 [Bug jit/95314] New: Sharing a local reference to a global variable in multiple functions results in location references block not in block tree bouanto at zoho dot com
` (9 preceding siblings ...)
2020-05-27 12:54 ` dmalcolm at gcc dot gnu.org
@ 2020-05-27 18:30 ` cvs-commit at gcc dot gnu.org
2020-05-27 18:36 ` dmalcolm at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-27 18:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95314
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:
https://gcc.gnu.org/g:c98bd673ef93836f03491201f1c63929ea429cd6
commit r11-668-gc98bd673ef93836f03491201f1c63929ea429cd6
Author: David Malcolm <dmalcolm@redhat.com>
Date: Wed May 27 09:44:07 2020 -0400
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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/95314] Sharing a local reference to a global variable in multiple functions results in location references block not in block tree
2020-05-25 13:15 [Bug jit/95314] New: Sharing a local reference to a global variable in multiple functions results in location references block not in block tree bouanto at zoho dot com
` (10 preceding siblings ...)
2020-05-27 18:30 ` cvs-commit at gcc dot gnu.org
@ 2020-05-27 18:36 ` dmalcolm at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-05-27 18:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95314
David Malcolm <dmalcolm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #12 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Should be fixed by the above commit.
^ permalink raw reply [flat|nested] 13+ messages in thread