This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Merge csl-arm-branch into mainline.
On Thursday 05 February 2004 6:25 am, Mark Mitchell wrote:
> >I'd like this patch (and the appropriate ARM bits) to be in 3.4 as well.
> >Will you approve it there as well please?
>
> Yes -- because multiple inheritance did work correctly on ARM in older
> versions of GCC.
>
> Paul, you want the ARM_DECLARE_FUNCTION_NAME and arm_output_mi_thunk
> changes from the ARM back end, plus the various
> current_function_is_thunk changes in the patch being discussed here.
> Would you please apply that?
Applied to gcc-3_4-branch as follows.
Paul
2004-02-05 Paul Brook <paul@codesourcery.com>
Backport from mainline.
2003-11-22 Phil Edwards <phil@codesourcery.com>
PR target/12476
* config/arm/arm.c (arm_output_mi_thunk): In Thumb mode, use
'bx' instead of 'b' to avoid branch range restrictions. Output
the thunk immediately before the thunked-to function.
* config/arm/arm.h (ARM_DECLARE_FUNCTION_NAME): Do not emit
.thumb_func if a thunk is being generated. Emit .code 16 along
with .thumb_func if a thunk is not being generated.
2003-11-05 Mark Mitchell <mark@codesourcery.com>
* calls.c (initialize_argument_information): Add CALL_FROM_THUNK_P
parameter. Use it instead of current_function_is_thunk.
* function.h (struct function): Update documentation for is_thunk.
* tree.h (CALL_FROM_THUNK_P): New macro.
* config/alpha/alpha.c (alpha_sa_mask): Do not check
no_new_pseudos when testing current_function_is_thunk.
* config/rs6000/rs6000.c (rs6000_ra_ever_killed): Likeiwse.
cp/
2003-11-05 Mark Mitchell <mark@codesourcery.com>
* decl.c (cxx_push_function_context): Do not set
current_function_is_thunk.
* method.c (use_thunk): Set CALL_FROM_THUNK on the call to the
actual function.
iIndex: gcc/calls.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/calls.c,v
retrieving revision 1.315.2.1
diff -u -p -r1.315.2.1 calls.c
--- gcc/calls.c 23 Jan 2004 23:35:53 -0000 1.315.2.1
+++ gcc/calls.c 5 Feb 2004 10:16:49 -0000
@@ -133,7 +133,8 @@ static int compute_argument_block_size (
static void initialize_argument_information (int, struct arg_data *,
struct args_size *, int, tree,
tree, CUMULATIVE_ARGS *, int,
- rtx *, int *, int *, int *);
+ rtx *, int *, int *, int *,
+ bool);
static void compute_argument_addresses (struct arg_data *, rtx, int);
static rtx rtx_for_function_call (tree, tree);
static void load_register_parameters (struct arg_data *, int, rtx *, int,
@@ -1023,7 +1024,10 @@ store_unaligned_arguments_into_pseudos (
and may be modified by this routine.
OLD_PENDING_ADJ, MUST_PREALLOCATE and FLAGS are pointers to integer
- flags which may may be modified by this routine. */
+ flags which may may be modified by this routine.
+
+ CALL_FROM_THUNK_P is true if this call is the jump from a thunk to
+ the thunked-to function. */
static void
initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED,
@@ -1034,7 +1038,8 @@ initialize_argument_information (int num
CUMULATIVE_ARGS *args_so_far,
int reg_parm_stack_space,
rtx *old_stack_level, int *old_pending_adj,
- int *must_preallocate, int *ecf_flags)
+ int *must_preallocate, int *ecf_flags,
+ bool call_from_thunk_p)
{
/* 1 if scanning parms front to back, -1 if scanning back to front. */
int inc;
@@ -1107,7 +1112,7 @@ initialize_argument_information (int num
{
/* If we're compiling a thunk, pass through invisible
references instead of making a copy. */
- if (current_function_is_thunk
+ if (call_from_thunk_p
#ifdef FUNCTION_ARG_CALLEE_COPIES
|| (FUNCTION_ARG_CALLEE_COPIES (*args_so_far, TYPE_MODE (type),
type, argpos < n_named_args)
@@ -2444,7 +2449,8 @@ expand_call (tree exp, rtx target, int i
n_named_args, actparms, fndecl,
&args_so_far, reg_parm_stack_space,
&old_stack_level, &old_pending_adj,
- &must_preallocate, &flags);
+ &must_preallocate, &flags,
+ CALL_FROM_THUNK_P (exp));
if (args_size.var)
{
Index: gcc/function.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/function.h,v
retrieving revision 1.108.4.1
diff -u -p -r1.108.4.1 function.h
--- gcc/function.h 23 Jan 2004 23:35:57 -0000 1.108.4.1
+++ gcc/function.h 5 Feb 2004 10:16:49 -0000
@@ -457,9 +457,10 @@ struct function GTY(())
/* Nonzero if the function being compiled issues a computed jump. */
unsigned int has_computed_jump : 1;
- /* Nonzero if the current function is a thunk (a lightweight function that
- just adjusts one of its arguments and forwards to another function), so
- we should try to cut corners where we can. */
+ /* Nonzero if the current function is a thunk, i.e., a lightweight
+ function implemented by the output_mi_thunk hook) that just
+ adjusts one of its arguments and forwards to another
+ function. */
unsigned int is_thunk : 1;
/* This bit is used by the exception handling logic. It is set if all
Index: gcc/tree.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/tree.h,v
retrieving revision 1.458.2.1
diff -u -p -r1.458.2.1 tree.h
--- gcc/tree.h 3 Feb 2004 16:12:22 -0000 1.458.2.1
+++ gcc/tree.h 5 Feb 2004 10:16:49 -0000
@@ -210,6 +210,8 @@ struct tree_common GTY(())
TREE_PROTECTED in
BLOCK
..._DECL
+ CALL_FROM_THUNK_P in
+ CALL_EXPR
side_effects_flag:
@@ -265,6 +267,7 @@ struct tree_common GTY(())
TREE_DEPRECATED in
..._DECL
+
*/
/* Define accessors for the fields that all tree nodes have
@@ -623,6 +626,10 @@ extern void tree_operand_check_failed (i
argument list. */
#define CALL_EXPR_HAS_RETURN_SLOT_ADDR(NODE) ((NODE)->common.private_flag)
+/* In a CALL_EXPR, means that the call is the jump from a thunk to the
+ thunked-to function. */
+#define CALL_FROM_THUNK_P(NODE) ((NODE)->common.protected_flag)
+
/* In a type, nonzero means that all objects of the type are guaranteed by
the
language or front-end to be properly aligned, so we can indicate that a
MEM
of this type is aligned at least to the alignment of the type, even if it
Index: gcc/config/alpha/alpha.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/alpha/alpha.c,v
retrieving revision 1.342.4.3
diff -u -p -r1.342.4.3 alpha.c
--- gcc/config/alpha/alpha.c 31 Jan 2004 06:18:09 -0000 1.342.4.3
+++ gcc/config/alpha/alpha.c 5 Feb 2004 10:16:49 -0000
@@ -6728,13 +6728,10 @@ alpha_sa_mask (unsigned long *imaskP, un
unsigned long fmask = 0;
unsigned int i;
- /* Irritatingly, there are two kinds of thunks -- those created with
- TARGET_ASM_OUTPUT_MI_THUNK and those with DECL_THUNK_P that go
- through the regular part of the compiler. In the
- TARGET_ASM_OUTPUT_MI_THUNK case we don't have valid register life
- info, but assemble_start_function wants to output .frame and
- .mask directives. */
- if (current_function_is_thunk && !no_new_pseudos)
+ /* When outputting a thunk, we don't have valid register life info,
+ but assemble_start_function wants to output .frame and .mask
+ directives. */
+ if (current_function_is_thunk)
{
*imaskP = 0;
*fmaskP = 0;
Index: gcc/config/arm/arm.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.317.4.2
diff -u -p -r1.317.4.2 arm.c
--- gcc/config/arm/arm.c 27 Jan 2004 14:57:26 -0000 1.317.4.2
+++ gcc/config/arm/arm.c 5 Feb 2004 10:16:50 -0000
@@ -13248,6 +13248,8 @@ arm_output_mi_thunk (FILE *file, tree th
HOST_WIDE_INT vcall_offset ATTRIBUTE_UNUSED,
tree function)
{
+ static int thunk_label = 0;
+ char label[256];
int mi_delta = delta;
const char *const mi_op = mi_delta < 0 ? "sub" : "add";
int shift = 0;
@@ -13255,6 +13257,14 @@ arm_output_mi_thunk (FILE *file, tree th
? 1 : 0);
if (mi_delta < 0)
mi_delta = - mi_delta;
+ if (TARGET_THUMB)
+ {
+ int labelno = thunk_label++;
+ ASM_GENERATE_INTERNAL_LABEL (label, "LTHUMBFUNC", labelno);
+ fputs ("\tldr\tr12, ", file);
+ assemble_name (file, label);
+ fputc ('\n', file);
+ }
while (mi_delta != 0)
{
if ((mi_delta & (3 << shift)) == 0)
@@ -13268,11 +13278,22 @@ arm_output_mi_thunk (FILE *file, tree th
shift += 8;
}
}
- fputs ("\tb\t", file);
- assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
- if (NEED_PLT_RELOC)
- fputs ("(PLT)", file);
- fputc ('\n', file);
+ if (TARGET_THUMB)
+ {
+ fprintf (file, "\tbx\tr12\n");
+ ASM_OUTPUT_ALIGN (file, 2);
+ assemble_name (file, label);
+ fputs (":\n", file);
+ assemble_integer (XEXP (DECL_RTL (function), 0), 4, BITS_PER_WORD, 1);
+ }
+ else
+ {
+ fputs ("\tb\t", file);
+ assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
+ if (NEED_PLT_RELOC)
+ fputs ("(PLT)", file);
+ fputc ('\n', file);
+ }
}
int
Index: gcc/config/arm/arm.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/arm.h,v
retrieving revision 1.214.2.1
diff -u -p -r1.214.2.1 arm.h
--- gcc/config/arm/arm.h 31 Jan 2004 06:18:11 -0000 1.214.2.1
+++ gcc/config/arm/arm.h 5 Feb 2004 10:16:50 -0000
@@ -2475,10 +2475,11 @@ extern int making_const_table;
{ \
if (TARGET_THUMB) \
{ \
- if (is_called_in_ARM_mode (DECL)) \
+ if (is_called_in_ARM_mode (DECL) \
+ || current_function_is_thunk) \
fprintf (STREAM, "\t.code 32\n") ; \
else \
- fprintf (STREAM, "\t.thumb_func\n") ; \
+ fprintf (STREAM, "\t.code 16\n\t.thumb_func\n") ; \
} \
if (TARGET_POKE_FUNCTION_NAME) \
arm_poke_function_name (STREAM, (char *) NAME); \
Index: gcc/config/rs6000/rs6000.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.576.2.5
diff -u -p -r1.576.2.5 rs6000.c
--- gcc/config/rs6000/rs6000.c 22 Jan 2004 09:14:49 -0000 1.576.2.5
+++ gcc/config/rs6000/rs6000.c 5 Feb 2004 10:16:49 -0000
@@ -10960,11 +10960,7 @@ rs6000_ra_ever_killed (void)
rtx reg;
rtx insn;
- /* Irritatingly, there are two kinds of thunks -- those created with
- TARGET_ASM_OUTPUT_MI_THUNK and those with DECL_THUNK_P that go
- through the regular part of the compiler. This is a very hacky
- way to tell them apart. */
- if (current_function_is_thunk && !no_new_pseudos)
+ if (current_function_is_thunk)
return 0;
/* regs_ever_live has LR marked as used if any sibcalls are present,
Index: gcc/cp/decl.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/cp/decl.c,v
retrieving revision 1.1174.2.5
diff -u -p -r1.1174.2.5 decl.c
--- gcc/cp/decl.c 3 Feb 2004 20:03:22 -0000 1.1174.2.5
+++ gcc/cp/decl.c 5 Feb 2004 10:16:49 -0000
@@ -11197,8 +11197,6 @@ cxx_push_function_context (struct functi
{
tree fn = f->decl;
- current_function_is_thunk = DECL_THUNK_P (fn);
-
if (DECL_SAVED_FUNCTION_DATA (fn))
{
/* If we already parsed this function, and we're just expanding it
Index: gcc/cp/method.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/cp/method.c,v
retrieving revision 1.275
diff -u -p -r1.275 method.c
--- gcc/cp/method.c 2 Jan 2004 15:57:16 -0000 1.275
+++ gcc/cp/method.c 5 Feb 2004 10:17:33 -0000
@@ -487,6 +487,7 @@ use_thunk (tree thunk_fndecl, bool emit_
t = tree_cons (NULL_TREE, a, t);
t = nreverse (t);
t = build_call (alias, t);
+ CALL_FROM_THUNK_P (t) = 1;
t = force_target_expr (TREE_TYPE (t), t);
if (!this_adjusting)
t = thunk_adjust (t, /*this_adjusting=*/0,