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]

Re: patch for support profiling for AIX 4.3


Hi Richard,

Here is the revised patch with all the modifications mentioned in this 
email. Please let me know is it okay to checkin.

Thanks
Chandra

Index: final.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/final.c,v
retrieving revision 1.151
diff -p -r1.151 final.c
*** final.c	2000/12/07 00:13:23	1.151
--- final.c	2000/12/19 23:38:57
*************** char regs_ever_live[FIRST_PSEUDO_REGISTE
*** 206,215 ****
  
  int frame_pointer_needed;
  
- /* Assign unique numbers to labels generated for profiling.  */
- 
- int profile_label_no;
- 
  /* Number of unmatched NOTE_INSN_BLOCK_BEG notes we have seen.  */
  
  static int block_depth;
--- 206,211 ----
Index: output.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/output.h,v
retrieving revision 1.52
diff -p -r1.52 output.h
*** output.h	2000/10/06 06:01:27	1.52
--- output.h	2000/12/19 23:38:57
*************** extern const char *user_label_prefix;
*** 471,473 ****
--- 471,477 ----
  #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
    (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'))
  #endif
+ 
+ /* Assign unique numbers to labels generated for profiling.  */
+ 
+ int profile_label_no;
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.235
diff -p -r1.235 function.c
*** function.c	2000/12/15 09:09:41	1.235
--- function.c	2000/12/19 23:38:57
*************** expand_function_start (subr, parms_have_
*** 6393,6398 ****
--- 6393,6403 ----
  			 Pmode);
      }
  
+ #ifdef PROFILE_HOOK
+   if (profile_flag)
+     PROFILE_HOOK (profile_label_no);
+ #endif
+ 
    /* After the display initializations is where the tail-recursion label
       should go, if we end up needing one.   Ensure we have a NOTE here
       since some things (like trampolines) get placed before this.  */
Index: config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.157
diff -p -r1.157 rs6000.c
*** rs6000.c	2000/12/12 11:53:48	1.157
--- rs6000.c	2000/12/19 23:38:58
*************** output_function_profiler (file, labelno)
*** 7094,7154 ****
        break;
  
      case ABI_AIX:
-       /* Set up a TOC entry for the profiler label.  */
-       toc_section ();
-       ASM_OUTPUT_INTERNAL_LABEL (file, "LPC", labelno);
-       if (TARGET_MINIMAL_TOC)
- 	{
- 	  fputs (TARGET_32BIT ? "\t.long " : "\t.llong ", file);
- 	  assemble_name (file, buf);
- 	  putc ('\n', file);
- 	}
-       else
- 	{
- 	  fputs ("\t.tc\t", file);
- 	  assemble_name (file, buf);
- 	  fputs ("[TC],", file);
- 	  assemble_name (file, buf);
- 	  putc ('\n', file);
- 	}
-       text_section ();
- 
-   /* Figure out last used parameter register.  The proper thing to do is
-      to walk incoming args of the function.  A function might have live
-      parameter registers even if it has no incoming args.  */
- 
-       for (last_parm_reg = 10;
- 	   last_parm_reg > 2 && ! regs_ever_live [last_parm_reg];
- 	   last_parm_reg--)
- 	;
- 
-   /* Save parameter registers in regs 23-30 and static chain in r22.
-      Don't overwrite reg 31, since it might be set up as the frame pointer.  */
- 
-       for (i = 3, j = 30; i <= last_parm_reg; i++, j--)
- 	asm_fprintf (file, "\tmr %d,%d\n", j, i);
-       if (current_function_needs_context)
- 	asm_fprintf (file, "\tmr %d,%d\n", j, STATIC_CHAIN_REGNUM);
- 
-   /* Load location address into r3, and call mcount.  */
- 
-       ASM_GENERATE_INTERNAL_LABEL (buf, "LPC", labelno);
-       asm_fprintf (file, TARGET_32BIT ? "\t{l|lwz} %s," : "\tld %s,",
- 		   reg_names[3]);
-       assemble_name (file, buf);
-       asm_fprintf (file, "(%s)\n\tbl %s\n\t", reg_names[2], RS6000_MCOUNT);
-       asm_fprintf (file, RS6000_CALL_GLUE);
-       putc('\n', file);
- 
-   /* Restore parameter registers and static chain.  */
- 
-       for (i = 3, j = 30; i <= last_parm_reg; i++, j--)
- 	asm_fprintf (file, "\tmr %d,%d\n", i, j);
-       if (current_function_needs_context)
- 	asm_fprintf (file, "\tmr %d,%d\n", STATIC_CHAIN_REGNUM, j);
- 
        break;
      }
  }
  
  /* Adjust the cost of a scheduling dependency.  Return the new cost of
--- 7094,7130 ----
        break;
  
      case ABI_AIX:
        break;
      }
+ }
+ 
+ 
+ /* Emit profile function. */
+ void
+ output_profile_hook (labelno)
+      int labelno;
+ {
+ 
+    if (profile_flag)
+      {
+        char *buf;
+        int length = 0;
+        rtx fun;
+ 
+        labelno += 1;
+        if (ggc_p)
+          buf = ggc_alloc_string (NULL, labelno+5);
+        else
+          buf = permalloc (labelno+6);
+ 
+        ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno);
+ 
+        fun = gen_rtx_SYMBOL_REF (Pmode, buf+1);
+ 
+        emit_library_call (init_one_libfunc (RS6000_MCOUNT), 0, VOIDmode, 1,
+                           fun, Pmode, Pmode);
+ 
+       }
  }
  
  /* Adjust the cost of a scheduling dependency.  Return the new cost of
Index: config/rs6000/rs6000-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000-protos.h,v
retrieving revision 1.11
diff -p -r1.11 rs6000-protos.h
*** rs6000-protos.h	2000/09/06 09:12:51	1.11
--- rs6000-protos.h	2000/12/19 23:38:58
*************** extern void output_ascii PARAMS ((FILE *
*** 159,164 ****
--- 159,165 ----
  extern void rs6000_gen_section_name PARAMS ((char **, const char *,
  					     const char *));
  extern void output_function_profiler PARAMS ((FILE *, int));
+ extern void output_profile_hook  PARAMS ((int));
  extern int rs6000_trampoline_size PARAMS ((void));
  extern void toc_section PARAMS ((void));
  extern void sdata_section PARAMS ((void));
Index: config/rs6000/aix.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/aix.h,v
retrieving revision 1.11
diff -p -r1.11 aix.h
*** aix.h	2000/11/02 23:29:12	1.11
--- aix.h	2000/12/19 23:38:58
*************** toc_section ()						\
*** 632,634 ****
--- 632,635 ----
     So we have to squirrel it away with this.  */
  #define SETUP_FRAME_ADDRESSES() rs6000_aix_emit_builtin_unwind_init ()
  
+ #define PROFILE_HOOK(LABEL)   output_profile_hook (LABEL)
Index: tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tm.texi,v
retrieving revision 1.157
diff -p -r1.157 tm.texi
*** tm.texi	2000/12/19 17:41:20	1.157
--- tm.texi	2000/12/19 23:44:03
*************** variable to be loaded into some register
*** 3595,3600 ****
--- 3595,3606 ----
  @samp{LP} followed by the number @var{labelno}, so you would generate
  the name using @samp{LP%d} in a @code{fprintf}.
  
+ @findex PROFILE_HOOK
+ @item PROFILE_HOOK
+ A C statement or compound statement to output to @var{file} some assembly
+ code to call the profiling subroutine @code{mcount} even the target does
+ not support profiling.
+ 
  @findex NO_PROFILE_COUNTERS
  @item NO_PROFILE_COUNTERS
  Define this macro if the @code{mcount} subroutine on your system does


On Thu, 14 Dec 2000, Richard Henderson wrote:

> On Thu, Dec 14, 2000 at 04:49:03PM -0800, Chandra Chavva wrote:
> > Here are some comments from Geoff Keating on this 
> > > Basically, this is an example of trying to do something complicated in
> > > a machine's backend, when it could be done much more easily with a
> > > little hook in the middle of the compiler.
> 
> I do agree that the machinations needed for adding the profiling code
> earlier and much less than adding the code later.  That leaves 
> several objections to the patch as presented:
> 
> (1) You needn't add anything to the generic part of the compiler
>     except the hook in expand_function_start.  Creating the symbol
>     for the call to emit_library_call can be done by the rs6000
>     backend.
> 
> (2) The declaration of profile_label_no is missing "extern".
>     The definition should not be removed from final.c, and the
>     declaration actually belongs in output.h not function.h.
> 
> (3) The rs6000 function output_function_profiler should do 
>     nothing in the ABI_AIX case.  I.e. delete all the old code
>     that we're functionally replacing.
> 
> 
> 
> r~
> 

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