https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64166

--- Comment #2 from dmalcolm at gcc dot gnu.org ---
(In reply to Richard Biener from comment #1)
> Huh, I think you rather want a "stable" introspection (plugin) API.  Like the
> treeish one that was proposed at some point but never was finished up.  The
> JIT should provide the modification API only.

Perhaps eventually, but that would involve a *lot* of changes:
  (A) writing this new API
  (B) having it be usable from the JIT API
  (C) probably other things I haven't thought of yet.

I hope to tackle (A) and (B) in the gcc 6 timeframe.

In the meantime, I have a mostly-working way of getting at the dumps via a new
gcc_jit_context_enable_dump entrypoint, which looks like this:

static char *trig_sincos_dump;
static char *trig_statistics_dump;

static void
create_test_of_builtin_trig (gcc_jit_context *ctxt)
{
  /* snip */
  gcc_jit_context_enable_dump (ctxt,
                   "tree-sincos",
                   &trig_sincos_dump);
  gcc_jit_context_enable_dump (ctxt,
                   "statistics",
                   &trig_statistics_dump);
  /* snip */
}

static void
verify_test_of_builtin_trig (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  /* snip */
  /* PR jit/64020:
     The "sincos" pass merges sin/cos calls into the cexpi builtin.
     Verify that a dump of the "sincos" pass was provided, and that it
     shows a call to the cexpi builtin on a SSA name of "theta".  */
  CHECK_NON_NULL (trig_sincos_dump);
  CHECK_STRING_CONTAINS (trig_sincos_dump, " = __builtin_cexpi (theta_");
  free (trig_sincos_dump);

  /* Similarly, verify that the statistics dump was provided, and that
     it shows the sincos optimization.  */
  CHECK_NON_NULL (trig_statistics_dump);
  CHECK_STRING_CONTAINS (
    trig_statistics_dump,
    "sincos \"sincos statements inserted\" \"test_of_builtin_trig\" 1");
  free (trig_statistics_dump);
}

I'm also experimenting with an API of capturing/verifying statistics:
  gcc_jit_context_set_bool_option (ctxt,
                   GCC_JIT_BOOL_OPTION_GATHER_STATISTICS,
                   1);
where the verify hook has:
  /* We expect exactly one sincos statement to be inserted.  */
  int sincos_count =
    gcc_jit_result_get_int_statistic (result,
                      "sincos statements inserted");
  if (sincos_count == 1)
    pass ("%s: %i sincos statements inserted", test, sincos_count);
  else
    fail ("%s: %i sincos statements inserted", test, sincos_count);

(again, I have this mostly working already, but it might be nice to provide a
richer querying API e.g. for narrowing things down e.g. to a particular
function).

Reply via email to