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]

x86-64 profiling fix


Hi,
I've noticed that Jakub's fix does not replace our profiling patch
completely.  It is also needed to update the mcount invokation code.
OK for mainlnie/3.2 branch?

Honza

Thu Oct 17 19:19:49 CEST 2002  Jan Hubicka  <jh@suse.cz>
	* i386-protos.h (x86_function_profiler): New function
	* i386.h (OUTPUT_FUNCTION_PROFILER): Move offline to ...
	* i386.c (x86_function_profiler) ... here; fix 64bit support
Index: i386-protos.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386-protos.h,v
retrieving revision 1.80
diff -c -3 -p -r1.80 i386-protos.h
*** i386-protos.h	15 Sep 2002 21:47:42 -0000	1.80
--- i386-protos.h	17 Oct 2002 17:19:38 -0000
*************** extern void ix86_set_move_mem_attrs PARA
*** 184,189 ****
--- 184,190 ----
  extern void emit_i387_cw_initialization PARAMS ((rtx, rtx));
  extern bool ix86_fp_jump_nontrivial_p PARAMS ((enum rtx_code));
  extern void x86_order_regs_for_local_alloc PARAMS ((void));
+ extern void x86_function_profiler PARAMS ((FILE *, int));
  
  
  #ifdef TREE_CODE
Index: i386.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.472
diff -c -3 -p -r1.472 i386.c
*** i386.c	17 Oct 2002 17:09:16 -0000	1.472
--- i386.c	17 Oct 2002 17:19:41 -0000
*************** x86_field_alignment (field, computed)
*** 13949,13954 ****
--- 13949,13986 ----
    return computed;
  }
  
+ /* Output assembler code to FILE to increment profiler label # LABELNO
+    for profiling a function entry.  */
+ void
+ x86_function_profiler (file, labelno)
+      FILE *file;
+      int labelno;
+ {
+   if (TARGET_64BIT)
+     if (flag_pic)
+       {
+ 	fprintf (file, "\tleaq\t%sP%d@(%%rip),%%r11\n",
+ 		 LPREFIX, labelno);
+ 	fprintf (file, "\tcall\t*_mcount@GOTPCREL(%%rip)\n");
+       }
+     else
+       {
+ 	fprintf (file, "\tmovq\t$%sP%d,%%r11\n", LPREFIX, labelno);
+ 	fprintf (file, "\tcall\t_mcount\n");
+       }
+   else if (flag_pic)
+     {
+       fprintf (file, "\tleal\t%sP%d@GOTOFF(%%ebx),%%edx\n",
+ 	       LPREFIX, labelno);
+       fprintf (file, "\tcall\t*_mcount@GOT(%%ebx)\n");
+     }
+   else
+     {
+       fprintf (file, "\tmovl\t$%sP%d,%%edx\n", LPREFIX, labelno);
+       fprintf (file, "\tcall\t_mcount\n");
+     }
+ }
+ 
  /* Implement machine specific optimizations.  
     At the moment we implement single transformation: AMD Athlon works faster
     when RET is not destination of conditional jump or directly preceeded
Index: i386.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.h,v
retrieving revision 1.295
diff -c -3 -p -r1.295 i386.h
*** i386.h	16 Oct 2002 13:14:23 -0000	1.295
--- i386.h	17 Oct 2002 17:19:43 -0000
*************** typedef struct ix86_args {
*** 1730,1749 ****
  /* Output assembler code to FILE to increment profiler label # LABELNO
     for profiling a function entry.  */
  
! #define FUNCTION_PROFILER(FILE, LABELNO)				\
! do {									\
!   if (flag_pic)								\
!     {									\
!       fprintf ((FILE), "\tleal\t%sP%d@GOTOFF(%%ebx),%%edx\n",		\
! 	       LPREFIX, (LABELNO));					\
!       fprintf ((FILE), "\tcall\t*_mcount@GOT(%%ebx)\n");		\
!     }									\
!   else									\
!     {									\
!       fprintf ((FILE), "\tmovl\t$%sP%d,%%edx\n", LPREFIX, (LABELNO));	\
!       fprintf ((FILE), "\tcall\t_mcount\n");				\
!     }									\
! } while (0)
  
  /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
     the stack pointer does not matter.  The value is tested only in
--- 1730,1736 ----
  /* Output assembler code to FILE to increment profiler label # LABELNO
     for profiling a function entry.  */
  
! #define FUNCTION_PROFILER(FILE, LABELNO) x86_function_profiler (FILE, LABELNO)
  
  /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
     the stack pointer does not matter.  The value is tested only in


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