public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: Weird problem
@ 2015-01-01  0:00 Dibyendu Majumdar
  2015-01-01  0:00 ` Dibyendu Majumdar
  0 siblings, 1 reply; 10+ messages in thread
From: Dibyendu Majumdar @ 2015-01-01  0:00 UTC (permalink / raw)
  To: David Malcolm; +Cc: jit

Thanks, will test tonight.From: David Malcolm
Sent: ‎30/‎06/‎2015 03:24
To: Dibyendu Majumdar
Cc: jit@gcc.gnu.org
Subject: Re: Weird problem
On Mon, 2015-06-29 at 21:38 -0400, David Malcolm wrote:
> On Mon, 2015-06-29 at 21:11 -0400, David Malcolm wrote:
> > On Mon, 2015-06-29 at 22:25 +0100, Dibyendu Majumdar wrote:
> > > On 29 June 2015 at 22:08, David Malcolm <dmalcolm@redhat.com> wrote:
> > >
> > > > Looking at src/lvm.c, I see that the signature of luaV_tonumber and that
> > > > lua_Number can be various types, including "double".
> > > >   int luaV_tonumber_ (const TValue *obj, lua_Number *n)
> > > >
> > >
> > > I am using double as lua_Number.
> > >
> > > > Does the type signature of luaV_tonumber as compiled by the main
> > > > compiler agree with that supplied by gcc_jit_context_new_function?  If
> > > > one of them is e.g. expecting a float *, but the other is expecting a
> > > > double *, then you might get the symptoms you're seeing.
> > > >
> > >
> > > I checked this - I think they match.
> > >
> > > > If that doesn't highlight a cause, maybe you're running into a libgccjit
> > > > bug.  If so, can you generate a reproducer and post it here so I can
> > > > poke at it please?
> > > >
> > >
> > > Attached is a reproducer.
> >
> > Thanks; I'm able to run the reproducer, at least to the point of being
> > able to invoke gcc_jit_context_compile on it.
> >
> > Interestingly, looking at the gimple dump (via
> > GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE), I see:
> >
> >   <float:64> OP_RAVI_TOFLT_n_2_8.0;
> >   <float:64> OP_RAVI_TOFLT_n_2_8.1;
> >   [...snip...]
> >   <float:64> OP_RAVI_TOFLT_n_2_8;
> >   [...snip...]
> >
> > OP_RAVI_TOFLT_if_not_float_2_10:
> >   OP_RAVI_TOFLT_n_2_8.0 = OP_RAVI_TOFLT_n_2_8;
> >   printf ("number %p = %f before call to luaV_number",
> > &OP_RAVI_TOFLT_n_2_8.0, OP_RAVI_TOFLT_n_2_8);
> >   OP_RAVI_TOFLT_n_2_8.1 = OP_RAVI_TOFLT_n_2_8;
> >   [...snip...]
> >   OP_RAVI_TOFLT_n_2_8.1 = OP_RAVI_TOFLT_n_2_8;
> >   D.392 = 0;
> >   D.393 = base + D.392;
> >   D.405 = luaV_tonumber_ (D.393, &OP_RAVI_TOFLT_n_2_8.1);
> >           ^^^^^^^^^^^^^^ here's the call          ^^^^^
> >   comparison_0_12 = D.405 == 0;
> >   if (comparison_0_12 != 0) goto
> > OP_RAVI_TOFLT_if_conversion_failed_2_13; else goto
> > OP_RAVI_TOFLT_if_conversion_ok_2_14;
> >
> > OP_RAVI_TOFLT_done_2_11:
> >   D.390 = L->ci;
> >   base = D.390->u.l.base;
> >   D.399 = 16;
> >   D.400 = base + D.399;
> >   L->top = D.400;
> >   D.394 = cl->p;
> >   D.406 = D.394->sizep;
> >   comparison_0_15 = D.406 > 0;
> >   if (comparison_0_15 != 0) goto OP_RETURN_if_sizep_gt_0_3_16; else goto
> > OP_RETURN_else_sizep_gt_0_3_17;
> >
> > OP_RAVI_TOFLT_if_conversion_failed_2_13:
> >   luaG_runerror (L, "number expected");
> >   goto OP_RAVI_TOFLT_if_conversion_ok_2_14;
> >   OP_RAVI_TOFLT_if_conversion_ok_2_14:
> >   printf ("number ok = %f", OP_RAVI_TOFLT_n_2_8);
> >
> >   [...snip...]
> >
> > which, if I'm reading it right, suggests that the local has effectively
> > been split into three locals during the conversion to gimple, and that a
> > ptr to
> >   OP_RAVI_TOFLT_n_2_8.1
> > is passed to luaV_tonumber_, but
> >   OP_RAVI_TOFLT_n_2_8
> > is then used.
> >
> > This is feeling like a bug at my end; sorry.  I'll continue to
> > investigate.
>
> Definitely looks like a bug at my end.
>
> I've created a minimal reproducer, and filed it as
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66700.
>
> I plan to investigate further tomorrow.
>
> Sorry about this.

Does the attached patch fix it for you?
(it's currently a bit of a hack; hope to get it more robust tomorrow)

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Weird problem
@ 2015-01-01  0:00 Dibyendu Majumdar
  2015-01-01  0:00 ` David Malcolm
  0 siblings, 1 reply; 10+ messages in thread
From: Dibyendu Majumdar @ 2015-01-01  0:00 UTC (permalink / raw)
  To: jit

Hi Dave,

I am trying to debug a problem I am having with one piece of code.

The generated code (snippet) is shown below:

  double OP_RAVI_TOFLT_n_2_8;
  bool comparison_0_12;
  comparison_0_12 = luaV_tonumber_ (&base[(int)0],
&OP_RAVI_TOFLT_n_2_8) == (int)0;
  if (comparison_0_12) goto OP_RAVI_TOFLT_if_conversion_failed_2_13;
else goto OP_RAVI_TOFLT_if_conversion_ok_2_14;

OP_RAVI_TOFLT_if_conversion_ok_2_14:
  (void)printf ("number ok = %f\
", OP_RAVI_TOFLT_n_2_8);


The printf output says that value of OP_RAVI_TOFLT_n_2_8 is 0.0.
Yet the called function luaV_tonumber_() set this to a different value:

Output from luaV_tonumber_():

set *0x7ffe1bb8d298 to 5.600000

Output from JIT code above:

number ok = 0.000000

From the dump it seems that the address of the local variable
OP_RAVI_TOFLT_n_2_8 is being passed to the function. And yet the value
of the variable is its original value which was 0.0.

Any tips on what I should be looking for?

Thanks and Regards
Dibyendu

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-06-30 19:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-01  0:00 Weird problem Dibyendu Majumdar
2015-01-01  0:00 ` Dibyendu Majumdar
2015-01-01  0:00   ` David Malcolm
2015-01-01  0:00 Dibyendu Majumdar
2015-01-01  0:00 ` David Malcolm
2015-01-01  0:00   ` Dibyendu Majumdar
2015-01-01  0:00     ` Dibyendu Majumdar
2015-01-01  0:00     ` David Malcolm
2015-01-01  0:00       ` David Malcolm
2015-01-01  0:00         ` David Malcolm

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).