public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: David Malcolm <dmalcolm@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Introduce selftest::locate_file
Date: Wed, 28 Sep 2016 16:33:00 -0000	[thread overview]
Message-ID: <92f48a5e-0df7-a84c-730b-c71ff212e2b6@redhat.com> (raw)
In-Reply-To: <1474505970-4753-1-git-send-email-dmalcolm@redhat.com>

On 09/21/2016 06:59 PM, David Malcolm wrote:
> On Mon, 2016-09-19 at 11:31 -0600, Jeff Law wrote:
>> On 09/16/2016 03:19 PM, David Malcolm wrote:
>>>
>>>> When possible I don't think we want the tests to be target
>>>> specific.
>>>> Hmm, I'm probably about to argue for Bernd's work...  The 71779
>>>> testcase
>>>> is a great example -- it uses high/lo_sum.  Not all targets
>>>> support
>>>> that
>>>> -- as long as we don't try to recognize those insns we're likely
>>>> OK,
>>>> but
>>>> that seems fragile long term.  Having an idealized target means
>>>> we
>>>> can
>>>> ignore much of these issues.
>>>
>>> An alternative would be to pick a specific target for each test.
>> It's an alternative, but not one I particularly like since those
>> tests
>> won't be consistently run.  With an abstracted target like Bernd
>> suggests we ought to be able to make most tests work with the
>> abstracted
>> target and minimize the number of truely target specific tests.
>>
>>
>>>> So I'm real curious, what happens if you run this RTL selftest
>>>> under
>>>> valgrind?  I have the sneaking suspicion that we'll start doing
>>>> some
>>>> uninitialized memory reads.
>>>
>>> I'm seeing various leaks (an htab within linemap_init for all of
>>> the
>>> line_table fixtures), but no uninitialized reads.
>> Wow.  I must say I'm surprised.  Good news though.
>>
>>
>>>>   +
>>>>> +  /* Dump taken from comment 2 of PR 71779, of
>>>>> +     "...the relevant memory access coming out of expand"
>>>>> +     with basic block IDs added, and prev/next insns set to
>>>>> +     0 at ends.  */
>>>>> +  const char *input_dump
>>>>> +    = (";; MEM[(struct isl_obj *)&obj1] =
>>>>> &isl_obj_map_vtable;\n"
>>>>> +       "(insn 1045 0 1046 2 (set (reg:SI 480)\n"
>>>>> +       "        (high:SI (symbol_ref:SI
>>>>> (\"isl_obj_map_vtable\")
>>>>> [flags 0xc0] <var_decl 0x7fa0363ea240 isl_obj_map_vtable>)))
>>>>> y.c:12702 -1\n"
>>>>> +       "     (nil))\n"
>>>>> +       "(insn 1046 1045 1047 2 (set (reg/f:SI 479)\n"
>>>>> +       "        (lo_sum:SI (reg:SI 480)\n"
>>>>> +       "            (symbol_ref:SI (\"isl_obj_map_vtable\")
>>>>> [flags
>>>>> 0xc0] <var_decl 0x7fa0363ea240 isl_obj_map_vtable>))) y.c:12702
>>>>> -1\n"
>>>>> +       "     (expr_list:REG_EQUAL (symbol_ref:SI
>>>>> (\"isl_obj_map_vtable\") [flags 0xc0] <var_decl 0x7fa0363ea240
>>>>> isl_obj_map_vtable>)\n"
>>>>> +       "        (nil)))\n"
>>>>> +       "(insn 1047 1046 1048 2 (set (reg:DI 481)\n"
>>>>> +       "        (subreg:DI (reg/f:SI 479) 0)) y.c:12702 -1\n"
>>>>> +       "     (nil))\n"
>>>>> +       "(insn 1048 1047 1049 2 (set (zero_extract:DI (reg/v:DI
>>>>> 191
>>>>> [ obj1D.17368 ])\n"
>>>>> +       "            (const_int 32 [0x20])\n"
>>>>> +       "            (const_int 0 [0]))\n"
>>>>> +       "        (reg:DI 481)) y.c:12702 -1\n"
>>>>> +       "     (nil))\n"
>>>> So looking at this just makes my head hurt.  Escaping, lots of
>>>> quotes,
>>>> unnecessary things in the dump, etc.  The question I would have
>>>> is
>>>> why
>>>> not have a file with the dump and read the file?
>>>
>>> (nods)
>>>
>>> Seems like I need to add a mechanism for telling the selftests
>>> which
>>> directory to load the tests relative to.
>> What about putting them inside the appropriate gcc.target
>> directories?
>> We could have one for the "generic" target assuming we build
>> something
>> like that, the others could live in their target specific directory.
>>
>>
>> jeff
>
> Having selftests that read RTL dumps load them from files rather than
> embedding them as strings in the source requires a way to locate the
> relevant files.
>
> This patch adds a selftest::locate_file function for locating such
> files, relative to "$(SRCDIR)/gcc/testsuite/selftests".  This is
> done via a new argument to -fself-test, which supplies the current
> value of "$(SRCDIR)/gcc" to cc1.
>
> I chose "$(SRCDIR)/gcc/testsuite/selftests", so as to be below
> gcc/testsuite, but not below any of the existing DejaGnu subdirectories,
> to avoid selftest-specific files from being picked up by .exp globbing
> patterns.  We could add target-specific directories below that dir if
> necessary.
>
> I've rewritten the rest of the patch kit to use this to load from .rtl
> dump files within that directory, rather than embedding the dumps as
> string literals in the C source.
>
> The patch also exposes a selftests::path_to_src_gcc, which could be
> used by a selftest to e.g. load a DejaGnu file, so that if need be
> we could share .rtl input files between both -fself-test tests and
> DejaGnu-based tests for the .rtl frontend.
>
> (Depends on the approved-when-needed
>   "[PATCH 2/9] Add selftest::read_file"
>     https://gcc.gnu.org/ml/gcc-patches/2016-09/msg00476.html ).
>
> Successfully bootstrapped&regrtested on x86_64-pc-linux-gnu.
>
> OK for trunk once the dependencies are in?
>
> gcc/ChangeLog:
> 	* Makefile.in (s-selftest) Add $(srcdir) as an argument of
> 	-fself-test.
> 	(selftest-gdb): Likewise.
> 	(selftest-valgrind): Likewise.
> 	* common.opt (fself-test): Rename to...
> 	(fself-test=): ...this, documenting the meaning of the argument.
> 	* selftest-run-tests.c: Include "options.h".
> 	(selftest::run_tests): Initialize selftest::path_to_src_gcc from
> 	flag_self_test.
> 	* selftest.c (selftest::path_to_src_gcc): New global.
> 	(selftest::locate_file): New function.
> 	(selftest::test_locate_file): New function.
> 	(selftest::selftest_c_tests): Call test_locate_file.
> 	* selftest.h (selftest::locate_file): New decl.
> 	(selftest::path_to_src_gcc): New decl.
>
> gcc/testsuite/ChangeLog:
> 	* gcc.dg/cpp/pr71591.c: Add a fake value for the argument of
> 	-fself-test.
> 	* selftests/example.txt: New file.
I do think we should go ahead and plan for a target subdirectory.  With 
that added, this should be OK once dependencies are in.


jeff

  reply	other threads:[~2016-09-28 16:27 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-09  0:01 [PATCH 0/9] RFC: selftests based on RTL dumps David Malcolm
2016-09-09  0:01 ` [PATCH 4/9] Expose forcibly_ggc_collect and run it after all selftests David Malcolm
2016-09-16 20:30   ` Jeff Law
2016-09-09  0:01 ` [PATCH 9/9] cse.c selftests David Malcolm
2016-09-16 20:34   ` Jeff Law
2016-09-16 21:28     ` David Malcolm
2016-09-19 17:37       ` Jeff Law
2016-09-22  3:23         ` [PATCH] Introduce selftest::locate_file David Malcolm
2016-09-28 16:33           ` Jeff Law [this message]
2016-09-09  0:01 ` [PATCH 6/9] df selftests David Malcolm
2016-09-16 20:40   ` Jeff Law
2016-09-16 21:34     ` David Malcolm
2016-09-09  0:01 ` [PATCH 1/9] Introduce class rtx_reader David Malcolm
2016-09-16 22:15   ` Jeff Law
2016-09-21 17:22     ` [PATCH, v2] " David Malcolm
2016-09-21 20:44       ` Richard Sandiford
2016-09-09  0:01 ` [PATCH 8/9] final.c selftests David Malcolm
2016-09-16 21:12   ` Jeff Law
2016-09-16 21:41     ` David Malcolm
2016-09-19 21:38       ` Jeff Law
2016-09-09  0:01 ` [PATCH 2/9] Add selftest::read_file David Malcolm
2016-09-16 21:19   ` Jeff Law
2016-09-09  0:01 ` [PATCH 3/9] selftest.h: add temp_override fixture David Malcolm
2016-09-14 22:24   ` Trevor Saunders
2016-09-16 20:37   ` Jeff Law
2016-09-09  0:01 ` [PATCH 7/9] combine.c selftests David Malcolm
2016-09-16 20:45   ` Jeff Law
2016-09-16 21:39     ` David Malcolm
2016-09-09  0:13 ` [PATCH 5/9] Introduce class function_reader David Malcolm
2016-09-16 21:31   ` Jeff Law
2016-09-16 22:04     ` David Malcolm
2016-09-19 21:39       ` Jeff Law
2016-09-12 14:14 ` [PATCH 0/9] RFC: selftests based on RTL dumps Bernd Schmidt
2016-09-12 18:59   ` David Malcolm
2016-09-13 11:35     ` Bernd Schmidt
2016-09-14 10:33       ` Bernd Schmidt
2016-09-16 20:26       ` Jeff Law
2016-09-16 21:28         ` David Malcolm
2016-09-19 17:50           ` Jeff Law
2016-09-20 14:34             ` Register numbers in RTL dumps (was Re: [PATCH 0/9] RFC: selftests based on RTL dumps) David Malcolm
2016-09-20 14:38               ` Bernd Schmidt
2016-09-20 15:26                 ` Jeff Law
2016-09-20 15:38                   ` Bernd Schmidt
2016-09-20 19:35                   ` David Malcolm
2016-09-21 18:59                     ` [PATCH] print-rtx.c: add 'h', v' and 'p' prefixes to regnos David Malcolm
2016-09-28 16:30                       ` Jeff Law
2016-09-28 16:33                         ` Bernd Schmidt
2016-09-28 17:11                           ` Jeff Law
2016-09-28 17:19                             ` Bernd Schmidt
2016-09-29 13:00                               ` David Malcolm
2016-09-29 17:32                               ` Jeff Law
2016-09-13 20:39     ` [PATCH 0/9] RFC: selftests based on RTL dumps Jeff Law
2016-09-14  8:44       ` Richard Biener
2016-09-16 20:16         ` Jeff Law
2016-09-16 21:27           ` David Malcolm
2016-09-19 12:21             ` Bernd Schmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=92f48a5e-0df7-a84c-730b-c71ff212e2b6@redhat.com \
    --to=law@redhat.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).