* [debug-early, jit] Port of jit to debug-early
@ 2015-01-01 0:00 David Malcolm
2015-01-01 0:00 ` Aldy Hernandez
0 siblings, 1 reply; 5+ messages in thread
From: David Malcolm @ 2015-01-01 0:00 UTC (permalink / raw)
To: aldyh; +Cc: gcc-patches, jit, David Malcolm
"jit" isn't part of "all" languages, and currently fails to build on
the aldyh/debug-early branch:
../../src/gcc/jit/jit-playback.c: In member function âvoid gcc::jit::playback::context::write_global_decls_2()â:
../../src/gcc/jit/jit-playback.c:710:20: error: âconst struct gcc_debug_hooksâ has no member named âglobal_declâ
debug_hooks->global_decl (decl);
This patch (on top of today's 1a07de5e93cc9e18d899a6a1b7d01436167ab1b1)
fixes the build of the jit.
"make check-jit" works, with:
# of expected passes 7609
I verified the debuggability of jitted code by hand by
(a) running jit.dg/test-using-globals.c
and inspecting globals, and
(b) running jit.dg/test-fibonacci.c and
single-stepping through the code in gdb:
(gdb) break my_fibonacci
(gdb) run
Breakpoint 1, my_fibonacci (x=10) at /home/david/coding-3/gcc-git-jit-early-debug/src/gcc/testsuite/jit.dg/test-fibonacci.c:19
19 FIRST_LINE + 3: if (x < 2)
(gdb) next
16 FIRST_LINE + 0: int
(gdb) next
19 FIRST_LINE + 3: if (x < 2)
(gdb) next
22 FIRST_LINE + 6: return my_fibonacci (x - 1) + my_fibonacci (x - 2);
OK for your branch?
gcc/jit/ChangeLog:
* dummy-frontend.c (jit_langhook_write_globals): Rename to...
(jit_langhook_post_compilation_parsing_cleanups): ...this, and
eliminate calls to finalize_compilation_unit and
write_global_decls_2.
(LANG_HOOKS_WRITE_GLOBALS): Rename to...
(LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS): ...this and
redirect from jit_langhook_write_globals to
jit_langhook_post_compilation_parsing_cleanups.
* jit-playback.c
(gcc::jit::playback::context::write_global_decls_1): Rename to...
(gcc::jit::playback::context::finalize_global_decls): ...this.
(gcc::jit::playback::context::write_global_decls_1): Delete.
* jit-playback.h
(gcc::jit::playback::context::write_global_decls_1): Rename to...
(gcc::jit::playback::context::finalize_global_decls): ...this.
(gcc::jit::playback::context::write_global_decls_1): Delete.
---
gcc/jit/dummy-frontend.c | 14 +++++---------
gcc/jit/jit-playback.c | 25 ++-----------------------
gcc/jit/jit-playback.h | 4 +---
3 files changed, 8 insertions(+), 35 deletions(-)
diff --git a/gcc/jit/dummy-frontend.c b/gcc/jit/dummy-frontend.c
index 8f7d06a..374df6f 100644
--- a/gcc/jit/dummy-frontend.c
+++ b/gcc/jit/dummy-frontend.c
@@ -222,18 +222,13 @@ jit_langhook_getdecls (void)
}
static void
-jit_langhook_write_globals (void)
+jit_langhook_post_compilation_parsing_cleanups (void)
{
gcc::jit::playback::context *ctxt = gcc::jit::active_playback_ctxt;
gcc_assert (ctxt);
JIT_LOG_SCOPE (ctxt->get_logger ());
- ctxt->write_global_decls_1 ();
-
- /* This is the hook that runs the middle and backends: */
- symtab->finalize_compilation_unit ();
-
- ctxt->write_global_decls_2 ();
+ ctxt->finalize_global_decls ();
}
#undef LANG_HOOKS_NAME
@@ -263,8 +258,9 @@ jit_langhook_write_globals (void)
#undef LANG_HOOKS_GETDECLS
#define LANG_HOOKS_GETDECLS jit_langhook_getdecls
-#undef LANG_HOOKS_WRITE_GLOBALS
-#define LANG_HOOKS_WRITE_GLOBALS jit_langhook_write_globals
+#undef LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS
+#define LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS \
+ jit_langhook_post_compilation_parsing_cleanups
struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index c75c076..0d329b0 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -673,14 +673,13 @@ as_truth_value (tree expr, location *loc)
return expr;
}
-/* For use by jit_langhook_write_globals.
+/* For use by jit_langhook_post_compilation_parsing_cleanups
Calls varpool_node::finalize_decl on each global. */
void
playback::context::
-write_global_decls_1 ()
+finalize_global_decls ()
{
- /* Compare with e.g. the C frontend's c_write_global_declarations. */
JIT_LOG_SCOPE (get_logger ());
int i;
@@ -692,26 +691,6 @@ write_global_decls_1 ()
}
}
-/* For use by jit_langhook_write_globals.
- Calls debug_hooks->global_decl on each global. */
-
-void
-playback::context::
-write_global_decls_2 ()
-{
- /* Compare with e.g. the C frontend's c_write_global_declarations_2. */
- JIT_LOG_SCOPE (get_logger ());
-
- int i;
- tree decl;
- FOR_EACH_VEC_ELT (m_globals, i, decl)
- {
- gcc_assert (TREE_CODE (decl) == VAR_DECL);
- debug_hooks->global_decl (decl);
- }
-}
-
-
/* Construct a playback::rvalue instance (wrapping a tree) for a
unary op. */
diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h
index e9832f0..84d99e4 100644
--- a/gcc/jit/jit-playback.h
+++ b/gcc/jit/jit-playback.h
@@ -215,9 +215,7 @@ public:
return m_recording_ctxt->errors_occurred ();
}
- /* For use by jit_langhook_write_globals. */
- void write_global_decls_1 ();
- void write_global_decls_2 ();
+ void finalize_global_decls ();
private:
void dump_generated_code ();
--
1.8.5.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [debug-early, jit] Port of jit to debug-early
2015-01-01 0:00 ` David Malcolm
@ 2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` Aldy Hernandez
0 siblings, 1 reply; 5+ messages in thread
From: David Malcolm @ 2015-01-01 0:00 UTC (permalink / raw)
To: Aldy Hernandez; +Cc: gcc-patches, jit
[-- Attachment #1: Type: text/plain, Size: 1922 bytes --]
On Fri, 2015-06-05 at 16:18 -0400, David Malcolm wrote:
> On Fri, 2015-06-05 at 15:37 -0400, Aldy Hernandez wrote:
> > On 06/05/2015 03:00 PM, David Malcolm wrote:
> > > "jit" isn't part of "all" languages, and currently fails to build on
> > > the aldyh/debug-early branch:
> >
> > The debug-early work is now in mainline. Feel free to commit when you
> > deem appropriate, since you are the jit maintainer ;-).
>
> Given that it fixes the build of the jit, I've gone ahead and committed
> the patch as-is to trunk (r224170).
>
> > > static void
> > > -jit_langhook_write_globals (void)
> > > +jit_langhook_post_compilation_parsing_cleanups (void)
> > > {
> > > gcc::jit::playback::context *ctxt = gcc::jit::active_playback_ctxt;
> > > gcc_assert (ctxt);
> > > JIT_LOG_SCOPE (ctxt->get_logger ());
> > >
> > > - ctxt->write_global_decls_1 ();
> > > -
> > > - /* This is the hook that runs the middle and backends: */
> > > - symtab->finalize_compilation_unit ();
> > > -
> > > - ctxt->write_global_decls_2 ();
> > > + ctxt->finalize_global_decls ();
> >
> > This hook gets called after the compilation proper has run, and we're
> > trying to avoid it. We're trying to get all the front-ends to finish
> > their thing and avoid depending on the compilation proper.
> >
> > Can you not get this to work without running finalize_global_decls after
> > the compilation proper? If not, then I see no problem with your
> > patch....after all, C++ is still using this hook :(.
>
> Am investigating.
All that it was doing was calling varpool_node::finalize_decl on each
global; it appears that it's OK to instead call that on them as soon as
they're created (despite the name).
I've committed the attached patch to trunk (r224173) which removes the
hook; "make check-jit" gives the same results as before, and I again
hand-tested (with gdb) jit.dg's test-using-global.c and
test-fibonacci.c.
[-- Attachment #2: r224173.patch --]
[-- Type: text/x-patch, Size: 2995 bytes --]
Index: gcc/jit/ChangeLog
===================================================================
--- gcc/jit/ChangeLog (revision 224172)
+++ gcc/jit/ChangeLog (revision 224173)
@@ -1,5 +1,16 @@
2015-06-05 David Malcolm <dmalcolm@redhat.com>
+ * dummy-frontend.c
+ (jit_langhook_post_compilation_parsing_cleanups): Remove.
+ (LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS): Remove
+ * jit-playback.c (gcc::jit::playback::context::new_global): Add
+ call to varpool_node::finalize_decl.
+ (gcc::jit::playback::context::finalize_global_decls): Remove.
+ * jit-playback.h
+ (gcc::jit::playback::context::finalize_global_decls): Remove.
+
+2015-06-05 David Malcolm <dmalcolm@redhat.com>
+
* dummy-frontend.c (jit_langhook_write_globals): Rename to...
(jit_langhook_post_compilation_parsing_cleanups): ...this, and
eliminate calls to finalize_compilation_unit and
Index: gcc/jit/dummy-frontend.c
===================================================================
--- gcc/jit/dummy-frontend.c (revision 224172)
+++ gcc/jit/dummy-frontend.c (revision 224173)
@@ -218,16 +218,6 @@
return NULL;
}
-static void
-jit_langhook_post_compilation_parsing_cleanups (void)
-{
- gcc::jit::playback::context *ctxt = gcc::jit::active_playback_ctxt;
- gcc_assert (ctxt);
- JIT_LOG_SCOPE (ctxt->get_logger ());
-
- ctxt->finalize_global_decls ();
-}
-
#undef LANG_HOOKS_NAME
#define LANG_HOOKS_NAME "libgccjit"
@@ -255,10 +245,6 @@
#undef LANG_HOOKS_GETDECLS
#define LANG_HOOKS_GETDECLS jit_langhook_getdecls
-#undef LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS
-#define LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS \
- jit_langhook_post_compilation_parsing_cleanups
-
struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
#include "gt-jit-dummy-frontend.h"
Index: gcc/jit/jit-playback.c
===================================================================
--- gcc/jit/jit-playback.c (revision 224172)
+++ gcc/jit/jit-playback.c (revision 224173)
@@ -514,6 +514,8 @@
varpool_node::get_create (inner);
+ varpool_node::finalize_decl (inner);
+
m_globals.safe_push (inner);
return new lvalue (this, inner);
@@ -668,24 +670,6 @@
return expr;
}
-/* For use by jit_langhook_post_compilation_parsing_cleanups
- Calls varpool_node::finalize_decl on each global. */
-
-void
-playback::context::
-finalize_global_decls ()
-{
- JIT_LOG_SCOPE (get_logger ());
-
- int i;
- tree decl;
- FOR_EACH_VEC_ELT (m_globals, i, decl)
- {
- gcc_assert (TREE_CODE (decl) == VAR_DECL);
- varpool_node::finalize_decl (decl);
- }
-}
-
/* Construct a playback::rvalue instance (wrapping a tree) for a
unary op. */
Index: gcc/jit/jit-playback.h
===================================================================
--- gcc/jit/jit-playback.h (revision 224172)
+++ gcc/jit/jit-playback.h (revision 224173)
@@ -215,8 +215,6 @@
return m_recording_ctxt->errors_occurred ();
}
- void finalize_global_decls ();
-
private:
void dump_generated_code ();
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [debug-early, jit] Port of jit to debug-early
2015-01-01 0:00 ` Aldy Hernandez
@ 2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` David Malcolm
0 siblings, 1 reply; 5+ messages in thread
From: David Malcolm @ 2015-01-01 0:00 UTC (permalink / raw)
To: Aldy Hernandez; +Cc: gcc-patches, jit
On Fri, 2015-06-05 at 15:37 -0400, Aldy Hernandez wrote:
> On 06/05/2015 03:00 PM, David Malcolm wrote:
> > "jit" isn't part of "all" languages, and currently fails to build on
> > the aldyh/debug-early branch:
>
> The debug-early work is now in mainline. Feel free to commit when you
> deem appropriate, since you are the jit maintainer ;-).
Given that it fixes the build of the jit, I've gone ahead and committed
the patch as-is to trunk (r224170).
> > static void
> > -jit_langhook_write_globals (void)
> > +jit_langhook_post_compilation_parsing_cleanups (void)
> > {
> > gcc::jit::playback::context *ctxt = gcc::jit::active_playback_ctxt;
> > gcc_assert (ctxt);
> > JIT_LOG_SCOPE (ctxt->get_logger ());
> >
> > - ctxt->write_global_decls_1 ();
> > -
> > - /* This is the hook that runs the middle and backends: */
> > - symtab->finalize_compilation_unit ();
> > -
> > - ctxt->write_global_decls_2 ();
> > + ctxt->finalize_global_decls ();
>
> This hook gets called after the compilation proper has run, and we're
> trying to avoid it. We're trying to get all the front-ends to finish
> their thing and avoid depending on the compilation proper.
>
> Can you not get this to work without running finalize_global_decls after
> the compilation proper? If not, then I see no problem with your
> patch....after all, C++ is still using this hook :(.
Am investigating.
Thanks
Dave
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [debug-early, jit] Port of jit to debug-early
2015-01-01 0:00 ` David Malcolm
@ 2015-01-01 0:00 ` Aldy Hernandez
0 siblings, 0 replies; 5+ messages in thread
From: Aldy Hernandez @ 2015-01-01 0:00 UTC (permalink / raw)
To: David Malcolm; +Cc: gcc-patches, jit
On 06/05/2015 05:17 PM, David Malcolm wrote:
> On Fri, 2015-06-05 at 16:18 -0400, David Malcolm wrote:
>> On Fri, 2015-06-05 at 15:37 -0400, Aldy Hernandez wrote:
>>> On 06/05/2015 03:00 PM, David Malcolm wrote:
>>>> "jit" isn't part of "all" languages, and currently fails to build on
>>>> the aldyh/debug-early branch:
>>>
>>> The debug-early work is now in mainline. Feel free to commit when you
>>> deem appropriate, since you are the jit maintainer ;-).
>>
>> Given that it fixes the build of the jit, I've gone ahead and committed
>> the patch as-is to trunk (r224170).
>>
>>>> static void
>>>> -jit_langhook_write_globals (void)
>>>> +jit_langhook_post_compilation_parsing_cleanups (void)
>>>> {
>>>> gcc::jit::playback::context *ctxt = gcc::jit::active_playback_ctxt;
>>>> gcc_assert (ctxt);
>>>> JIT_LOG_SCOPE (ctxt->get_logger ());
>>>>
>>>> - ctxt->write_global_decls_1 ();
>>>> -
>>>> - /* This is the hook that runs the middle and backends: */
>>>> - symtab->finalize_compilation_unit ();
>>>> -
>>>> - ctxt->write_global_decls_2 ();
>>>> + ctxt->finalize_global_decls ();
>>>
>>> This hook gets called after the compilation proper has run, and we're
>>> trying to avoid it. We're trying to get all the front-ends to finish
>>> their thing and avoid depending on the compilation proper.
>>>
>>> Can you not get this to work without running finalize_global_decls after
>>> the compilation proper? If not, then I see no problem with your
>>> patch....after all, C++ is still using this hook :(.
>>
>> Am investigating.
>
> All that it was doing was calling varpool_node::finalize_decl on each
> global; it appears that it's OK to instead call that on them as soon as
> they're created (despite the name).
Perfect. The earlier the better.
In most of the front-ends I think we are calling finalize_decl via
rest_of_decl_compilation which is where we also call the
early_global_decl hook.
>
> I've committed the attached patch to trunk (r224173) which removes the
> hook; "make check-jit" gives the same results as before, and I again
> hand-tested (with gdb) jit.dg's test-using-global.c and
> test-fibonacci.c.
>
Excellent.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [debug-early, jit] Port of jit to debug-early
2015-01-01 0:00 [debug-early, jit] Port of jit to debug-early David Malcolm
@ 2015-01-01 0:00 ` Aldy Hernandez
2015-01-01 0:00 ` David Malcolm
0 siblings, 1 reply; 5+ messages in thread
From: Aldy Hernandez @ 2015-01-01 0:00 UTC (permalink / raw)
To: David Malcolm; +Cc: gcc-patches, jit
On 06/05/2015 03:00 PM, David Malcolm wrote:
> "jit" isn't part of "all" languages, and currently fails to build on
> the aldyh/debug-early branch:
The debug-early work is now in mainline. Feel free to commit when you
deem appropriate, since you are the jit maintainer ;-).
> static void
> -jit_langhook_write_globals (void)
> +jit_langhook_post_compilation_parsing_cleanups (void)
> {
> gcc::jit::playback::context *ctxt = gcc::jit::active_playback_ctxt;
> gcc_assert (ctxt);
> JIT_LOG_SCOPE (ctxt->get_logger ());
>
> - ctxt->write_global_decls_1 ();
> -
> - /* This is the hook that runs the middle and backends: */
> - symtab->finalize_compilation_unit ();
> -
> - ctxt->write_global_decls_2 ();
> + ctxt->finalize_global_decls ();
This hook gets called after the compilation proper has run, and we're
trying to avoid it. We're trying to get all the front-ends to finish
their thing and avoid depending on the compilation proper.
Can you not get this to work without running finalize_global_decls after
the compilation proper? If not, then I see no problem with your
patch....after all, C++ is still using this hook :(.
Thanks for working on this.
Aldy
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-06-05 21:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-01 0:00 [debug-early, jit] Port of jit to debug-early David Malcolm
2015-01-01 0:00 ` Aldy Hernandez
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` David Malcolm
2015-01-01 0:00 ` Aldy Hernandez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).