rpms/gcc/devel gcc4-dwarf2-frame_base.patch, NONE, 1.1 gcc4-pr23478.patch, NONE, 1.1 gcc4-pr23484.patch, NONE, 1.1 .cvsignore, 1.106, 1.107 gcc4-stack-protector.patch, 1.4, 1.5 gcc4.spec, 1.68, 1.69 sources, 1.108, 1.109 gcc4-pr21254.patch, 1.1, NONE gcc4-s390-stack-protector.patch, 1.1, NONE
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Mon Aug 22 21:29:06 UTC 2005
Author: jakub
Update of /cvs/dist/rpms/gcc/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv1275
Modified Files:
.cvsignore gcc4-stack-protector.patch gcc4.spec sources
Added Files:
gcc4-dwarf2-frame_base.patch gcc4-pr23478.patch
gcc4-pr23484.patch
Removed Files:
gcc4-pr21254.patch gcc4-s390-stack-protector.patch
Log Message:
4.0.1-10
gcc4-dwarf2-frame_base.patch:
defaults.h | 11 +
dwarf2out.c | 462 +++++++++++++++++++++++++++++++++++----------------------
function.c | 6
tree.h | 1
var-tracking.c | 149 +-----------------
5 files changed, 312 insertions(+), 317 deletions(-)
--- NEW FILE gcc4-dwarf2-frame_base.patch ---
2005-08-22 Richard Henderson <rth at redhat.com>
* function.c (ARG_POINTER_CFA_OFFSET): Move ...
* defaults.h (ARG_POINTER_CFA_OFFSET): ... here.
(INCOMING_FRAME_SP_OFFSET): Moved from ...
* dwarf2out.c (INCOMING_FRAME_SP_OFFSET): ... here.
(struct cfa_loc): Change reg to unsigned int,
rearrange for better packing.
(lookup_cfa_1): Remove inline marker.
(cfa_equal_p): Split out of ...
(def_cfa_1): ... here. Use INVALID_REGNUM.
(build_cfa_loc): Handle !cfa->indirect.
(frame_pointer_cfa_offset): New.
(dbx_reg_number): Assert register elimination performed; do
leaf register remapping.
(reg_loc_descriptor): Avoid calling dbx_reg_number when unused.
(eliminate_reg_to_offset): New.
(based_loc_descr): Remove can_use_fbreg argument. Use fbreg only
for verifiably local stack frame addresses; re-base to CFA.
(mem_loc_descriptor): Remove can_use_fbreg argument.
(concat_loc_descriptor, loc_descriptor): Likewise.
(containing_function_has_frame_base): Remove.
(rtl_for_decl_location): Don't do register elimination or
leaf register remapping here.
(secname_for_decl): Split out from ..
(add_location_or_const_value_attribute): ... here.
(convert_cfa_to_loc_list): New.
(compute_frame_pointer_to_cfa_displacement): New.
(gen_subprogram_die): Use them.
* tree.h (frame_base_decl): Remove.
* var-tracking.c (frame_base_decl, frame_stack_adjust): Remove.
(prologue_stack_adjust): Remove.
(vt_stack_adjustments): Use INCOMING_FRAME_SP_OFFSET.
(adjust_stack_reference): Re-base memories to arg_pointer_rtx.
(set_frame_base_location): Remove.
(compute_bb_dataflow, emit_notes_in_bb): Don't call it.
(dump_attrs_list, dump_dataflow_set): Use string concatenation.
(vt_add_function_parameters): Don't eliminate_regs.
(vt_initialize): Don't create frame_base_decl.
--- gcc/defaults.h 11 Aug 2005 00:28:03 -0000 1.173
+++ gcc/defaults.h 22 Aug 2005 16:26:45 -0000
@@ -835,4 +835,15 @@ Software Foundation, 51 Franklin Street,
#define FRAME_GROWS_DOWNWARD 0
#endif
+/* On most machines, the CFA coincides with the first incoming parm. */
+#ifndef ARG_POINTER_CFA_OFFSET
+#define ARG_POINTER_CFA_OFFSET(FNDECL) FIRST_PARM_OFFSET (FNDECL)
+#endif
+
+/* The offset from the incoming value of %sp to the top of the stack frame
+ for the current function. */
+#ifndef INCOMING_FRAME_SP_OFFSET
+#define INCOMING_FRAME_SP_OFFSET 0
+#endif
+
#endif /* ! GCC_DEFAULTS_H */
--- gcc/dwarf2out.c 11 Aug 2005 21:22:43 -0000 1.612
+++ gcc/dwarf2out.c 22 Aug 2005 16:26:47 -0000
@@ -235,9 +235,9 @@ dw_cfi_node;
of this structure. */
typedef struct cfa_loc GTY(())
{
- unsigned long reg;
HOST_WIDE_INT offset;
HOST_WIDE_INT base_offset;
+ unsigned int reg;
int indirect; /* 1 if CFA is accessed via a dereference. */
} dw_cfa_location;
@@ -427,12 +427,6 @@ static void def_cfa_1 (const char *, dw_
#ifndef DWARF_FRAME_REGNUM
#define DWARF_FRAME_REGNUM(REG) DBX_REGISTER_NUMBER (REG)
#endif
-
-/* The offset from the incoming value of %sp to the top of the stack frame
- for the current function. */
-#ifndef INCOMING_FRAME_SP_OFFSET
-#define INCOMING_FRAME_SP_OFFSET 0
-#endif
/* Hook used by __throw. */
@@ -659,7 +653,7 @@ add_fde_cfi (const char *label, dw_cfi_r
/* Subroutine of lookup_cfa. */
-static inline void
+static void
lookup_cfa_1 (dw_cfi_ref cfi, dw_cfa_location *loc)
{
switch (cfi->dw_cfi_opc)
@@ -689,7 +683,7 @@ lookup_cfa (dw_cfa_location *loc)
{
dw_cfi_ref cfi;
- loc->reg = (unsigned long) -1;
+ loc->reg = INVALID_REGNUM;
loc->offset = 0;
loc->indirect = 0;
loc->base_offset = 0;
@@ -733,6 +727,18 @@ dwarf2out_def_cfa (const char *label, un
def_cfa_1 (label, &loc);
}
+/* Determine if two dw_cfa_location structures define the same data. */
+
+static bool
+cfa_equal_p (const dw_cfa_location *loc1, const dw_cfa_location *loc2)
+{
+ return (loc1->reg == loc2->reg
+ && loc1->offset == loc2->offset
+ && loc1->indirect == loc2->indirect
+ && (loc1->indirect == 0
+ || loc1->base_offset == loc2->base_offset));
+}
+
/* This routine does the actual work. The CFA is now calculated from
the dw_cfa_location structure. */
@@ -752,9 +758,7 @@ def_cfa_1 (const char *label, dw_cfa_loc
lookup_cfa (&old_cfa);
/* If nothing changed, no need to issue any call frame instructions. */
- if (loc.reg == old_cfa.reg && loc.offset == old_cfa.offset
- && loc.indirect == old_cfa.indirect
- && (loc.indirect == 0 || loc.base_offset == old_cfa.base_offset))
+ if (cfa_equal_p (&loc, &old_cfa))
return;
cfi = new_cfi ();
@@ -769,7 +773,8 @@ def_cfa_1 (const char *label, dw_cfa_loc
}
#ifndef MIPS_DEBUGGING_INFO /* SGI dbx thinks this means no offset. */
- else if (loc.offset == old_cfa.offset && old_cfa.reg != (unsigned long) -1
+ else if (loc.offset == old_cfa.offset
+ && old_cfa.reg != INVALID_REGNUM
&& !loc.indirect)
{
/* Construct a "DW_CFA_def_cfa_register <register>" instruction,
@@ -3264,27 +3269,40 @@ build_cfa_loc (dw_cfa_location *cfa)
{
struct dw_loc_descr_struct *head, *tmp;
- gcc_assert (cfa->indirect);
-
- if (cfa->base_offset)
+ if (cfa->indirect)
{
- if (cfa->reg <= 31)
- head = new_loc_descr (DW_OP_breg0 + cfa->reg, cfa->base_offset, 0);
+ if (cfa->base_offset)
+ {
+ if (cfa->reg <= 31)
+ head = new_loc_descr (DW_OP_breg0 + cfa->reg, cfa->base_offset, 0);
+ else
+ head = new_loc_descr (DW_OP_bregx, cfa->reg, cfa->base_offset);
+ }
+ else if (cfa->reg <= 31)
+ head = new_loc_descr (DW_OP_reg0 + cfa->reg, 0, 0);
else
- head = new_loc_descr (DW_OP_bregx, cfa->reg, cfa->base_offset);
+ head = new_loc_descr (DW_OP_regx, cfa->reg, 0);
+
+ head->dw_loc_oprnd1.val_class = dw_val_class_const;
+ tmp = new_loc_descr (DW_OP_deref, 0, 0);
+ add_loc_descr (&head, tmp);
+ if (cfa->offset != 0)
+ {
+ tmp = new_loc_descr (DW_OP_plus_uconst, cfa->offset, 0);
+ add_loc_descr (&head, tmp);
+ }
}
- else if (cfa->reg <= 31)
- head = new_loc_descr (DW_OP_reg0 + cfa->reg, 0, 0);
else
- head = new_loc_descr (DW_OP_regx, cfa->reg, 0);
-
- head->dw_loc_oprnd1.val_class = dw_val_class_const;
- tmp = new_loc_descr (DW_OP_deref, 0, 0);
- add_loc_descr (&head, tmp);
- if (cfa->offset != 0)
{
- tmp = new_loc_descr (DW_OP_plus_uconst, cfa->offset, 0);
- add_loc_descr (&head, tmp);
+ if (cfa->offset == 0)
+ if (cfa->reg <= 31)
+ head = new_loc_descr (DW_OP_reg0 + cfa->reg, 0, 0);
+ else
+ head = new_loc_descr (DW_OP_regx, cfa->reg, 0);
+ else if (cfa->reg <= 31)
+ head = new_loc_descr (DW_OP_breg0 + cfa->reg, cfa->offset, 0);
+ else
+ head = new_loc_descr (DW_OP_bregx, cfa->reg, cfa->offset);
}
return head;
@@ -3777,6 +3795,10 @@ static GTY(()) int label_num;
#ifdef DWARF2_DEBUGGING_INFO
+/* Offset from the "steady-state frame pointer" to the CFA,
+ within the current function. */
+static HOST_WIDE_INT frame_pointer_cfa_offset;
+
/* Forward declarations for functions defined in this file. */
static int is_pseudo_reg (rtx);
@@ -3922,11 +3944,11 @@ static dw_loc_descr_ref reg_loc_descript
static dw_loc_descr_ref one_reg_loc_descriptor (unsigned int);
static dw_loc_descr_ref multiple_reg_loc_descriptor (rtx, rtx);
static dw_loc_descr_ref int_loc_descriptor (HOST_WIDE_INT);
-static dw_loc_descr_ref based_loc_descr (unsigned, HOST_WIDE_INT, bool);
+static dw_loc_descr_ref based_loc_descr (rtx, HOST_WIDE_INT);
static int is_based_loc (rtx);
-static dw_loc_descr_ref mem_loc_descriptor (rtx, enum machine_mode mode, bool);
-static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx, bool);
-static dw_loc_descr_ref loc_descriptor (rtx, bool);
+static dw_loc_descr_ref mem_loc_descriptor (rtx, enum machine_mode mode);
+static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx);
+static dw_loc_descr_ref loc_descriptor (rtx);
static dw_loc_descr_ref loc_descriptor_from_tree_1 (tree, int);
static dw_loc_descr_ref loc_descriptor_from_tree (tree);
static HOST_WIDE_INT ceiling (HOST_WIDE_INT, unsigned int);
@@ -8342,8 +8364,18 @@ dbx_reg_number (rtx rtl)
{
unsigned regno = REGNO (rtl);
+ /* We do not want to see registers that should have been eliminated. */
+ gcc_assert (HARD_FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM
+ || rtl != arg_pointer_rtx);
+ gcc_assert (HARD_FRAME_POINTER_REGNUM == FRAME_POINTER_REGNUM
+ || rtl != frame_pointer_rtx);
+
gcc_assert (regno < FIRST_PSEUDO_REGISTER);
+#ifdef LEAF_REG_REMAP
+ regno = LEAF_REG_REMAP (regno);
+#endif
+
return DBX_REGISTER_NUMBER (regno);
}
@@ -8373,20 +8405,17 @@ add_loc_descr_op_piece (dw_loc_descr_ref
static dw_loc_descr_ref
reg_loc_descriptor (rtx rtl)
{
- unsigned reg;
rtx regs;
if (REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
return 0;
- reg = dbx_reg_number (rtl);
regs = targetm.dwarf_register_span (rtl);
- if (hard_regno_nregs[REGNO (rtl)][GET_MODE (rtl)] > 1
- || regs)
+ if (hard_regno_nregs[REGNO (rtl)][GET_MODE (rtl)] > 1 || regs)
return multiple_reg_loc_descriptor (rtl, regs);
else
- return one_reg_loc_descriptor (reg);
+ return one_reg_loc_descriptor (dbx_reg_number (rtl));
}
/* Return a location descriptor that designates a machine register for
@@ -8490,25 +8519,53 @@ int_loc_descriptor (HOST_WIDE_INT i)
return new_loc_descr (op, i, 0);
}
+/* Return an offset from an eliminable register to the post-prologue
+ frame pointer. */
+
+static HOST_WIDE_INT
+eliminate_reg_to_offset (rtx reg)
+{
+ HOST_WIDE_INT offset = 0;
+
+ reg = eliminate_regs (reg, VOIDmode, NULL_RTX);
+ if (GET_CODE (reg) == PLUS)
+ {
+ offset = INTVAL (XEXP (reg, 1));
+ reg = XEXP (reg, 0);
+ }
+ gcc_assert (reg == (frame_pointer_needed ? hard_frame_pointer_rtx
+ : stack_pointer_rtx));
+
+ return offset;
+}
+
/* Return a location descriptor that designates a base+offset location. */
static dw_loc_descr_ref
-based_loc_descr (unsigned int reg, HOST_WIDE_INT offset, bool can_use_fbreg)
+based_loc_descr (rtx reg, HOST_WIDE_INT offset)
{
dw_loc_descr_ref loc_result;
- /* For the "frame base", we use the frame pointer or stack pointer
- registers, since the RTL for local variables is relative to one of
- them. */
- unsigned fp_reg = DBX_REGISTER_NUMBER (frame_pointer_needed
- ? HARD_FRAME_POINTER_REGNUM
- : STACK_POINTER_REGNUM);
-
- if (reg == fp_reg && can_use_fbreg)
- loc_result = new_loc_descr (DW_OP_fbreg, offset, 0);
- else if (reg <= 31)
- loc_result = new_loc_descr (DW_OP_breg0 + reg, offset, 0);
+
+ /* We only use "frame base" when we're sure we're talking about the
+ post-prologue local stack frame. We do this by *not* running
+ register elimination until this point, and recognizing the special
+ argument pointer and soft frame pointer rtx's. */
+ if (reg == arg_pointer_rtx || reg == frame_pointer_rtx)
+ {
+ offset += eliminate_reg_to_offset (reg);
+ offset += frame_pointer_cfa_offset;
+
+ loc_result = new_loc_descr (DW_OP_fbreg, offset, 0);
+ }
else
- loc_result = new_loc_descr (DW_OP_bregx, reg, offset);
+ {
+ unsigned int regno = dbx_reg_number (reg);
+
+ if (regno <= 31)
+ loc_result = new_loc_descr (DW_OP_breg0 + regno, offset, 0);
+ else
+ loc_result = new_loc_descr (DW_OP_bregx, regno, offset);
+ }
return loc_result;
}
@@ -8537,15 +8594,13 @@ is_based_loc (rtx rtl)
MODE is the mode of the memory reference, needed to handle some
autoincrement addressing modes.
- CAN_USE_FBREG is a flag whether we can use DW_AT_frame_base in the location
- list for RTL. We can't use it when we are emitting location list for
- virtual variable frame_base_decl (i.e. a location list for DW_AT_frame_base)
- which describes how frame base changes when !frame_pointer_needed.
+ CAN_USE_FBREG is a flag whether we can use DW_AT_frame_base in the
+ location list for RTL.
Return 0 if we can't represent the location. */
static dw_loc_descr_ref
-mem_loc_descriptor (rtx rtl, enum machine_mode mode, bool can_use_fbreg)
+mem_loc_descriptor (rtx rtl, enum machine_mode mode)
{
dw_loc_descr_ref mem_loc_result = NULL;
enum dwarf_location_atom op;
@@ -8592,13 +8647,11 @@ mem_loc_descriptor (rtx rtl, enum machin
memory) so DWARF consumers need to be aware of the subtle
distinction between OP_REG and OP_BASEREG. */
if (REGNO (rtl) < FIRST_PSEUDO_REGISTER)
- mem_loc_result = based_loc_descr (dbx_reg_number (rtl), 0,
- can_use_fbreg);
+ mem_loc_result = based_loc_descr (rtl, 0);
break;
case MEM:
- mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl),
- can_use_fbreg);
+ mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl));
if (mem_loc_result != 0)
add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
break;
@@ -8664,13 +8717,11 @@ mem_loc_descriptor (rtx rtl, enum machin
case PLUS:
plus:
if (is_based_loc (rtl))
- mem_loc_result = based_loc_descr (dbx_reg_number (XEXP (rtl, 0)),
- INTVAL (XEXP (rtl, 1)),
- can_use_fbreg);
+ mem_loc_result = based_loc_descr (XEXP (rtl, 0),
+ INTVAL (XEXP (rtl, 1)));
else
{
- mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode,
- can_use_fbreg);
+ mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode);
if (mem_loc_result == 0)
break;
@@ -8682,8 +8733,7 @@ mem_loc_descriptor (rtx rtl, enum machin
else
{
add_loc_descr (&mem_loc_result,
- mem_loc_descriptor (XEXP (rtl, 1), mode,
- can_use_fbreg));
+ mem_loc_descriptor (XEXP (rtl, 1), mode));
add_loc_descr (&mem_loc_result,
new_loc_descr (DW_OP_plus, 0, 0));
}
@@ -8710,10 +8760,8 @@ mem_loc_descriptor (rtx rtl, enum machin
do_binop:
{
- dw_loc_descr_ref op0 = mem_loc_descriptor (XEXP (rtl, 0), mode,
- can_use_fbreg);
- dw_loc_descr_ref op1 = mem_loc_descriptor (XEXP (rtl, 1), mode,
- can_use_fbreg);
+ dw_loc_descr_ref op0 = mem_loc_descriptor (XEXP (rtl, 0), mode);
+ dw_loc_descr_ref op1 = mem_loc_descriptor (XEXP (rtl, 1), mode);
if (op0 == 0 || op1 == 0)
break;
@@ -8739,11 +8787,11 @@ mem_loc_descriptor (rtx rtl, enum machin
This is typically a complex variable. */
static dw_loc_descr_ref
-concat_loc_descriptor (rtx x0, rtx x1, bool can_use_fbreg)
+concat_loc_descriptor (rtx x0, rtx x1)
{
dw_loc_descr_ref cc_loc_result = NULL;
- dw_loc_descr_ref x0_ref = loc_descriptor (x0, can_use_fbreg);
- dw_loc_descr_ref x1_ref = loc_descriptor (x1, can_use_fbreg);
+ dw_loc_descr_ref x0_ref = loc_descriptor (x0);
+ dw_loc_descr_ref x1_ref = loc_descriptor (x1);
if (x0_ref == 0 || x1_ref == 0)
return 0;
@@ -8757,29 +8805,6 @@ concat_loc_descriptor (rtx x0, rtx x1, b
return cc_loc_result;
}
-/* Return true if DECL's containing function has a frame base attribute.
- Return false otherwise. */
-
-static bool
-containing_function_has_frame_base (tree decl)
-{
- tree declcontext = decl_function_context (decl);
- dw_die_ref context;
- dw_attr_ref attr;
-
- if (!declcontext)
- return false;
-
- context = lookup_decl_die (declcontext);
- if (!context)
- return false;
-
- for (attr = context->die_attr; attr; attr = attr->dw_attr_next)
- if (attr->dw_attr == DW_AT_frame_base)
- return true;
- return false;
-}
-
/* Output a proper Dwarf location descriptor for a variable or parameter
which is either allocated in a register or in a memory location. For a
register, we just generate an OP_REG and the register number. For a
@@ -8789,7 +8814,7 @@ containing_function_has_frame_base (tree
If we don't know how to describe it, return 0. */
static dw_loc_descr_ref
-loc_descriptor (rtx rtl, bool can_use_fbreg)
+loc_descriptor (rtx rtl)
{
dw_loc_descr_ref loc_result = NULL;
@@ -8810,20 +8835,18 @@ loc_descriptor (rtx rtl, bool can_use_fb
break;
case MEM:
- loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl),
- can_use_fbreg);
+ loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl));
break;
case CONCAT:
- loc_result = concat_loc_descriptor (XEXP (rtl, 0), XEXP (rtl, 1),
- can_use_fbreg);
+ loc_result = concat_loc_descriptor (XEXP (rtl, 0), XEXP (rtl, 1));
break;
case VAR_LOCATION:
/* Single part. */
if (GET_CODE (XEXP (rtl, 1)) != PARALLEL)
{
- loc_result = loc_descriptor (XEXP (XEXP (rtl, 1), 0), can_use_fbreg);
+ loc_result = loc_descriptor (XEXP (XEXP (rtl, 1), 0));
break;
}
@@ -8838,16 +8861,14 @@ loc_descriptor (rtx rtl, bool can_use_fb
int i;
/* Create the first one, so we have something to add to. */
- loc_result = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0),
- can_use_fbreg);
+ loc_result = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0));
mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, 0), 0));
add_loc_descr_op_piece (&loc_result, GET_MODE_SIZE (mode));
for (i = 1; i < num_elem; i++)
{
dw_loc_descr_ref temp;
- temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0),
- can_use_fbreg);
+ temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0));
add_loc_descr (&loc_result, temp);
mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, i), 0));
add_loc_descr_op_piece (&loc_result, GET_MODE_SIZE (mode));
@@ -8976,11 +8997,10 @@ loc_descriptor_from_tree_1 (tree loc, in
else
{
enum machine_mode mode;
- bool can_use_fb = containing_function_has_frame_base (loc);
/* Certain constructs can only be represented at top-level. */
if (want_address == 2)
- return loc_descriptor (rtl, can_use_fb);
+ return loc_descriptor (rtl);
mode = GET_MODE (rtl);
if (MEM_P (rtl))
@@ -8988,7 +9008,7 @@ loc_descriptor_from_tree_1 (tree loc, in
rtl = XEXP (rtl, 0);
have_address = 1;
}
- ret = mem_loc_descriptor (rtl, mode, can_use_fb);
+ ret = mem_loc_descriptor (rtl, mode);
}
}
break;
@@ -9062,14 +9082,12 @@ loc_descriptor_from_tree_1 (tree loc, in
/* Get an RTL for this, if something has been emitted. */
rtx rtl = lookup_constant_def (loc);
enum machine_mode mode;
- bool can_use_fb;
if (!rtl || !MEM_P (rtl))
return 0;
- can_use_fb = containing_function_has_frame_base (loc);
mode = GET_MODE (rtl);
rtl = XEXP (rtl, 0);
- ret = mem_loc_descriptor (rtl, mode, can_use_fb);
+ ret = mem_loc_descriptor (rtl, mode);
have_address = 1;
break;
}
@@ -9959,19 +9977,10 @@ rtl_for_decl_location (tree decl)
plus_constant (XEXP (rtl, 0), rsize-dsize));
}
- if (rtl != NULL_RTX)
- {
- rtl = eliminate_regs (rtl, 0, NULL_RTX);
-#ifdef LEAF_REG_REMAP
- if (current_function_uses_only_leaf_regs)
- leaf_renumber_regs_insn (rtl);
-#endif
- }
-
/* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time constant,
and will have been substituted directly into all expressions that use it.
C does not have such a concept, but C++ and other languages do. */
- else if (TREE_CODE (decl) == VAR_DECL && DECL_INITIAL (decl))
+ if (!rtl && TREE_CODE (decl) == VAR_DECL && DECL_INITIAL (decl))
{
/* If a variable is initialized with a string constant without embedded
zeros, build CONST_STRING. */
@@ -10019,6 +10028,34 @@ rtl_for_decl_location (tree decl)
return rtl;
}
+/* We need to figure out what section we should use as the base for the
+ address ranges where a given location is valid.
+ 1. If this particular DECL has a section associated with it, use that.
+ 2. If this function has a section associated with it, use that.
+ 3. Otherwise, use the text section.
+ XXX: If you split a variable across multiple sections, we won't notice. */
+
+static const char *
+secname_for_decl (tree decl)
+{
+ const char *secname;
+
+ if (DECL_SECTION_NAME (decl))
+ {
+ tree sectree = DECL_SECTION_NAME (decl);
+ secname = TREE_STRING_POINTER (sectree);
+ }
+ else if (current_function_decl && DECL_SECTION_NAME (current_function_decl))
+ {
+ tree sectree = DECL_SECTION_NAME (current_function_decl);
+ secname = TREE_STRING_POINTER (sectree);
+ }
+ else
+ secname = text_section_label;
+
+ return secname;
+}
+
/* Generate *either* a DW_AT_location attribute or else a DW_AT_const_value
data attribute for a variable or a parameter. We generate the
DW_AT_const_value attribute only in those cases where the given variable
@@ -10037,7 +10074,6 @@ add_location_or_const_value_attribute (d
rtx rtl;
dw_loc_descr_ref descr;
var_loc_list *loc_list;
- bool can_use_fb;
struct var_loc_node *node;
if (TREE_CODE (decl) == ERROR_MARK)
return;
@@ -10045,8 +10081,6 @@ add_location_or_const_value_attribute (d
gcc_assert (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL
|| TREE_CODE (decl) == RESULT_DECL);
- can_use_fb = containing_function_has_frame_base (decl);
-
/* See if we possibly have multiple locations for this variable. */
loc_list = lookup_decl_loc (decl);
@@ -10054,36 +10088,10 @@ add_location_or_const_value_attribute (d
differ. */
if (loc_list && loc_list->first != loc_list->last)
{
- const char *secname;
- const char *endname;
+ const char *endname, *secname;
dw_loc_list_ref list;
rtx varloc;
-
- /* We need to figure out what section we should use as the base
- for the address ranges where a given location is valid.
- 1. If this particular DECL has a section associated with it,
- use that.
- 2. If this function has a section associated with it, use
- that.
- 3. Otherwise, use the text section.
- XXX: If you split a variable across multiple sections, this
- won't notice. */
-
- if (DECL_SECTION_NAME (decl))
- {
- tree sectree = DECL_SECTION_NAME (decl);
- secname = TREE_STRING_POINTER (sectree);
- }
- else if (current_function_decl
- && DECL_SECTION_NAME (current_function_decl))
- {
- tree sectree = DECL_SECTION_NAME (current_function_decl);
- secname = TREE_STRING_POINTER (sectree);
- }
- else
- secname = text_section_label;
-
/* Now that we know what section we are using for a base,
actually construct the list of locations.
The first location information is what is passed to the
@@ -10097,7 +10105,9 @@ add_location_or_const_value_attribute (d
node = loc_list->first;
varloc = NOTE_VAR_LOCATION (node->var_loc_note);
- list = new_loc_list (loc_descriptor (varloc, can_use_fb),
+ secname = secname_for_decl (decl);
+
+ list = new_loc_list (loc_descriptor (varloc),
node->label, node->next->label, secname, 1);
node = node->next;
@@ -10107,9 +10117,7 @@ add_location_or_const_value_attribute (d
/* The variable has a location between NODE->LABEL and
NODE->NEXT->LABEL. */
varloc = NOTE_VAR_LOCATION (node->var_loc_note);
- add_loc_descr_to_loc_list (&list,
- loc_descriptor (varloc,
- can_use_fb),
+ add_loc_descr_to_loc_list (&list, loc_descriptor (varloc),
node->label, node->next->label, secname);
}
@@ -10128,9 +10136,7 @@ add_location_or_const_value_attribute (d
current_function_funcdef_no);
endname = ggc_strdup (label_id);
}
- add_loc_descr_to_loc_list (&list,
- loc_descriptor (varloc,
- can_use_fb),
+ add_loc_descr_to_loc_list (&list, loc_descriptor (varloc),
node->label, endname, secname);
}
@@ -10155,8 +10161,7 @@ add_location_or_const_value_attribute (d
if (loc_list && loc_list->first)
{
node = loc_list->first;
- descr = loc_descriptor (NOTE_VAR_LOCATION (node->var_loc_note),
- can_use_fb);
+ descr = loc_descriptor (NOTE_VAR_LOCATION (node->var_loc_note));
if (descr)
{
add_AT_location_description (die, attr, descr);
@@ -10202,6 +10207,98 @@ tree_add_const_value_attribute (dw_die_r
TREE_INT_CST_LOW (init));
}
+/* Convert the CFI instructions for the current function into a location
+ list. This is used for DW_AT_frame_base when we targeting a dwarf2
+ consumer that does not support the dwarf3 DW_OP_call_frame_cfa. */
+
+static dw_loc_list_ref
+convert_cfa_to_loc_list (void)
+{
+ dw_fde_ref fde;
+ dw_loc_list_ref list, *list_tail;
+ dw_cfi_ref cfi;
+ dw_cfa_location last_cfa, next_cfa;
+ const char *start_label, *last_label, *section;
+
+ fde = &fde_table[fde_table_in_use - 1];
+
+ section = secname_for_decl (current_function_decl);
+ list_tail = &list;
+ list = NULL;
+
+ next_cfa.reg = INVALID_REGNUM;
+ next_cfa.offset = 0;
+ next_cfa.indirect = 0;
+ next_cfa.base_offset = 0;
+
+ start_label = fde->dw_fde_begin;
+
+ /* ??? Bald assumption that the CIE opcode list does not contain
+ advance opcodes. */
+ for (cfi = cie_cfi_head; cfi; cfi = cfi->dw_cfi_next)
+ lookup_cfa_1 (cfi, &next_cfa);
+
+ last_cfa = next_cfa;
+ last_label = start_label;
+
+ for (cfi = fde->dw_fde_cfi; cfi; cfi = cfi->dw_cfi_next)
+ switch (cfi->dw_cfi_opc)
+ {
+ case DW_CFA_advance_loc1:
+ case DW_CFA_advance_loc2:
+ case DW_CFA_advance_loc4:
+ if (!cfa_equal_p (&last_cfa, &next_cfa))
+ {
+ *list_tail = new_loc_list (build_cfa_loc (&last_cfa), start_label,
+ last_label, section, list == NULL);
+
+ list_tail = &(*list_tail)->dw_loc_next;
+ last_cfa = next_cfa;
+ start_label = last_label;
+ }
+ last_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
+ break;
+
+ case DW_CFA_advance_loc:
+ /* The encoding is complex enough that we should never emit this. */
+ case DW_CFA_remember_state:
+ case DW_CFA_restore_state:
+ /* We don't handle these two in this function. It would be possible
+ if it were to be required. */
+ gcc_unreachable ();
+
+ default:
+ lookup_cfa_1 (cfi, &next_cfa);
+ break;
+ }
+
+ if (!cfa_equal_p (&last_cfa, &next_cfa))
+ {
+ *list_tail = new_loc_list (build_cfa_loc (&last_cfa), start_label,
+ last_label, section, list == NULL);
+ list_tail = &(*list_tail)->dw_loc_next;
+ start_label = last_label;
+ }
+ *list_tail = new_loc_list (build_cfa_loc (&next_cfa), start_label,
+ fde->dw_fde_end, section, list == NULL);
+
+ return list;
+}
+
+/* Compute a displacement from the "steady-state frame pointer" to
+ the CFA, and store it in frame_pointer_cfa_offset. */
+
+static void
+compute_frame_pointer_to_cfa_displacement (void)
+{
+ HOST_WIDE_INT offset;
+
+ offset = eliminate_reg_to_offset (arg_pointer_rtx);
+ offset += ARG_POINTER_CFA_OFFSET (current_function_decl);
+
+ frame_pointer_cfa_offset = -offset;
+}
+
/* Generate a DW_AT_name attribute given some string value to be included as
the value of the attribute. */
@@ -11248,7 +11345,6 @@ gen_subprogram_die (tree decl, dw_die_re
char label_id[MAX_ARTIFICIAL_LABEL_BYTES];
tree origin = decl_ultimate_origin (decl);
dw_die_ref subr_die;
- rtx fp_reg;
tree fn_arg_types;
tree outer_scope;
dw_die_ref old_die = lookup_decl_die (decl);
@@ -11411,20 +11507,32 @@ gen_subprogram_die (tree decl, dw_die_re
add_AT_fde_ref (subr_die, DW_AT_MIPS_fde, current_funcdef_fde);
#endif
- /* Define the "frame base" location for this routine. We use the
- frame pointer or stack pointer registers, since the RTL for local
- variables is relative to one of them. */
- if (frame_base_decl && lookup_decl_loc (frame_base_decl) != NULL)
- {
- add_location_or_const_value_attribute (subr_die, frame_base_decl,
- DW_AT_frame_base);
- }
- else
- {
- fp_reg
- = frame_pointer_needed ? hard_frame_pointer_rtx : stack_pointer_rtx;
- add_AT_loc (subr_die, DW_AT_frame_base, reg_loc_descriptor (fp_reg));
- }
+ /* We define the "frame base" as the function's CFA. This is more
+ convenient for several reasons: (1) It's stable across the prologue
+ and epilogue, which makes it better than just a frame pointer,
+ (2) With dwarf3, there exists a one-byte encoding that allows us
+ to reference the .debug_frame data by proxy, but failing that,
+ (3) We can at least reuse the code inspection and interpretation
+ code that determines the CFA position at various points in the
+ function. */
+ /* ??? Use some command-line or configury switch to enable the use
+ of dwarf3 DW_OP_call_frame_cfa. At present there are no dwarf
+ consumers that understand it; fall back to "pure" dwarf2 and
+ convert the CFA data into a location list. */
+ {
+ dw_loc_list_ref list = convert_cfa_to_loc_list ();
+ if (list->dw_loc_next)
+ add_AT_loc_list (subr_die, DW_AT_frame_base, list);
+ else
+ add_AT_loc (subr_die, DW_AT_frame_base, list->expr);
+ }
+
+ /* Compute a displacement from the "steady-state frame pointer" to
+ the CFA. The former is what all stack slots and argument slots
+ will reference in the rtl; the later is what we've told the
+ debugger about. We'll need to adjust all frame_base references
+ by this displacement. */
+ compute_frame_pointer_to_cfa_displacement ();
if (cfun->static_chain_decl)
add_AT_location_description (subr_die, DW_AT_static_link,
--- gcc/function.c 10 Aug 2005 09:02:45 -0000 1.642
+++ gcc/function.c 22 Aug 2005 16:26:48 -0000
@@ -1211,12 +1211,6 @@ static int cfa_offset;
#endif
#endif
-/* On most machines, the CFA coincides with the first incoming parm. */
-
-#ifndef ARG_POINTER_CFA_OFFSET
-#define ARG_POINTER_CFA_OFFSET(FNDECL) FIRST_PARM_OFFSET (FNDECL)
-#endif
-
/* Given a piece of RTX and a pointer to a HOST_WIDE_INT, if the RTX
is a virtual register, return the equivalent hard register and set the
--- gcc/tree.h 17 Aug 2005 04:00:21 -0000 1.753
+++ gcc/tree.h 22 Aug 2005 16:26:48 -0000
@@ -3036,7 +3036,6 @@ enum ptrmemfunc_vbit_where_t
#define NULL_TREE (tree) NULL
-extern GTY(()) tree frame_base_decl;
extern tree decl_assembler_name (tree);
/* Compute the number of bytes occupied by 'node'. This routine only
--- gcc/var-tracking.c 5 Jul 2005 16:20:30 -0000 2.31
+++ gcc/var-tracking.c 22 Aug 2005 16:26:49 -0000
@@ -266,19 +266,12 @@ static htab_t changed_variables;
/* Shall notes be emitted? */
static bool emit_notes;
-/* Fake variable for stack pointer. */
-tree frame_base_decl;
-
-/* Stack adjust caused by function prologue. */
-static HOST_WIDE_INT frame_stack_adjust;
-
/* Local function prototypes. */
static void stack_adjust_offset_pre_post (rtx, HOST_WIDE_INT *,
HOST_WIDE_INT *);
static void insn_stack_adjust_offset_pre_post (rtx, HOST_WIDE_INT *,
HOST_WIDE_INT *);
static void bb_stack_adjust_offset (basic_block);
-static HOST_WIDE_INT prologue_stack_adjust (void);
static bool vt_stack_adjustments (void);
static rtx adjust_stack_reference (rtx, HOST_WIDE_INT);
static hashval_t variable_htab_hash (const void *);
@@ -333,7 +326,6 @@ static void dump_dataflow_set (dataflow_
static void dump_dataflow_sets (void);
static void variable_was_changed (variable, htab_t);
-static void set_frame_base_location (dataflow_set *, rtx);
static void set_variable_part (dataflow_set *, rtx, tree, HOST_WIDE_INT);
static void delete_variable_part (dataflow_set *, rtx, tree, HOST_WIDE_INT);
static int emit_note_insn_var_location (void **, void *);
@@ -489,38 +481,6 @@ bb_stack_adjust_offset (basic_block bb)
VTI (bb)->out.stack_adjust = offset;
}
-/* Compute stack adjustment caused by function prologue. */
-
-static HOST_WIDE_INT
-prologue_stack_adjust (void)
-{
- HOST_WIDE_INT offset = 0;
- basic_block bb = ENTRY_BLOCK_PTR->next_bb;
- rtx insn;
- rtx end;
-
- if (!BB_END (bb))
- return 0;
-
- end = NEXT_INSN (BB_END (bb));
- for (insn = BB_HEAD (bb); insn != end; insn = NEXT_INSN (insn))
- {
- if (NOTE_P (insn)
- && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PROLOGUE_END)
- break;
-
- if (INSN_P (insn))
- {
- HOST_WIDE_INT tmp;
-
- insn_stack_adjust_offset_pre_post (insn, &tmp, &tmp);
- offset += tmp;
- }
- }
-
- return offset;
-}
-
/* Compute stack adjustments for all blocks by traversing DFS tree.
Return true when the adjustments on all incoming edges are consistent.
Heavily borrowed from flow_depth_first_order_compute. */
@@ -533,7 +493,7 @@ vt_stack_adjustments (void)
/* Initialize entry block. */
VTI (ENTRY_BLOCK_PTR)->visited = true;
- VTI (ENTRY_BLOCK_PTR)->out.stack_adjust = frame_stack_adjust;
+ VTI (ENTRY_BLOCK_PTR)->out.stack_adjust = INCOMING_FRAME_SP_OFFSET;
/* Allocate stack for back-tracking up CFG. */
stack = xmalloc ((n_basic_blocks + 1) * sizeof (edge_iterator));
@@ -587,27 +547,23 @@ vt_stack_adjustments (void)
return true;
}
-/* Adjust stack reference MEM by ADJUSTMENT bytes and return the new rtx. */
+/* Adjust stack reference MEM by ADJUSTMENT bytes and make it relative
+ to the argument pointer. Return the new rtx. */
static rtx
adjust_stack_reference (rtx mem, HOST_WIDE_INT adjustment)
{
- rtx adjusted_mem;
- rtx tmp;
+ rtx addr, cfa, tmp;
- if (adjustment == 0)
- return mem;
+ adjustment -= ARG_POINTER_CFA_OFFSET (current_function_decl);
+ cfa = plus_constant (arg_pointer_rtx, adjustment);
- adjusted_mem = copy_rtx (mem);
- XEXP (adjusted_mem, 0) = replace_rtx (XEXP (adjusted_mem, 0),
- stack_pointer_rtx,
- gen_rtx_PLUS (Pmode, stack_pointer_rtx,
- GEN_INT (adjustment)));
- tmp = simplify_rtx (XEXP (adjusted_mem, 0));
+ addr = replace_rtx (copy_rtx (XEXP (mem, 0)), stack_pointer_rtx, cfa);
+ tmp = simplify_rtx (addr);
if (tmp)
- XEXP (adjusted_mem, 0) = tmp;
+ addr = tmp;
- return adjusted_mem;
+ return replace_equiv_address_nv (mem, addr);
}
/* The hash function for variable_htab, computes the hash value
@@ -1673,14 +1629,7 @@ compute_bb_dataflow (basic_block bb)
break;
case MO_ADJUST:
- {
- rtx base;
-
- out->stack_adjust += VTI (bb)->mos[i].u.adjust;
- base = gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx,
- out->stack_adjust));
- set_frame_base_location (out, base);
- }
+ out->stack_adjust += VTI (bb)->mos[i].u.adjust;
break;
}
}
@@ -1803,8 +1752,7 @@ dump_attrs_list (attrs list)
for (; list; list = list->next)
{
print_mem_expr (dump_file, list->decl);
- fprintf (dump_file, "+");
- fprintf (dump_file, HOST_WIDE_INT_PRINT_DEC, list->offset);
+ fprintf (dump_file, "+" HOST_WIDE_INT_PRINT_DEC, list->offset);
}
fprintf (dump_file, "\n");
}
@@ -1854,9 +1802,8 @@ dump_dataflow_set (dataflow_set *set)
{
int i;
- fprintf (dump_file, "Stack adjustment: ");
- fprintf (dump_file, HOST_WIDE_INT_PRINT_DEC, set->stack_adjust);
- fprintf (dump_file, "\n");
+ fprintf (dump_file, "Stack adjustment: " HOST_WIDE_INT_PRINT_DEC "\n",
+ set->stack_adjust);
for (i = 1; i < FIRST_PSEUDO_REGISTER; i++)
{
if (set->regs[i])
@@ -1938,37 +1885,6 @@ variable_was_changed (variable var, htab
}
}
-/* Set the location of frame_base_decl to LOC in dataflow set SET. This
- function expects that frame_base_decl has already one location for offset 0
- in the variable table. */
-
-static void
-set_frame_base_location (dataflow_set *set, rtx loc)
-{
- variable var;
-
- var = htab_find_with_hash (set->vars, frame_base_decl,
- VARIABLE_HASH_VAL (frame_base_decl));
-#ifdef ENABLE_CHECKING
- if (!var)
- abort ();
- if (var->n_var_parts != 1)
- abort ();
- if (var->var_part[0].offset != 0)
- abort ();
- if (!var->var_part[0].loc_chain)
- abort ();
-#endif
-
- /* If frame_base_decl is shared unshare it first. */
- if (var->refcount > 1)
- var = unshare_variable (set, var);
-
- var->var_part[0].loc_chain->loc = loc;
- var->var_part[0].cur_loc = loc;
- variable_was_changed (var, set->vars);
-}
-
/* Set the part of variable's location in the dataflow set SET. The variable
part is specified by variable's declaration DECL and offset OFFSET and the
part's location by LOC. */
@@ -2499,15 +2415,7 @@ emit_notes_in_bb (basic_block bb)
break;
case MO_ADJUST:
- {
- rtx base;
-
- set.stack_adjust += VTI (bb)->mos[i].u.adjust;
- base = gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx,
- set.stack_adjust));
- set_frame_base_location (&set, base);
- emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN);
- }
+ set.stack_adjust += VTI (bb)->mos[i].u.adjust;
break;
}
}
@@ -2617,7 +2525,6 @@ vt_add_function_parameters (void)
abort ();
#endif
- incoming = eliminate_regs (incoming, 0, NULL_RTX);
out = &VTI (ENTRY_BLOCK_PTR)->out;
if (REG_P (incoming))
@@ -2631,9 +2538,7 @@ vt_add_function_parameters (void)
set_variable_part (out, incoming, parm, offset);
}
else if (MEM_P (incoming))
- {
- set_variable_part (out, incoming, parm, offset);
- }
+ set_variable_part (out, incoming, parm, offset);
}
}
@@ -2778,28 +2683,6 @@ vt_initialize (void)
changed_variables = htab_create (10, variable_htab_hash, variable_htab_eq,
NULL);
vt_add_function_parameters ();
-
- if (!frame_pointer_needed)
- {
- rtx base;
-
- /* Create fake variable for tracking stack pointer changes. */
- frame_base_decl = make_node (VAR_DECL);
- DECL_NAME (frame_base_decl) = get_identifier ("___frame_base_decl");
- TREE_TYPE (frame_base_decl) = char_type_node;
- DECL_ARTIFICIAL (frame_base_decl) = 1;
- DECL_IGNORED_P (frame_base_decl) = 1;
-
- /* Set its initial "location". */
- frame_stack_adjust = -prologue_stack_adjust ();
- base = gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx,
- frame_stack_adjust));
- set_variable_part (&VTI (ENTRY_BLOCK_PTR)->out, base, frame_base_decl, 0);
- }
- else
- {
- frame_base_decl = NULL;
- }
}
/* Free the data structures needed for variable tracking. */
gcc4-pr23478.patch:
flow.c | 12 +-
global.c | 4
regs.h | 7 +
testsuite/g++.dg/opt/pr23478.C | 211 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 231 insertions(+), 3 deletions(-)
--- NEW FILE gcc4-pr23478.patch ---
2005-08-22 Jakub Jelinek <jakub at redhat.com>
PR rtl-optimization/23478
* regs.h (reg_info): Add throw_calls_crossed.
(REG_N_THROWING_CALLS_CROSSED): Define.
* flow.c (allocate_reg_life_data): Initialize
REG_N_THROWING_CALLS_CROSSED.
(propagate_one_insn, attempt_auto_inc): Update
REG_N_THROWING_CALLS_CROSSED.
* global.c (global_alloc): Don't allocate pseudos across
calls that may throw.
* g++.dg/opt/pr23478.C: New test.
--- gcc/regs.h.jj 2005-07-02 02:27:21.000000000 +0200
+++ gcc/regs.h 2005-08-22 16:29:30.000000000 +0200
@@ -61,6 +61,7 @@ typedef struct reg_info_def
int deaths; /* # of times (REG n) dies */
int live_length; /* # of instructions (REG n) is live */
int calls_crossed; /* # of calls (REG n) is live across */
+ int throw_calls_crossed; /* # of calls that may throw (REG n) is live across */
int basic_block; /* # of basic blocks (REG n) is used in */
} reg_info;
@@ -125,6 +126,12 @@ extern varray_type reg_n_info;
#define REG_N_CALLS_CROSSED(N) (VARRAY_REG (reg_n_info, N)->calls_crossed)
+/* Indexed by N, gives number of CALL_INSNS that may throw, across which
+ (REG n) is live. */
+
+#define REG_N_THROWING_CALLS_CROSSED(N) \
+ (VARRAY_REG (reg_n_info, N)->throw_calls_crossed)
+
/* Total number of instructions at which (REG n) is live.
The larger this is, the less priority (REG n) gets for
allocation in a hard register (in global-alloc).
--- gcc/global.c.jj 2005-07-07 13:04:09.000000000 +0200
+++ gcc/global.c 2005-08-22 16:37:39.000000000 +0200
@@ -465,7 +465,9 @@ global_alloc (FILE *file)
/* Don't allocate pseudos that cross calls,
if this function receives a nonlocal goto. */
&& (! current_function_has_nonlocal_label
- || REG_N_CALLS_CROSSED (i) == 0))
+ || REG_N_CALLS_CROSSED (i) == 0)
+ /* Don't allocate pseudos that cross calls that may throw. */
+ && REG_N_THROWING_CALLS_CROSSED (i) == 0)
{
if (reg_renumber[i] < 0
&& reg_may_share[i] && reg_allocno[reg_may_share[i]] >= 0)
--- gcc/flow.c.jj 2005-08-16 16:23:58.000000000 +0200
+++ gcc/flow.c 2005-08-22 16:32:31.000000000 +0200
@@ -104,7 +104,7 @@ Software Foundation, 51 Franklin Street,
life_analysis fills in certain vectors containing information about
register usage: REG_N_REFS, REG_N_DEATHS, REG_N_SETS, REG_LIVE_LENGTH,
- REG_N_CALLS_CROSSED and REG_BASIC_BLOCK.
+ REG_N_CALLS_CROSSED, REG_N_THROWING_CALLS_CROSSED and REG_BASIC_BLOCK.
life_analysis sets current_function_sp_is_unchanging if the function
doesn't modify the stack pointer. */
@@ -1589,6 +1589,7 @@ allocate_reg_life_data (void)
REG_N_REFS (i) = 0;
REG_N_DEATHS (i) = 0;
REG_N_CALLS_CROSSED (i) = 0;
+ REG_N_THROWING_CALLS_CROSSED (i) = 0;
REG_LIVE_LENGTH (i) = 0;
REG_FREQ (i) = 0;
REG_BASIC_BLOCK (i) = REG_BLOCK_UNKNOWN;
@@ -1820,6 +1821,9 @@ propagate_one_insn (struct propagate_blo
reg_set_iterator rsi;
EXECUTE_IF_SET_IN_REG_SET (pbi->reg_live, 0, i, rsi)
REG_N_CALLS_CROSSED (i)++;
+ if (can_throw_internal (insn))
+ EXECUTE_IF_SET_IN_REG_SET (pbi->reg_live, 0, i, rsi)
+ REG_N_THROWING_CALLS_CROSSED (i)++;
}
/* Record sets. Do this even for dead instructions, since they
@@ -3512,7 +3516,11 @@ attempt_auto_inc (struct propagate_block
that REGNO now crosses them. */
for (temp = insn; temp != incr; temp = NEXT_INSN (temp))
if (CALL_P (temp))
- REG_N_CALLS_CROSSED (regno)++;
+ {
+ REG_N_CALLS_CROSSED (regno)++;
+ if (can_throw_internal (temp))
+ REG_N_THROWING_CALLS_CROSSED (regno)++;
+ }
/* Invalidate alias info for Q since we just changed its value. */
clear_reg_alias_info (q);
--- gcc/testsuite/g++.dg/opt/pr23478.C.jj 2005-08-22 17:18:16.000000000 +0200
+++ gcc/testsuite/g++.dg/opt/pr23478.C 2005-08-22 17:19:23.000000000 +0200
@@ -0,0 +1,211 @@
+// PR rtl-optimization/23478
+// { dg-do run }
+// { dg-options "-O2" }
+
+extern "C" void abort ();
+bool tthrow;
+struct C3 { int i; };
+class C14 {};
+struct C7
+{
+ virtual ~C7 ();
+};
+
+C7::~C7 ()
+{
+ asm volatile ("" : : : "memory");
+}
+class C2 : public C7 {};
+
+template <class X> class C13
+{
+ bool ma;
+ X *mb;
+public:
+ explicit C13 (X *p = 0) throw () : ma (p != 0), mb (p) {}
+ ~C13 ();
+};
+
+template <class X>
+C13<X>::~C13 ()
+{
+ asm volatile ("" : : "r" (ma), "r" (mb) : "memory");
+}
+
+struct C1
+{
+ C1 (const C3 &, const C3 &, const C3 &, const C3 *&);
+};
+
+C1::C1 (const C3 &, const C3 &, const C3 &, const C3 *&)
+{
+ if (!tthrow)
+ throw 24;
+}
+
+struct C8
+{
+ struct C15 {};
+ typedef C15 *C9;
+ virtual void f1 (C2 &, long *, void *, C3 &, void *, bool) = 0;
+ virtual C13<C14> f3 () const = 0;
+ virtual ~C8 () {}
+};
+
+bool
+xx14 ()
+{
+ bool b = false;
+ if (tthrow)
+ throw 6;
+ asm volatile ("" : : "r" (&b) : "memory");
+ return b;
+}
+
+bool
+xx2 ()
+{
+ bool b = false;
+ if (tthrow)
+ throw 6;
+ asm volatile ("" : : "r" (&b) : "memory");
+ return b;
+}
+
+C13<C7>
+xx9 ()
+{
+ return C13<C7>();
+}
+
+C2 &
+xx10 ()
+{
+ static C2 c2;
+ return c2;
+}
+
+C3 &
+xx12 ()
+{
+ static C3 c3 = { 1 };
+ return c3;
+}
+
+const C3 &
+xx5 ()
+{
+ static const C3 c3 = { 2 };
+ return c3;
+}
+
+const C3 *&
+xx4 ()
+{
+ static const C3 *p;
+ if (tthrow)
+ throw 6;
+ return p;
+}
+
+long ll13;
+
+long
+xx13 ()
+{
+ long ret;
+ asm volatile ("" : "=r" (ret) : "r" (ll13));
+ return ret;
+}
+
+void
+xx15 (C3 &x, C13<C1> &y)
+{
+ asm volatile ("" : : "r" (&x), "r" (&y) : "memory");
+}
+
+long
+xx16 (const void *x)
+{
+ long ret;
+ asm volatile ("" : "=r" (ret) : "0" (1), "r" (x) : "memory");
+ return ret;
+}
+
+void
+xx1 (C13<C14> x)
+{
+ asm volatile ("" : : "r" (&x) : "memory");
+ if (tthrow)
+ throw 6;
+}
+
+void
+xx3 (const C7 *x)
+{
+ if (x)
+ abort ();
+}
+
+void
+xx7 ()
+{
+ asm volatile ("" : : : "memory");
+}
+
+struct C5
+{
+ C13<C7> f2 (C3 &v1, const void *v2, C8 *v6);
+ C7 *m2[2];
+ long m1[2];
+};
+
+C13<C7>
+C5::f2 (C3 &v1, const void *v2, C8 *v6)
+{
+ C13<C7> v13 = xx9 ();
+ C2 &v9 = xx10 ();
+ for (long i = 1; i < 2; i++)
+ xx3 (m2[i]);
+ const C3 &ld = xx5 ();
+ xx7 ();
+ if (xx2 ())
+ throw "";
+ xx4 ();
+ C3 &si = xx12 ();
+ for (long i = 0; i < xx16 (v2); ++i)
+ {
+ C13<C1> sk (new C1 (xx5 (), ld, xx5 (), xx4 ()));
+ xx15 (si, sk);
+ }
+ long v4 = xx13 ();
+ for (long i = v4 - 1; i >= 0; --i)
+ m1[i] = i;
+ bool v8 = xx2 ();
+ for (long i = 0; i < 2 && !xx14 (); i++)
+ {
+ v6[i].f1 (v9, 0, __null, v1, __null, v8);
+ if (v8)
+ xx1 (v6[i].f3 ());
+ }
+ return v13;
+}
+
+int
+main (void)
+{
+ C5 c5 = { { __null, __null }, { 0, 0 } };
+ bool seen = false;
+ try
+ {
+ c5.f2 (xx12 (), __null, __null);
+ }
+ catch (int n)
+ {
+ if (n != 24)
+ abort ();
+ seen = true;
+ }
+ if (!seen)
+ abort ();
+}
gcc4-pr23484.patch:
builtins.c | 22 ++--
testsuite/gcc.c-torture/execute/builtins/pr23484-chk-lib.c | 1
testsuite/gcc.c-torture/execute/builtins/pr23484-chk.c | 61 +++++++++++++
3 files changed, 75 insertions(+), 9 deletions(-)
--- NEW FILE gcc4-pr23484.patch ---
2005-08-19 Jakub Jelinek <jakub at redhat.com>
PR middle-end/23484
* builtins.c (fold_builtin_memory_chk, fold_builtin_stxcpy_chk,
fold_builtin_strncpy_chk, fold_builtin_snprintf_chk): If len is
not constant, but maxlen is, don't set len to maxlen, rather
set maxlen to len if len is a constant.
* gcc.c-torture/execute/builtins/pr23484-chk.c: New test.
* gcc.c-torture/execute/builtins/pr23484-chk-lib.c: New file.
--- gcc/builtins.c.jj 2005-08-16 16:23:55.000000000 +0200
+++ gcc/builtins.c 2005-08-19 22:24:21.000000000 +0200
@@ -9533,10 +9533,11 @@ fold_builtin_memory_chk (tree exp, tree
}
return 0;
}
- len = maxlen;
}
+ else
+ maxlen = len;
- if (tree_int_cst_lt (size, len))
+ if (tree_int_cst_lt (size, maxlen))
return 0;
}
@@ -9639,10 +9640,11 @@ fold_builtin_stxcpy_chk (tree exp, tree
return fold_convert (TREE_TYPE (exp),
build_function_call_expr (fn, arglist));
}
- len = maxlen;
}
-
- if (! tree_int_cst_lt (len, size))
+ else
+ maxlen = len;
+
+ if (! tree_int_cst_lt (maxlen, size))
return 0;
}
@@ -9688,10 +9690,11 @@ fold_builtin_strncpy_chk (tree exp, tree
if SIZE is >= MAXLEN, never convert to __ocs_fail (). */
if (maxlen == NULL_TREE || ! host_integerp (maxlen, 1))
return 0;
- len = maxlen;
}
+ else
+ maxlen = len;
- if (tree_int_cst_lt (size, len))
+ if (tree_int_cst_lt (size, maxlen))
return 0;
}
@@ -9959,10 +9962,11 @@ fold_builtin_snprintf_chk (tree arglist,
if SIZE is >= MAXLEN, never convert to __ocs_fail (). */
if (maxlen == NULL_TREE || ! host_integerp (maxlen, 1))
return 0;
- len = maxlen;
}
+ else
+ maxlen = len;
- if (tree_int_cst_lt (size, len))
+ if (tree_int_cst_lt (size, maxlen))
return 0;
}
--- gcc/testsuite/gcc.c-torture/execute/builtins/pr23484-chk.c.jj 2005-08-19 21:23:26.000000000 +0200
+++ gcc/testsuite/gcc.c-torture/execute/builtins/pr23484-chk.c 2005-08-19 22:22:25.000000000 +0200
@@ -0,0 +1,61 @@
+/* PR middle-end/23484 */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen (const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern void *mempcpy (void *, const void *, size_t);
+extern void *memmove (void *, const void *, size_t);
+extern int snprintf (char *, size_t, const char *, ...);
+extern int memcmp (const void *, const void *, size_t);
+
+#include "chk.h"
+
+static char data[8] = "ABCDEFG";
+
+int l1;
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ char buf[8];
+
+ /* All the checking calls in this routine have a maximum length, so
+ object size checking should be done at compile time if optimizing. */
+ chk_calls = 0;
+
+ memset (buf, 'I', sizeof (buf));
+ if (memcpy (buf, data, l1 ? sizeof (buf) : 4) != buf
+ || memcmp (buf, "ABCDIIII", 8))
+ abort ();
+
+ memset (buf, 'J', sizeof (buf));
+ if (mempcpy (buf, data, l1 ? sizeof (buf) : 4) != buf + 4
+ || memcmp (buf, "ABCDJJJJ", 8))
+ abort ();
+
+ memset (buf, 'K', sizeof (buf));
+ if (memmove (buf, data, l1 ? sizeof (buf) : 4) != buf
+ || memcmp (buf, "ABCDKKKK", 8))
+ abort ();
+
+ memset (buf, 'L', sizeof (buf));
+ if (snprintf (buf, l1 ? sizeof (buf) : 4, "%d", l1 + 65536) != 5
+ || memcmp (buf, "655\0LLLL", 8))
+ abort ();
+
+ if (chk_calls)
+ abort ();
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (l1) : "0" (l1));
+ test1 ();
+}
--- gcc/testsuite/gcc.c-torture/execute/builtins/pr23484-chk-lib.c.jj 2005-08-19 21:23:22.000000000 +0200
+++ gcc/testsuite/gcc.c-torture/execute/builtins/pr23484-chk-lib.c 2005-06-27 14:17:38.000000000 +0200
@@ -0,0 +1 @@
+#include "lib/chk.c"
Index: .cvsignore
===================================================================
RCS file: /cvs/dist/rpms/gcc/devel/.cvsignore,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -r1.106 -r1.107
--- .cvsignore 17 Aug 2005 12:07:43 -0000 1.106
+++ .cvsignore 22 Aug 2005 21:29:04 -0000 1.107
@@ -1 +1 @@
-gcc-4.0.1-20050817.tar.bz2
+gcc-4.0.1-20050822.tar.bz2
gcc4-stack-protector.patch:
Makefile.in | 10 +-
c-cppbuiltin.c | 8 +
calls.c | 3
cfgexpand.c | 216 +++++++++++++++++++++++++++++++++++++++++++++-
common.opt | 12 ++
config.in | 6 +
config/i386/i386.c | 25 +++++
config/i386/i386.h | 1
config/i386/i386.md | 184 +++++++++++++++++++++++++++++----------
config/i386/linux.h | 5 +
config/i386/linux64.h | 6 +
config/rs6000/darwin.h | 14 +-
config/rs6000/linux.h | 5 +
config/rs6000/linux64.h | 6 +
config/rs6000/rs6000.c | 162 ++++++++++++++++++++++++++++++----
config/rs6000/rs6000.h | 93 +++++++++----------
config/rs6000/rs6000.md | 82 +++++++++++++++++
config/rs6000/sysv4.h | 5 -
config/s390/linux.h | 6 +
config/s390/s390-protos.h | 1
config/s390/s390.c | 63 +++++++++----
config/s390/s390.h | 12 +-
config/s390/s390.md | 83 +++++++++++++++++
config/sparc/linux.h | 5 +
config/sparc/linux64.h | 6 +
config/sparc/sparc.c | 10 +-
config/sparc/sparc.h | 1
config/sparc/sparc.md | 93 +++++++++++++++++++
configure | 48 ++++++++++
configure.ac | 39 ++++++++
doc/cpp.texi | 9 +
doc/invoke.texi | 26 +++++
doc/md.texi | 22 ++++
doc/tm.texi | 26 +++++
function.c | 104 ++++++++++++++++++++++
function.h | 4
gcc.c | 12 ++
params.def | 5 +
regrename.c | 6 +
target-def.h | 5 +
target.h | 11 ++
targhooks.c | 91 +++++++++++++++++++
targhooks.h | 4
toplev.c | 10 ++
tree.h | 2
45 files changed, 1385 insertions(+), 162 deletions(-)
Index: gcc4-stack-protector.patch
===================================================================
RCS file: /cvs/dist/rpms/gcc/devel/gcc4-stack-protector.patch,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- gcc4-stack-protector.patch 8 Aug 2005 14:48:45 -0000 1.4
+++ gcc4-stack-protector.patch 22 Aug 2005 21:29:04 -0000 1.5
@@ -1,3 +1,34 @@
+2005-08-13 James E Wilson <wilson at specifix.com>
+
+ * doc/cpp.texi (__SSP__, __SSP_ALL__): Document.
+ * doc/invoke.texi (-Wstack-protector, -fstack-protector,
+ -fstack-protector-all, --param ssp-buffer-size): Document.
+ (-Wvariadic-macros): Alphabetize.
+ (-fsched-stalled-insns-dep): Add missing 'f'.
+
+ * c-cppbuiltin.c (c_cpp_builtins): Add comment for flag_stack_protect
+ macros.
+
+2005-08-12 Andreas Krebbel <krebbel1 at de.ibm.com>
+ Jakub Jelinek <jakub at redhat.com>
+
+ * config/s390/linux.h (TARGET_THREAD_SSP_OFFSET): Define.
+ * config/s390/s390-protos.h (s390_get_thread_pointer): Prototype added.
+ * config/s390/s390.c (print_operand): New output modifier 'G' added.
+ (get_thread_pointer): Renamed to s390_get_thread_pointer.
+ * config/s390/s390.md (stack_protect_set, stack_protect_test): If
+ TARGET_THREAD_SSP_OFFSET is defined, change operands[1] to
+ (MEM:P (PLUS:P (tp, TARGET_THREAD_SSP_OFFSET))).
+ (UNSPEC_SP_SET, UNSPEC_SP_TEST): New constants.
+ ("stack_protect_set", "stack_protect_test"): New expanders.
+ ("stack_protect_setsi", "stack_protect_setdi", "stack_protect_testsi",
+ "stack_protect_testdi"): New insn definitions.
+
+2005-08-12 Kaz Kojima <kkojima at gcc.gnu.org>
+
+ * gcc.c (LINK_SSP_SPEC): Remove space before a trailing }.
+ (LINK_COMMAND_SPEC): Add space after %(link_ssp).
+
2005-08-03 Richard Henderson <rth at redhat.com>
PR 23221
@@ -254,6 +285,12 @@
* regrename.c (copy_value): Don't replace fixed or global
regs with older regs.
+2005-06-07 Adrian Straetling <straetling at de.ibm.com>
+
+ * config/s390/s390.c: (s390_compare_emitted): New global variable.
+ (s390_emit_compare): Do not emit comparison again after cas.
+ * config/s390/s390.h (s390_compare_emitted): Declare.
+
2005-04-14 Richard Henderson <rth at redhat.com>
* config/i386/i386.c (ix86_compare_emitted): New.
@@ -308,12 +345,14 @@
gtyp-gen.h: s-gtyp-gen ; @true
s-gtyp-gen: Makefile
--- gcc/c-cppbuiltin.c 25 Jun 2005 01:59:16 -0000 1.31
-+++ gcc/c-cppbuiltin.c 27 Jun 2005 07:40:56 -0000 1.32
-@@ -440,6 +440,12 @@ c_cpp_builtins (cpp_reader *pfile)
++++ gcc/c-cppbuiltin.c 13 Aug 2005 20:58:02 -0000 1.33
+@@ -440,6 +440,14 @@ c_cpp_builtins (cpp_reader *pfile)
if (targetm.handle_pragma_extern_prefix)
cpp_define (pfile, "__PRAGMA_EXTERN_PREFIX");
-+ /* Make the choice of the stack protector runtime visible to source code. */
++ /* Make the choice of the stack protector runtime visible to source code.
++ The macro names and values here were chosen for compatibility with an
++ earlier implementation, i.e. ProPolice. */
+ if (flag_stack_protect == 2)
+ cpp_define (pfile, "__SSP_ALL__=2");
+ else if (flag_stack_protect == 1)
@@ -1681,6 +1720,50 @@
#undef WORDS_BIG_ENDIAN
--- gcc/config/s390/s390.c 28 Jun 2005 14:25:13 -0000 1.239
+++ gcc/config/s390/s390.c 29 Jun 2005 15:21:39 -0000 1.240
+@@ -278,6 +278,10 @@ static int s390_sr_alias_set = 0;
+ emitted. */
+ rtx s390_compare_op0, s390_compare_op1;
+
++/* Save the result of a compare_and_swap until the branch or scc is
++ emitted. */
++rtx s390_compare_emitted = NULL_RTX;
++
+ /* Structure used to hold the components of a S/390 memory
+ address. A legitimate address on S/390 is of the general
+ form
+@@ -385,7 +389,6 @@ static const char *s390_branch_condition
+ static int check_mode (rtx, enum machine_mode *);
+ static int s390_short_displacement (rtx);
+ static int s390_decompose_address (rtx, struct s390_address *);
+-static rtx get_thread_pointer (void);
+ static rtx legitimize_tls_address (rtx, rtx);
+ static void print_shift_count_operand (FILE *, rtx);
+ static const char *get_some_local_dynamic_name (void);
+@@ -769,10 +772,21 @@ rtx
+ s390_emit_compare (enum rtx_code code, rtx op0, rtx op1)
+ {
+ enum machine_mode mode = s390_select_ccmode (code, op0, op1);
+- rtx cc = gen_rtx_REG (mode, CC_REGNUM);
++ rtx ret = NULL_RTX;
+
+- emit_insn (gen_rtx_SET (VOIDmode, cc, gen_rtx_COMPARE (mode, op0, op1)));
+- return gen_rtx_fmt_ee (code, VOIDmode, cc, const0_rtx);
++ /* Do not output a redundant compare instruction if a compare_and_swap
++ pattern already computed the result and the machine modes match. */
++ if (s390_compare_emitted && GET_MODE (s390_compare_emitted) == mode)
++ ret = gen_rtx_fmt_ee (code, VOIDmode, s390_compare_emitted, const0_rtx);
++ else
++ {
++ rtx cc = gen_rtx_REG (mode, CC_REGNUM);
++
++ emit_insn (gen_rtx_SET (VOIDmode, cc, gen_rtx_COMPARE (mode, op0, op1)));
++ ret = gen_rtx_fmt_ee (code, VOIDmode, cc, const0_rtx);
++ }
++ s390_compare_emitted = NULL_RTX;
++ return ret;
+ }
+
+ /* Emit a jump instruction to TARGET. If COND is NULL_RTX, emit an
@@ -1490,19 +1490,22 @@ s390_decompose_address (rtx addr, struct
/* Validate displacement. */
if (!disp)
@@ -1711,6 +1794,72 @@
if (!DISP_IN_RANGE (offset))
return false;
}
+@@ -3297,8 +3311,8 @@ legitimize_pic_address (rtx orig, rtx re
+
+ /* Load the thread pointer into a register. */
+
+-static rtx
+-get_thread_pointer (void)
++rtx
++s390_get_thread_pointer (void)
+ {
+ rtx tp = gen_reg_rtx (Pmode);
+
+@@ -3359,7 +3373,7 @@ legitimize_tls_address (rtx addr, rtx re
+ temp = gen_reg_rtx (Pmode);
+ emit_libcall_block (insn, temp, r2, new);
+
+- new = gen_rtx_PLUS (Pmode, get_thread_pointer (), temp);
++ new = gen_rtx_PLUS (Pmode, s390_get_thread_pointer (), temp);
+ if (reg != 0)
+ {
+ s390_load_address (reg, new);
+@@ -3382,7 +3396,7 @@ legitimize_tls_address (rtx addr, rtx re
+ temp = gen_reg_rtx (Pmode);
+ emit_libcall_block (insn, temp, r2, new);
+
+- new = gen_rtx_PLUS (Pmode, get_thread_pointer (), temp);
++ new = gen_rtx_PLUS (Pmode, s390_get_thread_pointer (), temp);
+ base = gen_reg_rtx (Pmode);
+ s390_load_address (base, new);
+
+@@ -3469,7 +3483,7 @@ legitimize_tls_address (rtx addr, rtx re
+ emit_insn (gen_rtx_SET (Pmode, temp, new));
+ }
+
+- new = gen_rtx_PLUS (Pmode, get_thread_pointer (), temp);
++ new = gen_rtx_PLUS (Pmode, s390_get_thread_pointer (), temp);
+ if (reg != 0)
+ {
+ s390_load_address (reg, new);
+@@ -3484,7 +3498,7 @@ legitimize_tls_address (rtx addr, rtx re
+ temp = gen_reg_rtx (Pmode);
+ emit_move_insn (temp, new);
+
+- new = gen_rtx_PLUS (Pmode, get_thread_pointer (), temp);
++ new = gen_rtx_PLUS (Pmode, s390_get_thread_pointer (), temp);
+ if (reg != 0)
+ {
+ s390_load_address (reg, new);
+@@ -4334,6 +4348,7 @@ print_operand_address (FILE *file, rtx a
+ 'C': print opcode suffix for branch condition.
+ 'D': print opcode suffix for inverse branch condition.
+ 'J': print tls_load/tls_gdcall/tls_ldcall suffix
++ 'G': print the size of the operand in bytes.
+ 'O': print only the displacement of a memory reference.
+ 'R': print only the base register of a memory reference.
+ 'S': print S-type memory reference (base+displacement).
+@@ -4380,6 +4395,10 @@ print_operand (FILE *file, rtx x, int co
+ abort ();
+ return;
+
++ case 'G':
++ fprintf (file, "%u", GET_MODE_SIZE (GET_MODE (x)));
++ return;
++
+ case 'O':
+ {
+ struct s390_address ad;
@@ -5865,7 +5868,8 @@ s390_frame_info (void)
return;
@@ -1732,8 +1881,8 @@
break;
case ARG_POINTER_REGNUM:
---- gcc/config/s390/s390.h 26 Jun 2005 05:18:46 -0000 1.142
-+++ gcc/config/s390/s390.h 29 Jun 2005 15:21:42 -0000 1.143
+--- gcc/config/s390/s390.h 26 Jun 2005 05:18:46 -0000
++++ gcc/config/s390/s390.h 29 Jun 2005 15:21:42 -0000
@@ -506,7 +506,7 @@ extern const enum reg_class regclass_map
are accessed by positive offsets, and function arguments are stored at
increasing addresses. */
@@ -1761,6 +1910,134 @@
/* Offset of first parameter from the argument pointer register value.
We have a fake argument pointer register that points directly to
+@@ -880,7 +880,7 @@ do { \
+ /* Define the information needed to generate branch and scc insns. This is
+ stored from the compare operation. Note that we can't use "rtx" here
+ since it hasn't been defined! */
+-extern struct rtx_def *s390_compare_op0, *s390_compare_op1;
++extern struct rtx_def *s390_compare_op0, *s390_compare_op1, *s390_compare_emitted;
+
+
+ /* Relative costs of operations. */
+--- gcc/config/s390/linux.h.jj 2004-10-17 20:09:46.000000000 +0200 1.39
++++ gcc/config/s390/linux.h 2005-08-22 15:53:01.000000000 +0200 1.40
+@@ -94,4 +94,10 @@ Software Foundation, 59 Temple Place - S
+
+ #define MD_UNWIND_SUPPORT "config/s390/linux-unwind.h"
+
++#ifdef TARGET_LIBC_PROVIDES_SSP
++/* s390 glibc provides __stack_chk_guard in 0x14(tp),
++ s390x glibc provides it at 0x28(tp). */
++#define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? 0x28 : 0x14)
++#endif
++
+ #endif
+--- gcc/config/s390/s390-protos.h.jj 2004-11-09 21:46:12.000000000 +0100 1.74
++++ gcc/config/s390/s390-protos.h 2005-08-22 15:53:01.000000000 +0200 1.75
+@@ -102,6 +102,7 @@ extern rtx s390_gen_rtx_const_DI (int, i
+ extern void s390_output_dwarf_dtprel (FILE*, int, rtx);
+ extern int s390_agen_dep_p (rtx, rtx);
+ extern rtx s390_load_got (void);
++extern rtx s390_get_thread_pointer (void);
+ extern void s390_emit_tpf_eh_return (rtx);
+
+ #endif /* RTX_CODE */
+--- gcc/config/s390/s390.md.jj 2005-08-17 10:24:30.000000000 +0200 1.187
++++ gcc/config/s390/s390.md 2005-08-22 15:53:01.000000000 +0200 1.188
+@@ -119,7 +119,11 @@
+ (UNSPEC_TLS_LOAD 512)
+
+ ; String Functions
+- (UNSPEC_SRST 600)
++ (UNSPEC_SRST 600)
++
++ ; Stack Smashing Protector
++ (UNSPEC_SP_SET 700)
++ (UNSPEC_SP_TEST 701)
+ ])
+
+ ;;
+@@ -8162,3 +8166,80 @@
+ DONE;
+ })
+
++;
++; Stack Protector Patterns
++;
++
++(define_expand "stack_protect_set"
++ [(set (match_operand 0 "memory_operand" "")
++ (match_operand 1 "memory_operand" ""))]
++ ""
++{
++#ifdef TARGET_THREAD_SSP_OFFSET
++ operands[1]
++ = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
++ GEN_INT (TARGET_THREAD_SSP_OFFSET)));
++#endif
++ if (TARGET_64BIT)
++ emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
++ else
++ emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
++
++ DONE;
++})
++
++(define_insn "stack_protect_setsi"
++ [(set (match_operand:SI 0 "memory_operand" "=Q")
++ (unspec:SI [(match_operand:SI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
++ ""
++ "mvc\t%O0(%G0,%R0),%S1"
++ [(set_attr "op_type" "SS")])
++
++(define_insn "stack_protect_setdi"
++ [(set (match_operand:DI 0 "memory_operand" "=Q")
++ (unspec:DI [(match_operand:DI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
++ "TARGET_64BIT"
++ "mvc\t%O0(%G0,%R0),%S1"
++ [(set_attr "op_type" "SS")])
++
++(define_expand "stack_protect_test"
++ [(set (reg:CC CC_REGNUM)
++ (compare (match_operand 0 "memory_operand" "")
++ (match_operand 1 "memory_operand" "")))
++ (match_operand 2 "" "")]
++ ""
++{
++#ifdef TARGET_THREAD_SSP_OFFSET
++ operands[1]
++ = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
++ GEN_INT (TARGET_THREAD_SSP_OFFSET)));
++#endif
++ s390_compare_op0 = operands[0];
++ s390_compare_op1 = operands[1];
++ s390_compare_emitted = gen_rtx_REG (CCZmode, CC_REGNUM);
++
++ if (TARGET_64BIT)
++ emit_insn (gen_stack_protect_testdi (operands[0], operands[1]));
++ else
++ emit_insn (gen_stack_protect_testsi (operands[0], operands[1]));
++
++ emit_jump_insn (gen_beq (operands[2]));
++
++ DONE;
++})
++
++(define_insn "stack_protect_testsi"
++ [(set (reg:CCZ CC_REGNUM)
++ (unspec:CCZ [(match_operand:SI 0 "memory_operand" "Q")
++ (match_operand:SI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
++ ""
++ "clc\t%O0(%G0,%R0),%S1"
++ [(set_attr "op_type" "SS")])
++
++(define_insn "stack_protect_testdi"
++ [(set (reg:CCZ CC_REGNUM)
++ (unspec:CCZ [(match_operand:DI 0 "memory_operand" "Q")
++ (match_operand:DI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
++ "TARGET_64BIT"
++ "clc\t%O0(%G0,%R0),%S1"
++ [(set_attr "op_type" "SS")])
--- gcc/config/sparc/linux.h 25 Jun 2005 01:22:29 -0000 1.71
+++ gcc/config/sparc/linux.h 6 Jul 2005 07:48:57 -0000 1.72
@@ -229,3 +229,8 @@ do { \
@@ -2042,8 +2319,8 @@
# Check whether --with-gc or --without-gc was given.
--- gcc/doc/md.texi 18 Jun 2005 15:21:19 -0000 1.136
-+++ gcc/doc/md.texi 27 Jun 2005 07:41:16 -0000 1.137
-@@ -4094,6 +4094,30 @@ released only after all previous memory
++++ gcc/doc/md.texi 30 Jun 2005 14:30:21 -0000 1.139
+@@ -4094,6 +4094,28 @@ released only after all previous memory
If this pattern is not defined, then a @code{memory_barrier} pattern
will be emitted, followed by a store of the value to the memory operand.
@@ -2063,37 +2340,15 @@
+
+This pattern, if defined, compares a @code{Pmode} value from the
+memory in operand 1 with the memory in operand 0 without leaving the
-+value in a register afterward. Further, it initializes the data
-+structures in the target as if the normal @code{cmp at var{mode}}
-+pattern had been emitted. If the pattern does not @code{FAIL}, then
-+the rtl expanders will be invoking either the @code{beq} or @code{bne}
-+pattern to make use of the comparison.
-+
-+If this pattern is not defined, then a plain compare pattern is used.
-+
- @end table
-
- @end ifset
---- gcc/doc/md.texi 28 Jun 2005 19:55:55 -0000 1.138
-+++ gcc/doc/md.texi 30 Jun 2005 14:30:21 -0000 1.139
-@@ -4112,13 +4112,11 @@ If this pattern is not defined, then a p
-
- This pattern, if defined, compares a @code{Pmode} value from the
- memory in operand 1 with the memory in operand 0 without leaving the
--value in a register afterward. Further, it initializes the data
--structures in the target as if the normal @code{cmp at var{mode}}
--pattern had been emitted. If the pattern does not @code{FAIL}, then
--the rtl expanders will be invoking either the @code{beq} or @code{bne}
--pattern to make use of the comparison.
+value in a register afterward and branches to operand 2 if the values
+weren't equal.
-
--If this pattern is not defined, then a plain compare pattern is used.
++
+If this pattern is not defined, then a plain compare pattern and
+conditional branch pattern is used.
-
++
@end table
+ @end ifset
--- gcc/doc/tm.texi 26 Jun 2005 05:18:53 -0000 1.434
+++ gcc/doc/tm.texi 27 Jun 2005 07:41:13 -0000 1.435
@@ -2716,6 +2716,7 @@ This describes the stack layout and call
@@ -2136,6 +2391,98 @@
@node Varargs
@section Implementing the Varargs Macros
@cindex varargs implementation
+--- gcc/doc/cpp.texi 12 May 2005 18:31:38 -0000 1.83
++++ gcc/doc/cpp.texi 13 Aug 2005 20:52:01 -0000 1.84
+@@ -2117,6 +2117,15 @@ macro to determine which runtime (NeXT o
+ These macros are defined, with value 1, if (and only if) the compilation
+ is for a target where @code{long int} and pointer both use 64-bits and
+ @code{int} uses 32-bit.
++
++ at item __SSP__
++This macro is defined, with value 1, when @option{-fstack-protector} is in
++use.
++
++ at item __SSP_ALL__
++This macro is defined, with value 2, when @option{-fstack-protector-all} is
++in use.
++
+ @end table
+
+ @node System-specific Predefined Macros
+--- gcc/doc/invoke.texi 12 Aug 2005 20:02:27 -0000 1.667
++++ gcc/doc/invoke.texi 13 Aug 2005 20:51:58 -0000 1.668
+@@ -229,13 +229,13 @@ Objective-C and Objective-C++ Dialects}.
+ -Wno-multichar -Wnonnull -Wpacked -Wpadded @gol
+ -Wparentheses -Wpointer-arith -Wredundant-decls @gol
+ -Wreturn-type -Wsequence-point -Wshadow @gol
+--Wsign-compare -Wstrict-aliasing -Wstrict-aliasing=2 @gol
+--Wswitch -Wswitch-default -Wswitch-enum @gol
++-Wsign-compare -Wstack-protector -Wstrict-aliasing @gol
++-Wstrict-aliasing=2 -Wswitch -Wswitch-default -Wswitch-enum @gol
+ -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized @gol
+ -Wunknown-pragmas -Wunreachable-code @gol
+ -Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol
+--Wunused-value -Wunused-variable -Wwrite-strings @gol
+--Wvariadic-macros}
++-Wunused-value -Wunused-variable -Wvariadic-macros @gol
++-Wwrite-strings}
+
+ @item C-only Warning Options
+ @gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
+@@ -309,10 +309,11 @@ Objective-C and Objective-C++ Dialects}.
+ -frounding-math -fschedule-insns -fschedule-insns2 @gol
+ -fno-sched-interblock -fno-sched-spec -fsched-spec-load @gol
+ -fsched-spec-load-dangerous @gol
+--fsched-stalled-insns=@var{n} -sched-stalled-insns-dep=@var{n} @gol
++-fsched-stalled-insns=@var{n} -fsched-stalled-insns-dep=@var{n} @gol
+ -fsched2-use-superblocks @gol
+ -fsched2-use-traces -freschedule-modulo-scheduled-loops @gol
+ -fsignaling-nans -fsingle-precision-constant -fspeculative-prefetching @gol
++-fstack-protector -fstack-protector-all @gol
+ -fstrength-reduce -fstrict-aliasing -ftracer -fthread-jumps @gol
+ -funroll-all-loops -funroll-loops -fpeel-loops @gol
+ -fsplit-ivs-in-unroller -funswitch-loops @gol
+@@ -3181,6 +3182,11 @@ This option is only supported for C and
+ @item -Werror
+ @opindex Werror
+ Make all warnings into errors.
++
++ at item -Wstack-protector
++This option is only active when @option{-fstack-protector} is active. It
++warns about functions that will not be protected against stack smashing.
++
+ @end table
+
+ @node Debugging Options
+@@ -5372,6 +5378,17 @@ threading.
+ When performing branch target register load optimization, don't reuse
+ branch target registers in within any basic block.
+
++ at item -fstack-protector
++Emit extra code to check for buffer overflows, such as stack smashing
++attacks. This is done by adding a guard variable to functions with
++vulnerable objects. This includes functions that call alloca, and
++functions with buffers larger than 8 bytes. The guards are initialized
++when a function is entered and then checked when the function exits.
++If a guard check fails, an error message is printed and the program exits.
++
++ at item -fstack-protector-all
++Like @option{-fstack-protector} except that all functions are protected.
++
+ @item --param @var{name}=@var{value}
+ @opindex param
+ In some places, GCC uses various constants to control the amount of
+@@ -5718,6 +5735,10 @@ Small integer constants can use a shared
+ compiler's memory usage and increasing its speed. This sets the maximum
+ value of a shared integer constant's. The default value is 256.
+
++ at item ssp-buffer-size
++The minimum size of buffers (i.e. arrays) that will receive stack smashing
++protection when @option{-fstack-protection} is used.
++
+ @end table
+ @end table
+
--- gcc/function.c 26 Jun 2005 05:18:16 -0000
+++ gcc/function.c 27 Jun 2005 07:40:48 -0000
@@ -61,6 +61,8 @@ Software Foundation, 59 Temple Place - S
@@ -2283,8 +2630,8 @@
/* Collected bit flags. */
/* Nonzero if function being compiled needs to be given an address
---- gcc/gcc.c 25 Jun 2005 02:00:04 -0000 1.461
-+++ gcc/gcc.c 2 Jul 2005 08:51:54 -0000 1.462
+--- gcc/gcc.c 25 Jun 2005 02:00:04 -0000
++++ gcc/gcc.c 2 Jul 2005 08:51:54 -0000
@@ -680,6 +680,14 @@ proper position among the other output f
#define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G"
#endif
@@ -2293,7 +2640,7 @@
+#ifdef TARGET_LIBC_PROVIDES_SSP
+#define LINK_SSP_SPEC "%{fstack-protector:}"
+#else
-+#define LINK_SSP_SPEC "%{fstack-protector:-lssp_nonshared -lssp }"
++#define LINK_SSP_SPEC "%{fstack-protector:-lssp_nonshared -lssp}"
+#endif
+#endif
+
@@ -2305,7 +2652,7 @@
%{static:} %{L*} %(mfwrap) %(link_libgcc) %o %(mflib)\
%{fprofile-arcs|fprofile-generate:-lgcov}\
- %{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}}\
-+ %{!nostdlib:%{!nodefaultlibs:%(link_ssp)%(link_gcc_c_sequence)}}\
++ %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\
%{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}"
#endif
Index: gcc4.spec
===================================================================
RCS file: /cvs/dist/rpms/gcc/devel/gcc4.spec,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- gcc4.spec 17 Aug 2005 14:52:27 -0000 1.68
+++ gcc4.spec 22 Aug 2005 21:29:04 -0000 1.69
@@ -1,6 +1,6 @@
-%define DATE 20050817
+%define DATE 20050822
%define gcc_version 4.0.1
-%define gcc_release 9
+%define gcc_release 10
%define _unpackaged_files_terminate_build 0
%define multilib_64_archs sparc64 ppc64 s390x x86_64
%ifarch %{ix86} alpha ia64 x86_64 s390 sparc sparc64
@@ -98,17 +98,18 @@
Patch16: gcc4-libjava-ia64-backtrace.patch
Patch17: gcc4-stack-protector.patch
Patch18: gcc4-ia64-stack-protector.patch
-Patch19: gcc4-s390-stack-protector.patch
-Patch20: gcc4-pr22052.patch
-Patch21: gcc4-libffi-x86.patch
-Patch22: gcc4-ppc32-msecure-plt.patch
-Patch23: gcc4-pr17828-test.patch
-Patch24: gcc4-dwarf2-usefbreg.patch
-Patch25: gcc4-dwarf2-prefer-1elt-vartracking.patch
-Patch26: gcc4-dwarf2-pr20268.patch
-Patch27: gcc4-dwarf2-inline-details.patch
-Patch28: gcc4-pr21254.patch
-Patch29: gcc4-dv.patch
+Patch19: gcc4-pr22052.patch
+Patch20: gcc4-libffi-x86.patch
+Patch21: gcc4-ppc32-msecure-plt.patch
+Patch22: gcc4-pr17828-test.patch
+Patch23: gcc4-dwarf2-usefbreg.patch
+Patch24: gcc4-dwarf2-prefer-1elt-vartracking.patch
+Patch25: gcc4-dwarf2-pr20268.patch
+Patch26: gcc4-dwarf2-inline-details.patch
+Patch27: gcc4-dv.patch
+Patch28: gcc4-dwarf2-frame_base.patch
+Patch29: gcc4-pr23478.patch
+Patch30: gcc4-pr23484.patch
%define _gnu %{nil}
%ifarch sparc
@@ -436,17 +437,18 @@
%patch16 -p0 -b .libjava-ia64-backtrace~
%patch17 -p0 -b .stack-protector~
%patch18 -p0 -b .ia64-stack-protector~
-%patch19 -p0 -b .s390-stack-protector~
-%patch20 -p0 -b .pr22052~
-%patch21 -p0 -b .libffi-x86~
-%patch22 -p0 -b .ppc32-msecure-plt~
-%patch23 -p0 -b .pr17828-test~
-%patch24 -p0 -b .dwarf2-usefbreg~
-%patch25 -p0 -b .dwarf2-prefer-1elt-vartracking~
-%patch26 -p0 -b .dwarf2-pr20268~
-%patch27 -p0 -b .dwarf2-inline-details~
-#%patch28 -p0 -b .pr21254~
-%patch29 -p0 -b .dv~
+%patch19 -p0 -b .pr22052~
+%patch20 -p0 -b .libffi-x86~
+%patch21 -p0 -b .ppc32-msecure-plt~
+%patch22 -p0 -b .pr17828-test~
+%patch23 -p0 -b .dwarf2-usefbreg~
+%patch24 -p0 -b .dwarf2-prefer-1elt-vartracking~
+%patch25 -p0 -b .dwarf2-pr20268~
+%patch26 -p0 -b .dwarf2-inline-details~
+%patch27 -p0 -b .dv~
+%patch28 -p0 -b .dwarf2-frame_base~
+%patch29 -p0 -b .pr23478~
+%patch30 -p0 -b .pr23484~
perl -pi -e 's/4\.0\.2/4.0.1/' gcc/version.c
perl -pi -e 's/"%{gcc_version}"/"%{gcc_version} \(release\)"/' gcc/version.c
@@ -1484,6 +1486,18 @@
%endif
%changelog
+* Mon Aug 22 2005 Jakub Jelinek <jakub at redhat.com> 4.0.1-10
+- update from CVS
+ - PRs c++/22233, c++/23089, c/18715, c/21562, fortran/23065, java/17845,
+ java/21436, libfortran/15266, libgcj/21074, libgcj/21943,
+ middle-end/20624, rtl-optimization/21254
+- fix DW_AT_frame_base attribute computation and handling of locations based
+ on the frame base (Richard Henderson, #165514)
+- backport HEAD -fstack-protector fixes and documentation additions
+- fix __builtin_*_chk miscompilation (PR middle-end/23484)
+- avoid call used regs for pseudos that live across calls that may throw
+ (#166237, PR rtl-optimization/23478)
+
* Wed Aug 17 2005 Jakub Jelinek <jakub at redhat.com> 4.0.1-9
- update from CVS
- PRs c++/21799, c++/23219, c++/23266, c++/23337, c++/8271, fortran/21432,
Index: sources
===================================================================
RCS file: /cvs/dist/rpms/gcc/devel/sources,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- sources 17 Aug 2005 12:07:43 -0000 1.108
+++ sources 22 Aug 2005 21:29:04 -0000 1.109
@@ -1 +1 @@
-4a52e62261db6ba039ce1b863f4f191c gcc-4.0.1-20050817.tar.bz2
+b36a64c93e824672ec53e8878ab342ae gcc-4.0.1-20050822.tar.bz2
--- gcc4-pr21254.patch DELETED ---
--- gcc4-s390-stack-protector.patch DELETED ---
More information about the fedora-cvs-commits
mailing list