This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch for PR target/19889 (IA64 HP-UX profiling)
- From: Steve Ellcey <sje at cup dot hp dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 17 Jun 2005 11:20:03 -0700 (PDT)
- Subject: Patch for PR target/19889 (IA64 HP-UX profiling)
- Reply-to: sje at cup dot hp dot com
This patch fixes profiling on IA64 HP-UX which has never worked. To
implement it I switched the HP-UX target from using FUNCTION_PROFILER to
PROFILE_HOOK. This fixes the failure of g++.old-deja/g++.law/profile1.C
in the testsuite. Tested on IA64 HP-UX and Linux with no regressions.
OK for checkin?
Steve Ellcey
sje@cup.hp.com
2005-06-17 Steve Ellcey <sje@cup.hp.com>
PR target/19889
* config/ia64/hpux.h (FUNCTION_PROFILER): New (dummy).
(PROFILE_HOOK): New.
(PROFILE_BEFORE_PROLOGUE): Undef.
(NO_PROFILE_COUNTERS): New.
* config/ia64/ia64-protos.h (ia64_profile_hook): New.
* config/ia64/ia64.c (ia64_compute_frame_size): Add ifdef.
(gen_mcount_func_rtx): New.
(ia64_profile_hook): New.
* config/ia64/ia64.md (ip_value): New.
*** gcc.orig/gcc/config/ia64/hpux.h Fri Jun 17 11:08:16 2005
--- gcc/gcc/config/ia64/hpux.h Fri Jun 17 11:07:03 2005
*************** do { \
*** 208,210 ****
--- 208,225 ----
/* HP-UX headers are C++-compatible. */
#define NO_IMPLICIT_EXTERN_C
+
+ /* HP-UX uses PROFILE_HOOK instead of FUNCTION_PROFILER but we need a
+ FUNCTION_PROFILER defined because its use is not ifdefed. When using
+ PROFILE_HOOK, the profile call comes after the prologue. */
+
+ #undef FUNCTION_PROFILER
+ #define FUNCTION_PROFILER(FILE, LABELNO) do { } while (0)
+
+ #undef PROFILE_HOOK
+ #define PROFILE_HOOK(LABEL) ia64_profile_hook (LABEL)
+
+ #undef PROFILE_BEFORE_PROLOGUE
+
+ #undef NO_PROFILE_COUNTERS
+ #define NO_PROFILE_COUNTERS 0
*** gcc.orig/gcc/config/ia64/ia64-protos.h Fri Jun 17 11:07:45 2005
--- gcc/gcc/config/ia64/ia64-protos.h Fri Jun 17 11:07:30 2005
*************** extern enum direction ia64_hpux_function
*** 114,116 ****
--- 114,117 ----
extern void ia64_hpux_handle_builtin_pragma (struct cpp_reader *);
extern void ia64_output_function_profiler (FILE *, int);
+ extern void ia64_profile_hook (int);
*** gcc.orig/gcc/config/ia64/ia64.c Fri Jun 17 11:07:59 2005
--- gcc/gcc/config/ia64/ia64.c Fri Jun 17 11:07:20 2005
*************** ia64_compute_frame_size (HOST_WIDE_INT s
*** 2087,2098 ****
--- 2087,2100 ----
break;
i = regno - OUT_REG (0) + 1;
+ #ifndef PROFILE_HOOK
/* When -p profiling, we need one output register for the mcount argument.
Likewise for -a profiling for the bb_init_func argument. For -ax
profiling, we need two output registers for the two bb_init_trace_func
arguments. */
if (current_function_profile)
i = MAX (i, 1);
+ #endif
current_frame_info.n_output_regs = i;
/* ??? No rotating register support yet. */
*************** ia64_output_function_profiler (FILE *fil
*** 8577,8582 ****
--- 8579,8621 ----
fputs ("\t.body\n", file);
fputs ("\tmov out1 = r1\n", file);
fputs ("\tbr.call.sptk.many b0 = _mcount\n\t;;\n", file);
+ }
+
+ static GTY(()) rtx mcount_func_rtx;
+ static rtx
+ gen_mcount_func_rtx (void)
+ {
+ if (!mcount_func_rtx)
+ mcount_func_rtx = init_one_libfunc ("_mcount");
+ return mcount_func_rtx;
+ }
+
+ #ifndef NO_PROFILE_COUNTERS
+ #define NO_PROFILE_COUNTERS 0
+ #endif
+
+ void
+ ia64_profile_hook (int labelno)
+ {
+ rtx label, ip;
+
+ if (NO_PROFILE_COUNTERS)
+ label = const0_rtx;
+ else
+ {
+ char buf[30];
+ const char *label_name;
+ ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno);
+ label_name = (*targetm.strip_name_encoding) (ggc_strdup (buf));
+ label = gen_rtx_SYMBOL_REF (Pmode, label_name);
+ }
+ ip = gen_reg_rtx (Pmode);
+ emit_insn (gen_ip_value (ip));
+ emit_library_call (gen_mcount_func_rtx (), LCT_NORMAL,
+ VOIDmode, 3,
+ gen_rtx_REG (Pmode, BR_REG (0)), Pmode,
+ ip, Pmode,
+ label, Pmode);
}
#include "gt-ia64.h"
*** gcc.orig/gcc/config/ia64/ia64.md Fri Jun 17 11:08:05 2005
--- gcc/gcc/config/ia64/ia64.md Fri Jun 17 11:07:14 2005
***************
*** 6154,6159 ****
--- 6154,6169 ----
"addp4 %0 = %1, %2"
[(set_attr "itanium_class" "ialu")])
+ ;;
+ ;; Get instruction pointer
+
+ (define_insn "ip_value"
+ [(set (match_operand:DI 0 "register_operand" "=r")
+ (pc))]
+ ""
+ "mov %0 = ip"
+ [(set_attr "itanium_class" "ialu")])
+
;; Vector operations
(include "vect.md")
;; Atomic operations