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]

[bfin] Don't load the address of counter variable before calling _mcount ()


To load the address of counter variable may clobber the value of P1, which is set up in function prologue, since the instrument code is inserted after prologue. To fix it, we could save P1 on stack before loading the address of counter variable into P1 and pop it from stack after _mcount return. But there is only one project using -pg on Blackfin and it does not require the address of counter variable, so the simpler way is not to load the address into P1 at all.

Is it OK?

Thanks,
Jie
	* config/bfin/bfin.h (FUNCTION_PROFILER): Don't use LABELNO.
	(NO_PROFILE_COUNTERS): Define as 1.

Index: config/bfin/bfin.h
===================================================================
--- config/bfin/bfin.h	(revision 118545)
+++ config/bfin/bfin.h	(working copy)
@@ -1210,12 +1210,14 @@
 
 #define ASM_COMMENT_START "//"
 
-#define FUNCTION_PROFILER(FILE, LABELNO) \
-  do {\
-    fprintf (FILE, "\tP1.l =LP$%d; P1.h =LP$%d; call mcount;\n", \
-       LABELNO, LABELNO);\
+#define FUNCTION_PROFILER(FILE, LABELNO)	\
+  do {						\
+    fprintf (FILE, "\tCALL __mcount;\n");	\
   } while(0)
 
+#undef NO_PROFILE_COUNTERS
+#define NO_PROFILE_COUNTERS 1
+
 #define ASM_OUTPUT_REG_PUSH(FILE, REGNO) fprintf (FILE, "[SP--] = %s;\n", reg_names[REGNO])
 #define ASM_OUTPUT_REG_POP(FILE, REGNO)  fprintf (FILE, "%s = [SP++];\n", reg_names[REGNO])
 

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