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]

patch for support profiling for AIX 4.3




IBM AIX 4.3 does not support profiling. When AIX 4.3 tools are 
compiled with -p option, the compiler does not generate the correct code. 

Here is the patch which supports profiling for AIX 4.3. Please let me 
know the patch is okay to apply.

Thanks
Chandra

	* expr.h (libfunc_index): LTI_profile_mcount new.
        (libfunc_table): Define profile_mcount_libfunc.
        * optabs.c (init_optabs): Initialize profile_mcount_libfunc.
        * function.c (expand_function_start): Call PROFILE_HOOK to do
         profiling.
        * final.c: Move the definition of profile_label_no to ...
        (profile_function): Do not call FUNCTION_PROFILE if
        * function.h: ... here.
        PROFILE_HOOK is defined.
        * config/rs6000/rs6000.c: output_profile_hook new function.
        * config/rs6000/aix.h: PROFILE_HOOK, MCOUNT_FUNCTION new macros.
        * config/rs6000/rs6000.h:  Move FUNCTION_PROFILER to ...
        * config/rs6000/sysv4.h: ... here. The generic code.

Index: expr.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/expr.h,v
retrieving revision 1.73
diff -p -r1.73 expr.h
*** expr.h	2000/12/03 23:58:44	1.73
--- expr.h	2000/12/11 23:01:16
*************** enum libfunc_index
*** 605,610 ****
--- 605,614 ----
    LTI_profile_function_entry,
    LTI_profile_function_exit,
  
+ #ifdef PROFILE_HOOK
+   LTI_profile_mcount,
+ #endif
+ 
    LTI_MAX
  };
  
*************** extern rtx libfunc_table[LTI_MAX];
*** 737,742 ****
--- 741,749 ----
  
  #define profile_function_entry_libfunc	(libfunc_table[LTI_profile_function_entry])
  #define profile_function_exit_libfunc	(libfunc_table[LTI_profile_function_exit])
+ #ifdef PROFILE_HOOK
+ #define profile_mcount_libfunc (libfunc_table[LTI_profile_mcount])
+ #endif
  
  typedef rtx (*rtxfun) PARAMS ((rtx));
  
Index: optabs.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/optabs.c,v
retrieving revision 1.86
diff -p -r1.86 optabs.c
*** optabs.c	2000/11/17 06:05:15	1.86
--- optabs.c	2000/12/11 23:01:16
*************** init_optabs ()
*** 4879,4884 ****
--- 4879,4888 ----
    profile_function_exit_libfunc
      = init_one_libfunc ("__cyg_profile_func_exit");
  
+ #ifdef PROFILE_HOOK
+   profile_mcount_libfunc = init_one_libfunc (MCOUNT_FUNCTION);
+ #endif
+ 
  #ifdef HAVE_conditional_trap
    init_traps ();
  #endif
Index: function.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/function.c,v
retrieving revision 1.233
diff -p -r1.233 function.c
*** function.c	2000/11/30 06:31:17	1.233
--- function.c	2000/12/11 23:01:16
*************** expand_function_start (subr, parms_have_
*** 6357,6362 ****
--- 6357,6367 ----
  			 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: final.c
===================================================================
RCS file: /cvs/gcc/egcs/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/11 23:01:16
*************** 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 ----
*************** profile_function (file)
*** 1754,1760 ****
--- 1750,1758 ----
  #endif
  #endif
  
+ #ifndef PROFILE_HOOK
    FUNCTION_PROFILER (file, profile_label_no);
+ #endif
  
  #if defined(STATIC_CHAIN_INCOMING_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
    if (cxt)
Index: function.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/function.h,v
retrieving revision 1.58
diff -p -r1.58 function.h
*** function.h	2000/11/30 06:31:17	1.58
--- function.h	2000/12/11 23:01:16
*************** extern struct function *cfun;
*** 472,477 ****
--- 472,481 ----
  /* A list of all functions we have compiled so far.  */
  extern struct function *all_functions;
  
+ /* Assign unique numbers to labels generated for profiling.  */
+ 
+ int profile_label_no;
+ 
  /* For backward compatibility... eventually these should all go away.  */
  #define current_function_name (cfun->name)
  #define current_function_pops_args (cfun->pops_args)
Index: config/rs6000/rs6000.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.96
diff -p -r1.96 rs6000.h
*** rs6000.h	2000/10/17 22:17:34	1.96
--- rs6000.h	2000/12/11 23:01:16
*************** typedef struct rs6000_args
*** 1548,1559 ****
  
  #define FUNCTION_PROLOGUE(FILE, SIZE) output_prolog (FILE, SIZE)
  
- /* Output assembler code to FILE to increment profiler label # LABELNO
-    for profiling a function entry.  */
- 
- #define FUNCTION_PROFILER(FILE, LABELNO)	\
-   output_function_profiler ((FILE), (LABELNO));
- 
  /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
     the stack pointer does not matter. No definition is equivalent to
     always zero.
--- 1548,1553 ----
Index: config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.156
diff -p -r1.156 rs6000.c
*** rs6000.c	2000/11/19 18:49:31	1.156
--- rs6000.c	2000/12/11 23:01:16
*************** rs6000_gen_section_name (buf, filename, 
*** 7026,7031 ****
--- 7026,7057 ----
      *p = '\0';
  }
  
+ 
+ /* Emit profile function. */
+ void
+ output_profile_hook (labelno)
+      int labelno;
+ {
+ 
+    if (profile_flag)
+      {
+        char *buf;
+        int length = 0;
+        rtx fun;
+ 
+        labelno += 1;
+        buf = ggc_alloc_string (NULL, labelno+5);
+ 
+        ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno);
+ 
+        fun = gen_rtx_SYMBOL_REF (Pmode, buf+1);
+ 
+        emit_library_call (profile_mcount_libfunc, 0, VOIDmode, 1,
+                           fun, Pmode, Pmode);
+ 
+       }
+ }
+ 
  /* Write function profiler code. */
  
  void
Index: config/rs6000/aix.h
===================================================================
RCS file: /cvs/gcc/egcs/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/11 23:01:16
*************** toc_section ()						\
*** 632,634 ****
--- 632,638 ----
     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)
+ 
+ #define MCOUNT_FUNCTION               RS6000_MCOUNT
+ 
Index: config/rs6000/sysv4.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/rs6000/sysv4.h,v
retrieving revision 1.38
diff -p -r1.38 sysv4.h
*** sysv4.h	2000/11/02 23:29:12	1.38
--- sysv4.h	2000/12/11 23:01:16
*************** do {									\
*** 1550,1555 ****
--- 1550,1561 ----
  /* Function name to call to do profiling.  */
  #define RS6000_MCOUNT "_mcount"
  
+ /* Output assembler code to FILE to increment profiler label # LABELNO
+    for profiling a function entry.  */
+ 
+ #define FUNCTION_PROFILER(FILE, LABELNO)        \
+   output_function_profiler ((FILE), (LABELNO));
+ 
  /* Define library calls for quad FP operations.  These are all part of the
     PowerPC 32bit ABI.  */
  #define ADDTF3_LIBCALL "_q_add"





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