View | Details | Raw Unified | Return to bug 77728 | Differences between
and this patch

Collapse All | Expand All

(-)gcc/config/arm/arm.c.jj (-17 / +61 lines)
Lines 64-69 Link Here
64
#include "rtl-iter.h"
64
#include "rtl-iter.h"
65
#include "optabs-libfuncs.h"
65
#include "optabs-libfuncs.h"
66
#include "gimplify.h"
66
#include "gimplify.h"
67
#include "gimple.h"
67
68
68
/* This file should be included last.  */
69
/* This file should be included last.  */
69
#include "target-def.h"
70
#include "target-def.h"
Lines 81-87 struct four_ints Link Here
81
82
82
/* Forward function declarations.  */
83
/* Forward function declarations.  */
83
static bool arm_const_not_ok_for_debug_p (rtx);
84
static bool arm_const_not_ok_for_debug_p (rtx);
84
static bool arm_needs_doubleword_align (machine_mode, const_tree);
85
static int arm_needs_doubleword_align (machine_mode, const_tree);
85
static int arm_compute_static_chain_stack_bytes (void);
86
static int arm_compute_static_chain_stack_bytes (void);
86
static arm_stack_offsets *arm_get_frame_offsets (void);
87
static arm_stack_offsets *arm_get_frame_offsets (void);
87
static void arm_add_gc_roots (void);
88
static void arm_add_gc_roots (void);
Lines 6349-6356 aapcs_layout_arg (CUMULATIVE_ARGS *pcum, Link Here
6349
  /* C3 - For double-word aligned arguments, round the NCRN up to the
6350
  /* C3 - For double-word aligned arguments, round the NCRN up to the
6350
     next even number.  */
6351
     next even number.  */
6351
  ncrn = pcum->aapcs_ncrn;
6352
  ncrn = pcum->aapcs_ncrn;
6352
  if ((ncrn & 1) && arm_needs_doubleword_align (mode, type))
6353
  if (ncrn & 1)
6353
    ncrn++;
6354
    {
6355
      int res = arm_needs_doubleword_align (mode, type);
6356
      /* Only warn during RTL expansion of call stmts, otherwise we would
6357
	 warn e.g. during gimplification even on functions that will be
6358
	 always inlined, and we'd warn multiple times.  Don't warn when
6359
	 called in expand_function_start either, as we warn instead in
6360
	 arm_function_arg_boundary in that case.  */
6361
      if (res < 0 && warn_psabi && currently_expanding_gimple_stmt)
6362
	inform (input_location, "parameter passing for argument of type "
6363
		"%qT changed in GCC 7.1", type);
6364
      else if (res > 0)
6365
	ncrn++;
6366
    }
6354
6367
6355
  nregs = ARM_NUM_REGS2(mode, type);
6368
  nregs = ARM_NUM_REGS2(mode, type);
6356
6369
Lines 6455-6466 arm_init_cumulative_args (CUMULATIVE_ARG Link Here
6455
    }
6468
    }
6456
}
6469
}
6457
6470
6458
/* Return true if mode/type need doubleword alignment.  */
6471
/* Return 1 if double word alignment is required for argument passing.
6459
static bool
6472
   Return -1 if double word alignment used to be required for argument
6473
   passing before PR77728 ABI fix, but is not required anymore.
6474
   Return 0 if double word alignment is not required and wasn't requried
6475
   before either.  */
6476
static int
6460
arm_needs_doubleword_align (machine_mode mode, const_tree type)
6477
arm_needs_doubleword_align (machine_mode mode, const_tree type)
6461
{
6478
{
6462
  if (!type)
6479
  if (!type)
6463
    return PARM_BOUNDARY < GET_MODE_ALIGNMENT (mode);
6480
    return GET_MODE_ALIGNMENT (mode) > PARM_BOUNDARY;
6464
6481
6465
  /* Scalar and vector types: Use natural alignment, i.e. of base type.  */
6482
  /* Scalar and vector types: Use natural alignment, i.e. of base type.  */
6466
  if (!AGGREGATE_TYPE_P (type))
6483
  if (!AGGREGATE_TYPE_P (type))
Lines 6470-6481 arm_needs_doubleword_align (machine_mode Link Here
6470
  if (TREE_CODE (type) == ARRAY_TYPE)
6487
  if (TREE_CODE (type) == ARRAY_TYPE)
6471
    return TYPE_ALIGN (TREE_TYPE (type)) > PARM_BOUNDARY;
6488
    return TYPE_ALIGN (TREE_TYPE (type)) > PARM_BOUNDARY;
6472
6489
6490
  int ret = 0;
6473
  /* Record/aggregate types: Use greatest member alignment of any member.  */ 
6491
  /* Record/aggregate types: Use greatest member alignment of any member.  */ 
6474
  for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
6492
  for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
6475
    if (DECL_ALIGN (field) > PARM_BOUNDARY)
6493
    if (DECL_ALIGN (field) > PARM_BOUNDARY)
6476
      return true;
6494
      {
6495
	if (TREE_CODE (field) == FIELD_DECL)
6496
	  return 1;
6497
	else
6498
	  /* Before PR77728 fix, we were incorrectly considering also
6499
	     other aggregate fields, like VAR_DECLs, TYPE_DECLs etc.
6500
	     Make sure we can warn about that with -Wpsabi.  */
6501
	  ret = -1;
6502
      }
6477
6503
6478
  return false;
6504
  return ret;
6479
}
6505
}
6480
6506
6481
6507
Lines 6532-6541 arm_function_arg (cumulative_args_t pcum Link Here
6532
    }
6558
    }
6533
6559
6534
  /* Put doubleword aligned quantities in even register pairs.  */
6560
  /* Put doubleword aligned quantities in even register pairs.  */
6535
  if (pcum->nregs & 1
6561
  if ((pcum->nregs & 1) && ARM_DOUBLEWORD_ALIGN)
6536
      && ARM_DOUBLEWORD_ALIGN
6562
    {
6537
      && arm_needs_doubleword_align (mode, type))
6563
      int res = arm_needs_doubleword_align (mode, type);
6538
    pcum->nregs++;
6564
      if (res < 0 && warn_psabi)
6565
	inform (input_location, "parameter passing for argument of type "
6566
		"%qT changed in GCC 7.1", type);
6567
      else if (res > 0)
6568
	pcum->nregs++;
6569
    }
6539
6570
6540
  /* Only allow splitting an arg between regs and memory if all preceding
6571
  /* Only allow splitting an arg between regs and memory if all preceding
6541
     args were allocated to regs.  For args passed by reference we only count
6572
     args were allocated to regs.  For args passed by reference we only count
Lines 6554-6562 arm_function_arg (cumulative_args_t pcum Link Here
6554
static unsigned int
6585
static unsigned int
6555
arm_function_arg_boundary (machine_mode mode, const_tree type)
6586
arm_function_arg_boundary (machine_mode mode, const_tree type)
6556
{
6587
{
6557
  return (ARM_DOUBLEWORD_ALIGN && arm_needs_doubleword_align (mode, type)
6588
  if (!ARM_DOUBLEWORD_ALIGN)
6558
	  ? DOUBLEWORD_ALIGNMENT
6589
    return PARM_BOUNDARY;
6559
	  : PARM_BOUNDARY);
6590
6591
  int res = arm_needs_doubleword_align (mode, type);
6592
  if (res < 0 && warn_psabi)
6593
    inform (input_location, "parameter passing for argument of type %qT "
6594
	    "changed in GCC 7.1", type);
6595
6596
  return res > 0 ? DOUBLEWORD_ALIGNMENT : PARM_BOUNDARY;
6560
}
6597
}
6561
6598
6562
static int
6599
static int
Lines 26516-26523 arm_setup_incoming_varargs (cumulative_a Link Here
26516
  if (pcum->pcs_variant <= ARM_PCS_AAPCS_LOCAL)
26553
  if (pcum->pcs_variant <= ARM_PCS_AAPCS_LOCAL)
26517
    {
26554
    {
26518
      nregs = pcum->aapcs_ncrn;
26555
      nregs = pcum->aapcs_ncrn;
26519
      if ((nregs & 1) && arm_needs_doubleword_align (mode, type))
26556
      if (nregs & 1)
26520
	nregs++;
26557
	{
26558
	  int res = arm_needs_doubleword_align (mode, type);
26559
	  if (res < 0 && warn_psabi)
26560
	    inform (input_location, "parameter passing for argument of "
26561
		    "type %qT changed in GCC 7.1", type);
26562
	  else if (res > 0)
26563
	    nregs++;
26564
	}
26521
    }
26565
    }
26522
  else
26566
  else
26523
    nregs = pcum->nregs;
26567
    nregs = pcum->nregs;
(-)gcc/testsuite/g++.dg/abi/pr77728-1.C.jj (+171 lines)
Line 0 Link Here
1
// { dg-do compile { target arm_eabi } }
2
// { dg-options "-Wpsabi" }
3
4
#include <stdarg.h>
5
6
template <int N>
7
struct A { double p; };
8
9
A<0> v;
10
11
template <int N>
12
struct B
13
{
14
  typedef A<N> T;
15
  int i, j;
16
};
17
18
struct C : public B<0> {};
19
struct D {};
20
struct E : public D, C {};
21
struct F : public B<1> {};
22
struct G : public F { static double y; };
23
struct H : public G {};
24
struct I : public D { long long z; };
25
struct J : public D { static double z; int i, j; };
26
27
template <int N>
28
struct K : public D { typedef A<N> T; int i, j; };
29
30
struct L { static double h; int i, j; };
31
32
int
33
fn1 (int a, B<0> b)	// { dg-message "note: parameter passing for argument of type \[^\n\r]* changed in GCC 7\.1" }
34
{
35
  return a + b.i;
36
}
37
38
int
39
fn2 (int a, B<1> b)
40
{
41
  return a + b.i;
42
}
43
44
int
45
fn3 (int a, L b)	// { dg-message "note: parameter passing for argument of type \[^\n\r]* changed in GCC 7\.1" }
46
{
47
  return a + b.i;
48
}
49
50
int
51
fn4 (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, B<0> n, ...)
52
// { dg-message "note: parameter passing for argument of type \[^\n\r]* changed in GCC 7\.1" "" { target *-*-* } .-1 }
53
{
54
  va_list ap;
55
  va_start (ap, n);
56
  int x = va_arg (ap, int);
57
  va_end (ap);
58
  return x;
59
}
60
61
int
62
fn5 (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, B<1> n, ...)
63
{
64
  va_list ap;
65
  va_start (ap, n);
66
  int x = va_arg (ap, int);
67
  va_end (ap);
68
  return x;
69
}
70
71
int
72
fn6 (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, C n, ...)
73
{
74
  va_list ap;
75
  va_start (ap, n);
76
  int x = va_arg (ap, int);
77
  va_end (ap);
78
  return x;
79
}
80
81
int
82
fn7 (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, E n, ...)
83
{
84
  va_list ap;
85
  va_start (ap, n);
86
  int x = va_arg (ap, int);
87
  va_end (ap);
88
  return x;
89
}
90
91
int
92
fn8 (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, H n, ...)
93
{
94
  va_list ap;
95
  va_start (ap, n);
96
  int x = va_arg (ap, int);
97
  va_end (ap);
98
  return x;
99
}
100
101
int
102
fn9 (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, I n, ...)
103
{
104
  va_list ap;
105
  va_start (ap, n);
106
  int x = va_arg (ap, int);
107
  va_end (ap);
108
  return x;
109
}
110
111
int
112
fn10 (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, J n, ...)
113
// { dg-message "note: parameter passing for argument of type \[^\n\r]* changed in GCC 7\.1" "" { target *-*-* } .-1 }
114
{
115
  va_list ap;
116
  va_start (ap, n);
117
  int x = va_arg (ap, int);
118
  va_end (ap);
119
  return x;
120
}
121
122
int
123
fn11 (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, K<0> n, ...)
124
// { dg-message "note: parameter passing for argument of type \[^\n\r]* changed in GCC 7\.1" "" { target *-*-* } .-1 }
125
{
126
  va_list ap;
127
  va_start (ap, n);
128
  int x = va_arg (ap, int);
129
  va_end (ap);
130
  return x;
131
}
132
133
int
134
fn12 (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, K<2> n, ...)
135
{
136
  va_list ap;
137
  va_start (ap, n);
138
  int x = va_arg (ap, int);
139
  va_end (ap);
140
  return x;
141
}
142
143
void
144
test ()
145
{
146
  static B<0> b0;
147
  static B<1> b1;
148
  static L l;
149
  static C c;
150
  static E e;
151
  static H h;
152
  static I i;
153
  static J j;
154
  static K<0> k0;
155
  static K<2> k2;
156
  fn1 (1, b0);	// { dg-message "note: parameter passing for argument of type \[^\n\r]* changed in GCC 7\.1" }
157
  fn2 (1, b1);
158
  fn3 (1, l);	// { dg-message "note: parameter passing for argument of type \[^\n\r]* changed in GCC 7\.1" }
159
  fn4 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, b0, 1, 2, 3, 4);
160
  // { dg-message "note: parameter passing for argument of type \[^\n\r]* changed in GCC 7\.1" "" { target *-*-* } .-1 }
161
  fn5 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, b1, 1, 2, 3, 4);
162
  fn6 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, c, 1, 2, 3, 4);
163
  fn7 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, e, 1, 2, 3, 4);
164
  fn8 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, h, 1, 2, 3, 4);
165
  fn9 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, i, 1, 2, 3, 4);
166
  fn10 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, j, 1, 2, 3, 4);
167
  // { dg-message "note: parameter passing for argument of type \[^\n\r]* changed in GCC 7\.1" "" { target *-*-* } .-1 }
168
  fn11 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, k0, 1, 2, 3, 4);
169
  // { dg-message "note: parameter passing for argument of type \[^\n\r]* changed in GCC 7\.1" "" { target *-*-* } .-1 }
170
  fn12 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, k2, 1, 2, 3, 4);
171
}

Return to bug 77728