summaryrefslogtreecommitdiff
path: root/packages/gcc/gcc-4.3.1/fedora/gcc43-pr33763.patch
blob: 9e9c90d271a656b1032646b0a20e50f95f0b8079 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
2007-11-06  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/33763
	* gcc.dg/pr33763.c: New test.
	* g++.dg/opt/inline13.C: New test.

2007-11-06  Jan Hubicka  <jh@suse.cz>

	PR tree-optimization/33763
	* tree-inline.c (expand_call_inline): Silently ignore always_inline
	attribute for redefined extern inline functions.

--- gcc/tree-inline.c.jj	2007-11-06 09:29:04.000000000 +0100
+++ gcc/tree-inline.c	2007-11-06 16:19:12.000000000 +0100
@@ -2582,6 +2582,12 @@ expand_call_inline (basic_block bb, tree
   if (!cgraph_inline_p (cg_edge, &reason))
     {
       if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn))
+	/* For extern inline functions that get redefined we always
+	   silently ignored alway_inline flag. Better behaviour would
+	   be to be able to keep both bodies and use extern inline body
+	   for inlining, but we can't do that because frontends overwrite
+	   the body.  */
+	  && !cg_edge->callee->local.redefined_extern_inline
 	  /* Avoid warnings during early inline pass. */
 	  && (!flag_unit_at_a_time || cgraph_global_info_ready))
 	{
--- gcc/testsuite/gcc.dg/pr33763.c.jj	2007-11-06 16:19:12.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr33763.c	2007-11-06 16:19:12.000000000 +0100
@@ -0,0 +1,60 @@
+/* PR tree-optimization/33763 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+typedef struct
+{
+  void *a;
+  void *b;
+} T;
+extern void *foo (const char *, const char *);
+extern void *bar (void *, const char *, T);
+extern int baz (const char *, int);
+
+extern inline __attribute__ ((always_inline, gnu_inline)) int
+baz (const char *x, int y)
+{
+  return 2;
+}
+
+int
+baz (const char *x, int y)
+{
+  return 1;
+}
+
+int xa, xb;
+
+static void *
+inl (const char *x, const char *y)
+{
+  T t = { &xa, &xb };
+  int *f = (int *) __builtin_malloc (sizeof (int));
+  const char *z;
+  int o = 0;
+  void *r = 0;
+
+  for (z = y; *z; z++)
+    {
+      if (*z == 'r')
+	o |= 1;
+      if (*z == 'w')
+	o |= 2;
+    }
+  if (o == 1)
+    *f = baz (x, 0);
+  if (o == 2)
+    *f = baz (x, 1);
+  if (o == 3)
+    *f = baz (x, 2);
+
+  if (o && *f > 0)
+    r = bar (f, "w", t);
+  return r;
+}
+
+void *
+foo (const char *x, const char *y)
+{
+  return inl (x, y);
+}
--- gcc/testsuite/g++.dg/opt/inline13.C.jj	2007-11-06 16:20:20.000000000 +0100
+++ gcc/testsuite/g++.dg/opt/inline13.C	2007-11-06 16:21:30.000000000 +0100
@@ -0,0 +1,60 @@
+// PR tree-optimization/33763
+// { dg-do compile }
+// { dg-options "-O2" }
+
+typedef struct
+{
+  void *a;
+  void *b;
+} T;
+extern void *foo (const char *, const char *);
+extern void *bar (void *, const char *, T);
+extern int baz (const char *, int);
+
+extern inline __attribute__ ((always_inline, gnu_inline)) int
+baz (const char *x, int y)
+{
+  return 2;
+}
+
+int
+baz (const char *x, int y)
+{
+  return 1;
+}
+
+int xa, xb;
+
+static void *
+inl (const char *x, const char *y)
+{
+  T t = { &xa, &xb };
+  int *f = (int *) __builtin_malloc (sizeof (int));
+  const char *z;
+  int o = 0;
+  void *r = 0;
+
+  for (z = y; *z; z++)
+    {
+      if (*z == 'r')
+	o |= 1;
+      if (*z == 'w')
+	o |= 2;
+    }
+  if (o == 1)
+    *f = baz (x, 0);
+  if (o == 2)
+    *f = baz (x, 1);
+  if (o == 3)
+    *f = baz (x, 2);
+
+  if (o && *f > 0)
+    r = bar (f, "w", t);
+  return r;
+}
+
+void *
+foo (const char *x, const char *y)
+{
+  return inl (x, y);
+}