This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix -fdump-rtl-sms (PR rtl-optimization/52095)


On Fri, Feb 3, 2012 at 8:07 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> On some targets e.g. sms-7.c test fails, because fprintf is called
> with %s format and NULL argument, GLIBC prints for that e.g.
> SMS loop num: 1, file: (null), line: 0
> but it isn't portable. Âprint-rtl.c guards the locator printing with
> Â Â Â Â Â Â/* ÂPretty-print insn locators. ÂIgnore scoping as it is mostly
> Â Â Â Â Â Â Â Âredundant with line number information and do not print anything
> Â Â Â Â Â Â Â Âwhen there is no location information available. Â*/
> Â Â Â Â Â Âif (INSN_LOCATOR (in_rtx) && insn_file (in_rtx))
> Â Â Â Â Â Â Âfprintf(outfile, " %s:%i", insn_file (in_rtx), insn_line (in_rtx));
> which fixes this, but there are 7 different spots that would need adjusting
> in modulo-sched.c, so I've added a helper function for that.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>

Ok with me.

It would be better to try and locate some relevant file:line
information elsewhere(?) instead of silently giving up.

Thanks,
Ayal.


> 2012-02-03 ÂJakub Jelinek Â<jakub@redhat.com>
>
> Â Â Â ÂPR rtl-optimization/52095
> Â Â Â Â* modulo-sched.c (dump_insn_locator): New function.
> Â Â Â Â(loop_canon_p, sms_schedule): Use it.
>
> --- gcc/modulo-sched.c.jj    2011-12-14 08:11:03.000000000 +0100
> +++ gcc/modulo-sched.c Â2012-02-03 13:45:49.137997767 +0100
> @@ -1246,6 +1246,19 @@ loop_single_full_bb_p (struct loop *loop
> Â return true;
> Â}
>
> +/* Dump file:line from INSN's location info to dump_file. Â*/
> +
> +static void
> +dump_insn_locator (rtx insn)
> +{
> + Âif (dump_file && INSN_LOCATOR (insn))
> + Â Â{
> + Â Â Âconst char *file = insn_file (insn);
> + Â Â Âif (file)
> + Â Â Â fprintf (dump_file, " %s:%i", file, insn_line (insn));
> + Â Â}
> +}
> +
> Â/* A simple loop from SMS point of view; it is a loop that is composed of
> Â Âeither a single basic block or two BBs - a header and a latch. Â*/
> Â#define SIMPLE_SMS_LOOP_P(loop) ((loop->num_nodes < 3 ) Â Â Â Â Â Â Â Â Â Â\
> @@ -1271,9 +1284,9 @@ loop_canon_p (struct loop *loop)
> Â Â Â Â{
> Â Â Â Â Ârtx insn = BB_END (loop->header);
>
> - Â Â Â Â fprintf (dump_file, "SMS loop many exits ");
> - Â Â Â Â Â Â Â Â fprintf (dump_file, " %s %d (file, line)\n",
> - Â Â Â Â Â Â Â Â Â Â Â Â Âinsn_file (insn), insn_line (insn));
> + Â Â Â Â fprintf (dump_file, "SMS loop many exits");
> + Â Â Â Â dump_insn_locator (insn);
> + Â Â Â Â fprintf (dump_file, "\n");
> Â Â Â Â}
> Â Â Â return false;
> Â Â }
> @@ -1284,9 +1297,9 @@ loop_canon_p (struct loop *loop)
> Â Â Â Â{
> Â Â Â Â Ârtx insn = BB_END (loop->header);
>
> - Â Â Â Â fprintf (dump_file, "SMS loop many BBs. ");
> - Â Â Â Â fprintf (dump_file, " %s %d (file, line)\n",
> - Â Â Â Â Â Â Â Â Âinsn_file (insn), insn_line (insn));
> + Â Â Â Â fprintf (dump_file, "SMS loop many BBs.");
> + Â Â Â Â dump_insn_locator (insn);
> + Â Â Â Â fprintf (dump_file, "\n");
> Â Â Â Â}
> Â Â Â return false;
> Â Â }
> @@ -1407,13 +1420,13 @@ sms_schedule (void)
> Â Â Â Â }
>
> Â Â Â if (dump_file)
> - Â Â Â{
> - Â Â Â Â rtx insn = BB_END (loop->header);
> -
> - Â Â Â Â fprintf (dump_file, "SMS loop num: %d, file: %s, line: %d\n",
> - Â Â Â Â Â Â Â Â Âloop->num, insn_file (insn), insn_line (insn));
> + Â Â Â {
> + Â Â Â Â rtx insn = BB_END (loop->header);
>
> - Â Â Â}
> + Â Â Â Â fprintf (dump_file, "SMS loop num: %d", loop->num);
> + Â Â Â Â dump_insn_locator (insn);
> + Â Â Â Â fprintf (dump_file, "\n");
> + Â Â Â }
>
> Â Â Â if (! loop_canon_p (loop))
> Â Â Â Â continue;
> @@ -1440,9 +1453,8 @@ sms_schedule (void)
> Â Â Â Â{
> Â Â Â Â Âif (dump_file)
> Â Â Â Â Â Â{
> - Â Â Â Â Â Â fprintf (dump_file, " %s %d (file, line)\n",
> - Â Â Â Â Â Â Â Â Â Â Âinsn_file (tail), insn_line (tail));
> - Â Â Â Â Â Â fprintf (dump_file, "SMS single-bb-loop\n");
> + Â Â Â Â Â Â dump_insn_locator (tail);
> + Â Â Â Â Â Â fprintf (dump_file, "\nSMS single-bb-loop\n");
> Â Â Â Â Â Â Âif (profile_info && flag_branch_probabilities)
> Â Â Â Â Â Â Â Â{
> Â Â Â Â Â Â Â Â Âfprintf (dump_file, "SMS loop-count ");
> @@ -1543,14 +1555,15 @@ sms_schedule (void)
> Â Â Â Â continue;
>
> Â Â Â if (dump_file)
> - Â Â Â{
> - Â Â Â Â rtx insn = BB_END (loop->header);
> + Â Â Â {
> + Â Â Â Â rtx insn = BB_END (loop->header);
>
> - Â Â Â Â fprintf (dump_file, "SMS loop num: %d, file: %s, line: %d\n",
> - Â Â Â Â Â Â Â Â Âloop->num, insn_file (insn), insn_line (insn));
> + Â Â Â Â fprintf (dump_file, "SMS loop num: %d", loop->num);
> + Â Â Â Â dump_insn_locator (insn);
> + Â Â Â Â fprintf (dump_file, "\n");
>
> - Â Â Â Â print_ddg (dump_file, g);
> - Â Â Â}
> + Â Â Â Â print_ddg (dump_file, g);
> + Â Â Â }
>
> Â Â Â get_ebb_head_tail (loop->header, loop->header, &head, &tail);
>
> @@ -1561,9 +1574,8 @@ sms_schedule (void)
>
> Â Â Â if (dump_file)
> Â Â Â Â{
> - Â Â Â Â fprintf (dump_file, " %s %d (file, line)\n",
> - Â Â Â Â Â Â Â Â Âinsn_file (tail), insn_line (tail));
> - Â Â Â Â fprintf (dump_file, "SMS single-bb-loop\n");
> + Â Â Â Â dump_insn_locator (tail);
> + Â Â Â Â fprintf (dump_file, "\nSMS single-bb-loop\n");
> Â Â Â Â Âif (profile_info && flag_branch_probabilities)
> Â Â Â Â Â Â{
> Â Â Â Â Â Â Âfprintf (dump_file, "SMS loop-count ");
> @@ -1705,9 +1717,9 @@ sms_schedule (void)
>
> Â Â Â Â Â if (dump_file)
> Â Â Â Â Â Â {
> - Â Â Â Â Â Â fprintf (dump_file,
> - Â Â Â Â Â Â Â Â Â Â Â"%s:%d SMS succeeded %d %d (with ii, sc)\n",
> - Â Â Â Â Â Â Â Â Â Â Âinsn_file (tail), insn_line (tail), ps->ii, stage_count);
> + Â Â Â Â Â Â dump_insn_locator (tail);
> + Â Â Â Â Â Â fprintf (dump_file, " SMS succeeded %d %d (with ii, sc)\n",
> + Â Â Â Â Â Â Â Â Â Â Âps->ii, stage_count);
> Â Â Â Â Â Â Âprint_partial_schedule (ps, dump_file);
> Â Â Â Â Â Â}
>
>
> Â Â Â ÂJakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]