View | Details | Return to bug 40838 | Differences between
and this patch

Collapse All | Expand All

(-)gcc-4.4.1/gcc/cfgexpand.c (-4 / +19 lines)
Lines 1069-1074 expand_one_var (tree var, bool toplevel, Link Here
1069
      && TREE_CODE (var) == VAR_DECL)
1069
      && TREE_CODE (var) == VAR_DECL)
1070
    {
1070
    {
1071
      unsigned int align;
1071
      unsigned int align;
1072
      bool enforce;
1072
1073
1073
      /* Because we don't know if VAR will be in register or on stack,
1074
      /* Because we don't know if VAR will be in register or on stack,
1074
	 we conservatively assume it will be on stack even if VAR is
1075
	 we conservatively assume it will be on stack even if VAR is
Lines 1076-1086 expand_one_var (tree var, bool toplevel, Link Here
1076
	 variables, which won't be on stack, we collect alignment of
1077
	 variables, which won't be on stack, we collect alignment of
1077
	 type and ignore user specified alignment.  */
1078
	 type and ignore user specified alignment.  */
1078
      if (TREE_STATIC (var) || DECL_EXTERNAL (var))
1079
      if (TREE_STATIC (var) || DECL_EXTERNAL (var))
1079
	align = MINIMUM_ALIGNMENT (TREE_TYPE (var),
1080
	{
1080
				   TYPE_MODE (TREE_TYPE (var)),
1081
	  align = MINIMUM_ALIGNMENT (TREE_TYPE (var),
1081
				   TYPE_ALIGN (TREE_TYPE (var)));
1082
				     TYPE_MODE (TREE_TYPE (var)),
1083
				     TYPE_ALIGN (TREE_TYPE (var)));
1084
	  enforce = ENFORCE_STACK_ALIGNMENT (TREE_TYPE (var),
1085
	  				     TYPE_MODE (TREE_TYPE (var)),
1086
					     TYPE_ALIGN (TREE_TYPE (var)));
1087
	}
1082
      else
1088
      else
1083
	align = MINIMUM_ALIGNMENT (var, DECL_MODE (var), DECL_ALIGN (var));
1089
	{
1090
	  align = MINIMUM_ALIGNMENT (var, DECL_MODE (var), DECL_ALIGN (var));
1091
	  enforce = ENFORCE_STACK_ALIGNMENT (var, DECL_MODE (var),
1092
	  				     DECL_ALIGN (var));
1093
	}
1084
1094
1085
      if (crtl->stack_alignment_estimated < align)
1095
      if (crtl->stack_alignment_estimated < align)
1086
        {
1096
        {
Lines 1089-1094 expand_one_var (tree var, bool toplevel, Link Here
1089
          gcc_assert(!crtl->stack_realign_processed);
1099
          gcc_assert(!crtl->stack_realign_processed);
1090
	  crtl->stack_alignment_estimated = align;
1100
	  crtl->stack_alignment_estimated = align;
1091
	}
1101
	}
1102
      if (enforce)
1103
	crtl->enforced_stack_alignment = true;
1092
    }
1104
    }
1093
1105
1094
  if (TREE_CODE (var) != VAR_DECL)
1106
  if (TREE_CODE (var) != VAR_DECL)
Lines 2246-2251 expand_stack_alignment (void) Link Here
2246
2258
2247
  crtl->stack_realign_needed
2259
  crtl->stack_realign_needed
2248
    = INCOMING_STACK_BOUNDARY < crtl->stack_alignment_estimated;
2260
    = INCOMING_STACK_BOUNDARY < crtl->stack_alignment_estimated;
2261
  if (crtl->enforced_stack_alignment)
2262
    crtl->stack_realign_needed = true;
2249
  crtl->stack_realign_tried = crtl->stack_realign_needed;
2263
  crtl->stack_realign_tried = crtl->stack_realign_needed;
2250
2264
2251
  crtl->stack_realign_processed = true;
2265
  crtl->stack_realign_processed = true;
Lines 2317-2322 gimple_expand_cfg (void) Link Here
2317
  crtl->max_used_stack_slot_alignment = STACK_BOUNDARY;
2331
  crtl->max_used_stack_slot_alignment = STACK_BOUNDARY;
2318
  crtl->stack_alignment_estimated = STACK_BOUNDARY;
2332
  crtl->stack_alignment_estimated = STACK_BOUNDARY;
2319
  crtl->preferred_stack_boundary = STACK_BOUNDARY;
2333
  crtl->preferred_stack_boundary = STACK_BOUNDARY;
2334
  crtl->enforced_stack_alignment = false;
2320
  cfun->cfg->max_jumptable_ents = 0;
2335
  cfun->cfg->max_jumptable_ents = 0;
2321
2336
2322
2337
(-)gcc-4.4.1/gcc/config/i386/i386-protos.h (+2 lines)
Lines 205-210 extern unsigned int ix86_local_alignment Link Here
205
					  unsigned int);
205
					  unsigned int);
206
extern unsigned int ix86_minimum_alignment (tree, enum machine_mode,
206
extern unsigned int ix86_minimum_alignment (tree, enum machine_mode,
207
					    unsigned int);
207
					    unsigned int);
208
extern bool ix86_enforce_stack_alignment (tree, enum machine_mode,
209
					  unsigned int);
208
extern int ix86_constant_alignment (tree, int);
210
extern int ix86_constant_alignment (tree, int);
209
extern tree ix86_handle_shared_attribute (tree *, tree, tree, int, bool *);
211
extern tree ix86_handle_shared_attribute (tree *, tree, tree, int, bool *);
210
extern tree ix86_handle_selectany_attribute (tree *, tree, tree, int, bool *);
212
extern tree ix86_handle_selectany_attribute (tree *, tree, tree, int, bool *);
(-)gcc-4.4.1/gcc/config/i386/i386.c (-1 / +27 lines)
Lines 8208-8214 ix86_finalize_stack_realign_flags (void) Link Here
8208
  unsigned int incoming_stack_boundary
8208
  unsigned int incoming_stack_boundary
8209
    = (crtl->parm_stack_boundary > ix86_incoming_stack_boundary
8209
    = (crtl->parm_stack_boundary > ix86_incoming_stack_boundary
8210
       ? crtl->parm_stack_boundary : ix86_incoming_stack_boundary);
8210
       ? crtl->parm_stack_boundary : ix86_incoming_stack_boundary);
8211
  unsigned int stack_realign = (incoming_stack_boundary
8211
  unsigned int stack_realign = ((crtl->enforced_stack_alignment
8212
				   ? MIN_STACK_BOUNDARY
8213
				   : incoming_stack_boundary)
8212
				< (current_function_is_leaf
8214
				< (current_function_is_leaf
8213
				   ? crtl->max_used_stack_slot_alignment
8215
				   ? crtl->max_used_stack_slot_alignment
8214
				   : crtl->stack_alignment_needed));
8216
				   : crtl->stack_alignment_needed));
Lines 19649-19654 ix86_minimum_alignment (tree exp, enum m Link Here
19649
19651
19650
  return align;
19652
  return align;
19651
}
19653
}
19654
19655
bool
19656
ix86_enforce_stack_alignment (tree exp __attribute__((unused)),
19657
			      enum machine_mode mode,
19658
			      unsigned int align)
19659
{
19660
	if (TARGET_64BIT)
19661
	  return false;
19662
19663
	if (mode == V4SFmode ||
19664
	    mode == V4SImode ||
19665
	    mode == V2DFmode ||
19666
	    mode == V16QImode ||
19667
	    mode == V8HImode ||
19668
	    mode == V2DImode)
19669
	  return true;
19670
19671
	/* assume that it is structure with some elementes vectorized ... */
19672
	if (mode == BLKmode && align >= 128)
19673
	  return true;
19674
19675
	return false;
19676
}
19677
19652
19678
19653
/* Emit RTL insns to initialize the variable parts of a trampoline.
19679
/* Emit RTL insns to initialize the variable parts of a trampoline.
19654
   FNADDR is an RTX for the address of the function's pure code.
19680
   FNADDR is an RTX for the address of the function's pure code.
(-)gcc-4.4.1/gcc/config/i386/i386.h (+3 lines)
Lines 819-824 enum target_cpu_default Link Here
819
#define MINIMUM_ALIGNMENT(EXP, MODE, ALIGN) \
819
#define MINIMUM_ALIGNMENT(EXP, MODE, ALIGN) \
820
  ix86_minimum_alignment (EXP, MODE, ALIGN)
820
  ix86_minimum_alignment (EXP, MODE, ALIGN)
821
821
822
#define ENFORCE_STACK_ALIGNMENT(EXP, MODE, ALIGN) \
823
  ix86_enforce_stack_alignment (EXP, MODE, ALIGN)
824
822
825
823
/* If defined, a C expression that gives the alignment boundary, in
826
/* If defined, a C expression that gives the alignment boundary, in
824
   bits, of an argument with the specified mode and type.  If it is
827
   bits, of an argument with the specified mode and type.  If it is
(-)gcc-4.4.1/gcc/defaults.h (+4 lines)
Lines 958-963 see the files COPYING3 and COPYING.RUNTI Link Here
958
#define MINIMUM_ALIGNMENT(EXP,MODE,ALIGN) (ALIGN)
958
#define MINIMUM_ALIGNMENT(EXP,MODE,ALIGN) (ALIGN)
959
#endif
959
#endif
960
960
961
#ifndef ENFORCE_STACK_ALIGNMENT
962
#define ENFORCE_STACK_ALIGNMENT(EXP,MODE,ALIGN) false
963
#endif
964
961
/* Alignment value for attribute ((aligned)).  */
965
/* Alignment value for attribute ((aligned)).  */
962
#ifndef ATTRIBUTE_ALIGNED_VALUE
966
#ifndef ATTRIBUTE_ALIGNED_VALUE
963
#define ATTRIBUTE_ALIGNED_VALUE BIGGEST_ALIGNMENT
967
#define ATTRIBUTE_ALIGNED_VALUE BIGGEST_ALIGNMENT
(-)gcc-4.4.1/gcc/emit-rtl.c (+2 lines)
Lines 873-878 gen_reg_rtx (enum machine_mode mode) Link Here
873
      unsigned int min_align = MINIMUM_ALIGNMENT (NULL, mode, align);
873
      unsigned int min_align = MINIMUM_ALIGNMENT (NULL, mode, align);
874
      if (crtl->stack_alignment_estimated < min_align)
874
      if (crtl->stack_alignment_estimated < min_align)
875
	crtl->stack_alignment_estimated = min_align;
875
	crtl->stack_alignment_estimated = min_align;
876
      if (ENFORCE_STACK_ALIGNMENT (NULL, mode, align))
877
	crtl->enforced_stack_alignment = true;
876
    }
878
    }
877
879
878
  if (generating_concat_p
880
  if (generating_concat_p
(-)gcc-4.4.1/gcc/function.c (-3 / +12 lines)
Lines 3149-3158 assign_parms (tree fndecl) Link Here
3149
						      data.passed_type);
3149
						      data.passed_type);
3150
	  align = MINIMUM_ALIGNMENT (data.passed_type, data.promoted_mode,
3150
	  align = MINIMUM_ALIGNMENT (data.passed_type, data.promoted_mode,
3151
				     align);
3151
				     align);
3152
	  if (ENFORCE_STACK_ALIGNMENT (data.passed_type, data.promoted_mode,
3153
	  			       align))
3154
	    crtl->enforced_stack_alignment = true;
3152
	  if (TYPE_ALIGN (data.nominal_type) > align)
3155
	  if (TYPE_ALIGN (data.nominal_type) > align)
3153
	    align = MINIMUM_ALIGNMENT (data.nominal_type,
3156
	    {
3154
				       TYPE_MODE (data.nominal_type),
3157
	      align = MINIMUM_ALIGNMENT (data.nominal_type,
3155
				       TYPE_ALIGN (data.nominal_type));
3158
					 TYPE_MODE (data.nominal_type),
3159
					 TYPE_ALIGN (data.nominal_type));
3160
	      if (ENFORCE_STACK_ALIGNMENT (data.nominal_type,
3161
	      				   TYPE_MODE (data.nominal_type),
3162
					   TYPE_ALIGN (data.nominal_type)))
3163
		crtl->enforced_stack_alignment = true;
3164
	    }
3156
	  if (crtl->stack_alignment_estimated < align)
3165
	  if (crtl->stack_alignment_estimated < align)
3157
	    {
3166
	    {
3158
	      gcc_assert (!crtl->stack_realign_processed);
3167
	      gcc_assert (!crtl->stack_realign_processed);
(-)gcc-4.4.1/gcc/function.h (+4 lines)
Lines 414-419 struct rtl_data GTY(()) Link Here
414
  /* When set, expand should optimize for speed.  */
414
  /* When set, expand should optimize for speed.  */
415
  bool maybe_hot_insn_p;
415
  bool maybe_hot_insn_p;
416
416
417
  /* The functions contains some insns that require aligned stack.
418
     So align the stack unconditionally.  */
419
  bool enforced_stack_alignment;
420
417
  /* Nonzero if function stack realignment is needed.  This flag may be
421
  /* Nonzero if function stack realignment is needed.  This flag may be
418
     set twice: before and after reload.  It is set before reload wrt
422
     set twice: before and after reload.  It is set before reload wrt
419
     stack alignment estimation before reload.  It will be changed after
423
     stack alignment estimation before reload.  It will be changed after

Return to bug 40838