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] Add hints for slim dumping if fallthrough bb of jump isn't next bb


Hi Richard,

on 2019/7/11 下午4:51, Richard Sandiford wrote:
> Kewen.Lin <linkw@linux.ibm.com> writes:
>>
>> -      if (flags & TDF_BLOCKS)
> 
> I think we still need an if here, but with the condition instead being:
> 
>    cfun->curr_properties & PROP_cfg
> 
>> +             else if (EDGE_COUNT (bb->succs) > 0)
>> +               {
>> +                 gcc_assert (BB_END (bb) == tmp_rtx);
>> +                 const rtx_insn *ninsn = NEXT_INSN (tmp_rtx);
> 
> I think it'd be better to loop until we hit a real insn or a nonnull
> start[], e.g. to cope with intervening deleted-insn notes and debug insns.
> Something like:
> 
> 		    while (ninsn && !INSN_P (nisn) && !start[INSN_UID (ninsn)])
> 		      ninsn = NEXT_INSN (insn);
> 

Thanks a lot for the comments, I've merged your suggested codes as below.

Regression testing is ongoing on powerpc64le-unknown-linux-gnu.

If regtest and bootstrap is ok, is it ok for trunk?


Thanks,
Kewen

---------

gcc/ChangeLog

2019-07-11  Kewen Lin  <linkw@gcc.gnu.org>

	* gcc/cfgrtl.c (print_rtl_with_bb): Emit a hint if the fallthrough
	target of current basic block isn't the placed right next.


diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index a1ca5992c41..19b118a8ece 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -2193,7 +2193,7 @@ print_rtl_with_bb (FILE *outf, const rtx_insn *rtx_first, dump_flags_t flags)
       if (df)
        df_dump_start (outf);

-      if (flags & TDF_BLOCKS)
+      if (cfun->curr_properties & PROP_cfg)
        {
          FOR_EACH_BB_REVERSE_FN (bb, cfun)
            {
@@ -2201,16 +2201,19 @@ print_rtl_with_bb (FILE *outf, const rtx_insn *rtx_first, dump_flags_t flags)

              start[INSN_UID (BB_HEAD (bb))] = bb;
              end[INSN_UID (BB_END (bb))] = bb;
-             for (x = BB_HEAD (bb); x != NULL_RTX; x = NEXT_INSN (x))
+             if (flags & TDF_BLOCKS)
                {
-                 enum bb_state state = IN_MULTIPLE_BB;
+                 for (x = BB_HEAD (bb); x != NULL_RTX; x = NEXT_INSN (x))
+                   {
+                     enum bb_state state = IN_MULTIPLE_BB;

-                 if (in_bb_p[INSN_UID (x)] == NOT_IN_BB)
-                   state = IN_ONE_BB;
-                 in_bb_p[INSN_UID (x)] = state;
+                     if (in_bb_p[INSN_UID (x)] == NOT_IN_BB)
+                       state = IN_ONE_BB;
+                     in_bb_p[INSN_UID (x)] = state;

-                 if (x == BB_END (bb))
-                   break;
+                     if (x == BB_END (bb))
+                       break;
+                   }
                }
            }
        }
@@ -2244,16 +2247,35 @@ print_rtl_with_bb (FILE *outf, const rtx_insn *rtx_first, dump_flags_t flags)
          if (flags & TDF_DETAILS)
            df_dump_insn_bottom (tmp_rtx, outf);

-         if (flags & TDF_BLOCKS)
+         bb = end[INSN_UID (tmp_rtx)];
+         if (bb != NULL)
            {
-             bb = end[INSN_UID (tmp_rtx)];
-             if (bb != NULL)
+             if (flags & TDF_BLOCKS)
                {
                  dump_bb_info (outf, bb, 0, dump_flags, false, true);
                  if (df && (flags & TDF_DETAILS))
                    df_dump_bottom (bb, outf);
                  putc ('\n', outf);
                }
+             /* Emit a hint if the fallthrough target of current basic block
+                isn't the one placed right next.  */
+             else if (EDGE_COUNT (bb->succs) > 0)
+               {
+                 gcc_assert (BB_END (bb) == tmp_rtx);
+                 const rtx_insn *ninsn = NEXT_INSN (tmp_rtx);
+                 /* Bypass intervening deleted-insn notes and debug insns.  */
+                 while (ninsn && !NONDEBUG_INSN_P (ninsn)
+                        && !start[INSN_UID (ninsn)])
+                   ninsn = NEXT_INSN (ninsn);
+                 edge e = find_fallthru_edge (bb->succs);
+                 if (e && ninsn)
+                   {
+                     basic_block dest = e->dest;
+                     if (start[INSN_UID (ninsn)] != dest)
+                       fprintf (outf, "%s      ; pc falls through to BB %d\n",
+                                print_rtx_head, dest->index);
+                   }
+               }
            }
        }


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