This is the mail archive of the gcc@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]

improve -fverbose-asm option


Hello,

I'd like to get more helpful information from the final .S file, such
as basic block info, so that I can draw a cfg graph through a script.
Perhaps the -fverbose-asm option is the right way to open this
functionality. Here's a simple patch based on the current trunk svn.

Index: gcc/final.c
===================================================================
--- gcc/final.c (revision 144878)
+++ gcc/final.c (working copy)
@@ -1830,10 +1830,38 @@ final_scan_insn (rtx insn, FILE *file, i
          targetm.asm_out.unwind_emit (asm_out_file, insn);
 #endif

-         if (flag_debug_asm)
+         if (flag_debug_asm && !flag_verbose_asm)
            fprintf (asm_out_file, "\t%s basic block %d\n",
                     ASM_COMMENT_START, NOTE_BASIC_BLOCK (insn)->index);

+          /* Print basic block info. */
+          if (flag_verbose_asm)
+            {
+              fprintf (asm_out_file, "\t%s BLOCK %d",
+                       ASM_COMMENT_START, NOTE_BASIC_BLOCK (insn)->index);
+              if (NOTE_BASIC_BLOCK (insn)->frequency)
+                fprintf (asm_out_file, " freq: %d",
+                         NOTE_BASIC_BLOCK (insn)->frequency);
+              if (NOTE_BASIC_BLOCK (insn)->count)
+                fprintf (asm_out_file, " count: %d",
+                         NOTE_BASIC_BLOCK (insn)->count);
+              fprintf (asm_out_file, "\n");
+
+              fprintf (asm_out_file, "\t%s PRED:", ASM_COMMENT_START);
+              FOR_EACH_EDGE (e, ei, NOTE_BASIC_BLOCK (insn)->preds)
+                {
+                  dump_edge_info (asm_out_file, e, 0);
+                }
+              fprintf (asm_out_file, "\n");
+
+              fprintf (asm_out_file, "\t%s SUCC:", ASM_COMMENT_START);
+              FOR_EACH_EDGE (e, ei, NOTE_BASIC_BLOCK (insn)->succs)
+                {
+                  dump_edge_info (asm_out_file, e, 1);
+                }
+              fprintf (asm_out_file, "\n");
+            }
+
          if ((*seen & (SEEN_EMITTED | SEEN_BB)) == SEEN_BB)
            {
              *seen |= SEEN_EMITTED;

Also, I think it will be better to generate one label for each basic
block, and the local label should have the function name as the
suffix. Because some profile tools, such as oprofile, will output
samples based on the labels. So this will help us to analyze the
samples for each basic block. But current generated code will have
many local labels with the same name. Perhaps it's again the
-fverbose-asm to enable this functionality. But where should I go if I
wanna implement this functionality?

Cheers,

Eric Fisher
Mar 16, 2009


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