alpha.c (alpha_does_function_need_gp): Test TARGET_PROFILING_NEEDS_GP in the if,...
authorRichard Henderson <rth@cygnus.com>
Sun, 28 May 2000 02:25:46 +0000 (19:25 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Sun, 28 May 2000 02:25:46 +0000 (19:25 -0700)
        * config/alpha/alpha.c (alpha_does_function_need_gp): Test
        TARGET_PROFILING_NEEDS_GP in the if, instead of with an ifdef.
        (alpha_expand_prologue): Emit prologue_mcount if needed.
        * config/alpha/alpha.h (TARGET_PROFILING_NEEDS_GP): Default to 0.
        * config/alpha/alpha.md (prologue_mcount): New.
        * config/alpha/linux.h (FUNCTION_PROFILER): Remove.
        (TARGET_PROFILING_NEEDS_GP): Undef before redefining.
        * config/alpha/netbsd.h: Likewise.

From-SVN: r34222

gcc/ChangeLog
gcc/config/alpha/alpha.c
gcc/config/alpha/alpha.h
gcc/config/alpha/alpha.md
gcc/config/alpha/linux.h
gcc/config/alpha/netbsd.h

index 461423fcdf475d5fbe017392b4376b5768b06999..cff7b963bb720149e5f8ebca40aba06e1a2d5088 100644 (file)
@@ -1,3 +1,14 @@
+2000-05-27  Richard Henderson  <rth@cygnus.com>
+
+       * config/alpha/alpha.c (alpha_does_function_need_gp): Test
+       TARGET_PROFILING_NEEDS_GP in the if, instead of with an ifdef.
+       (alpha_expand_prologue): Emit prologue_mcount if needed.
+       * config/alpha/alpha.h (TARGET_PROFILING_NEEDS_GP): Default to 0.
+       * config/alpha/alpha.md (prologue_mcount): New.
+       * config/alpha/linux.h (FUNCTION_PROFILER): Remove.
+       (TARGET_PROFILING_NEEDS_GP): Undef before redefining.
+       * config/alpha/netbsd.h: Likewise.
+
 2000-05-27  Richard Henderson  <rth@cygnus.com>
 
        * config/alpha/elf.h (SELECT_SECTION): Mirror Kenner's May 19
index ed708788d7c37303ef60107b4d2e7147808eff8a..f70e889bac81adb8180265d22471fa9ea84c9955 100644 (file)
@@ -4056,10 +4056,8 @@ alpha_does_function_need_gp ()
   if (TARGET_WINDOWS_NT || TARGET_OPEN_VMS)
     return 0;
 
-#ifdef TARGET_PROFILING_NEEDS_GP
-  if (profile_flag)
+  if (TARGET_PROFILING_NEEDS_GP && profile_flag)
     return 1;
-#endif
 
 #ifdef ASM_OUTPUT_MI_THUNK
   if (current_function_is_thunk)
@@ -4190,6 +4188,13 @@ alpha_expand_prologue ()
        emit_insn (gen_prologue_ldgp ());
     }
 
+  /* TARGET_PROFILING_NEEDS_GP actually implies that we need to insert
+     the call to mcount ourselves, rather than having the linker do it
+     magically in response to -pg.  Since _mcount has special linkage,
+     don't represent the call as a call.  */
+  if (TARGET_PROFILING_NEEDS_GP && profile_flag)
+    emit_insn (gen_prologue_mcount ());
+      
   /* Adjust the stack by the frame size.  If the frame size is > 4096
      bytes, we need to be sure we probe somewhere in the first and last
      4096 bytes (we can probably get away without the latter test) and
index a362bb86c745b0548a7e2ef4af2c9e72025065b7..ad59214ff18820650eddb63506b433c76320716e 100644 (file)
@@ -185,6 +185,9 @@ extern enum alpha_fp_trap_mode alpha_fptm;
 #ifndef TARGET_HAS_XFLOATING_LIBS
 #define TARGET_HAS_XFLOATING_LIBS 0
 #endif
+#ifndef TARGET_PROFILING_NEEDS_GP
+#define TARGET_PROFILING_NEEDS_GP 0
+#endif
 
 /* Macro to define tables used to set the flags.
    This is a list in braces of pairs in braces,
index dfef1506b0834af6cd1c10ca08b6c3fd7e2cf99d..0866be524a12413d5fb7e00a2c3da239a5c87eda 100644 (file)
@@ -41,6 +41,9 @@
 ;;     5       prologue_stack_probe_loop
 ;;     6       realign
 ;;     7       exception_receiver
+;;     8       prologue_mcount
+;;     9       prologue_ldgp_1
+;;     10      prologue_ldgp_2
 \f
 ;; Processor type -- this attribute must exactly match the processor_type
 ;; enumeration in alpha.h.
   "! TARGET_OPEN_VMS && ! TARGET_WINDOWS_NT"
   "")
 
+;; The _mcount profiling hook has special calling conventions, and
+;; does not clobber all the registers that a normal call would.  So
+;; hide the fact this is a call at all.
+
+(define_insn "prologue_mcount"
+  [(unspec_volatile [(const_int 0)] 8)]
+  ""
+  "lda $28,_mcount\;jsr $28,($28),_mcount"
+  [(set_attr "type" "multi")
+   (set_attr "length" "8")])
+
 (define_insn "init_fp"
   [(set (match_operand:DI 0 "register_operand" "=r")
         (match_operand:DI 1 "register_operand" "r"))
index 8858eb6be5152934e1ffdb5bbec51608c380d057..9969cc6279f0d398b72dc1fe28e5d4f53337dc4a 100644 (file)
@@ -31,11 +31,8 @@ SUB_CPP_PREDEFINES
 #undef LIB_SPEC
 #define LIB_SPEC "%{pg:-lgmon} %{pg:-lc_p} %{!pg:-lc}"
 
-#undef FUNCTION_PROFILER
-#define FUNCTION_PROFILER(FILE, LABELNO)                       \
-       fputs ("\tlda $28,_mcount\n\tjsr $28,($28),_mcount\n", (FILE))
-
 /* Show that we need a GP when profiling.  */
+#undef TARGET_PROFILING_NEEDS_GP
 #define TARGET_PROFILING_NEEDS_GP 1
 
 /* Don't care about faults in the prologue.  */
index 15dcadb00efea710811cbb28edb179e6a7234175..0a10f5ae0dc0918674a4e63dd0048418280287c3 100644 (file)
@@ -28,9 +28,6 @@ Boston, MA 02111-1307, USA.  */
 #undef LIB_SPEC
 #define LIB_SPEC "%{pg:-lgmon} %{pg:-lc_p} %{!pg:-lc}"
 
-#undef FUNCTION_PROFILER
-#define FUNCTION_PROFILER(FILE, LABELNO)                       \
-       fputs ("\tlda $28,_mcount\n\tjsr $28,($28),_mcount\n", (FILE))
-
 /* Show that we need a GP when profiling.  */
-#define TARGET_PROFILING_NEEDS_GP
+#undef TARGET_PROFILING_NEEDS_GP
+#define TARGET_PROFILING_NEEDS_GP 1