diff options
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0400-PR-gcov-profile-49299.patch')
-rw-r--r-- | meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0400-PR-gcov-profile-49299.patch | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0400-PR-gcov-profile-49299.patch b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0400-PR-gcov-profile-49299.patch new file mode 100644 index 0000000000..ac84e6a823 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0400-PR-gcov-profile-49299.patch | |||
@@ -0,0 +1,158 @@ | |||
1 | From a9093bc0aa135388aec0930c07f021c85c39dd93 Mon Sep 17 00:00:00 2001 | ||
2 | From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | ||
3 | Date: Tue, 7 Jun 2011 09:53:17 +0000 | ||
4 | Subject: [PATCH] PR gcov-profile/49299 | ||
5 | * value-prof.c (gimple_ic): Don't assume icall has | ||
6 | a fallthru edge. | ||
7 | |||
8 | * gcc.dg/tree-prof/pr49299-1.c: New test. | ||
9 | * gcc.dg/tree-prof/pr49299-2.c: New test. | ||
10 | |||
11 | |||
12 | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@174739 138bc75d-0d04-0410-961f-82ee72b054a4 | ||
13 | |||
14 | index 629f79a..8ee5730 100644 | ||
15 | new file mode 100644 | ||
16 | index 0000000..dd45baf | ||
17 | --- /dev/null | ||
18 | +++ b/gcc/testsuite/gcc.dg/tree-prof/pr49299-1.c | ||
19 | @@ -0,0 +1,34 @@ | ||
20 | +/* { dg-options "-O2" } */ | ||
21 | + | ||
22 | +__attribute__((noreturn)) void (*fn) (void); | ||
23 | + | ||
24 | +volatile int v; | ||
25 | + | ||
26 | +__attribute__((noreturn)) void | ||
27 | +fn0 (void) | ||
28 | +{ | ||
29 | + __builtin_exit (0); | ||
30 | +} | ||
31 | + | ||
32 | +__attribute__((noreturn)) void | ||
33 | +fn1 (void) | ||
34 | +{ | ||
35 | + __builtin_exit (1); | ||
36 | +} | ||
37 | + | ||
38 | +__attribute__((noinline, noclone)) void | ||
39 | +setfn (__attribute__((noreturn)) void (*x) (void)) | ||
40 | +{ | ||
41 | + fn = x; | ||
42 | +} | ||
43 | + | ||
44 | +int | ||
45 | +main () | ||
46 | +{ | ||
47 | + int i; | ||
48 | + if (v < 1) | ||
49 | + setfn (fn0); | ||
50 | + else | ||
51 | + setfn (fn1); | ||
52 | + fn (); | ||
53 | +} | ||
54 | diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr49299-2.c b/gcc/testsuite/gcc.dg/tree-prof/pr49299-2.c | ||
55 | new file mode 100644 | ||
56 | index 0000000..220c8c8 | ||
57 | --- /dev/null | ||
58 | +++ b/gcc/testsuite/gcc.dg/tree-prof/pr49299-2.c | ||
59 | @@ -0,0 +1,34 @@ | ||
60 | +/* { dg-options "-O2" } */ | ||
61 | + | ||
62 | +void (*fn) (void); | ||
63 | + | ||
64 | +volatile int v; | ||
65 | + | ||
66 | +__attribute__((noreturn)) void | ||
67 | +fn0 (void) | ||
68 | +{ | ||
69 | + __builtin_exit (0); | ||
70 | +} | ||
71 | + | ||
72 | +void | ||
73 | +fn1 (void) | ||
74 | +{ | ||
75 | +} | ||
76 | + | ||
77 | +__attribute__((noinline, noclone)) void | ||
78 | +setfn (void (*x) (void)) | ||
79 | +{ | ||
80 | + fn = x; | ||
81 | +} | ||
82 | + | ||
83 | +int | ||
84 | +main () | ||
85 | +{ | ||
86 | + int i; | ||
87 | + if (v < 1) | ||
88 | + setfn (fn0); | ||
89 | + else | ||
90 | + setfn (fn1); | ||
91 | + fn (); | ||
92 | + return 0; | ||
93 | +} | ||
94 | diff --git a/gcc/value-prof.c b/gcc/value-prof.c | ||
95 | index 8491c77..da7c0e5 100644 | ||
96 | --- a/gcc/value-prof.c | ||
97 | +++ b/gcc/value-prof.c | ||
98 | @@ -1104,9 +1104,9 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call, | ||
99 | { | ||
100 | gimple dcall_stmt, load_stmt, cond_stmt; | ||
101 | tree tmp0, tmp1, tmpv, tmp; | ||
102 | - basic_block cond_bb, dcall_bb, icall_bb, join_bb; | ||
103 | + basic_block cond_bb, dcall_bb, icall_bb, join_bb = NULL; | ||
104 | tree optype = build_pointer_type (void_type_node); | ||
105 | - edge e_cd, e_ci, e_di, e_dj, e_ij; | ||
106 | + edge e_cd, e_ci, e_di, e_dj = NULL, e_ij; | ||
107 | gimple_stmt_iterator gsi; | ||
108 | int lp_nr; | ||
109 | |||
110 | @@ -1153,12 +1153,19 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call, | ||
111 | else | ||
112 | { | ||
113 | e_ij = find_fallthru_edge (icall_bb->succs); | ||
114 | - e_ij->probability = REG_BR_PROB_BASE; | ||
115 | - e_ij->count = all - count; | ||
116 | - e_ij = single_pred_edge (split_edge (e_ij)); | ||
117 | + /* The indirect call might be noreturn. */ | ||
118 | + if (e_ij != NULL) | ||
119 | + { | ||
120 | + e_ij->probability = REG_BR_PROB_BASE; | ||
121 | + e_ij->count = all - count; | ||
122 | + e_ij = single_pred_edge (split_edge (e_ij)); | ||
123 | + } | ||
124 | + } | ||
125 | + if (e_ij != NULL) | ||
126 | + { | ||
127 | + join_bb = e_ij->dest; | ||
128 | + join_bb->count = all; | ||
129 | } | ||
130 | - join_bb = e_ij->dest; | ||
131 | - join_bb->count = all; | ||
132 | |||
133 | e_cd->flags = (e_cd->flags & ~EDGE_FALLTHRU) | EDGE_TRUE_VALUE; | ||
134 | e_cd->probability = prob; | ||
135 | @@ -1170,12 +1177,15 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call, | ||
136 | |||
137 | remove_edge (e_di); | ||
138 | |||
139 | - e_dj = make_edge (dcall_bb, join_bb, EDGE_FALLTHRU); | ||
140 | - e_dj->probability = REG_BR_PROB_BASE; | ||
141 | - e_dj->count = count; | ||
142 | + if (e_ij != NULL) | ||
143 | + { | ||
144 | + e_dj = make_edge (dcall_bb, join_bb, EDGE_FALLTHRU); | ||
145 | + e_dj->probability = REG_BR_PROB_BASE; | ||
146 | + e_dj->count = count; | ||
147 | |||
148 | - e_ij->probability = REG_BR_PROB_BASE; | ||
149 | - e_ij->count = all - count; | ||
150 | + e_ij->probability = REG_BR_PROB_BASE; | ||
151 | + e_ij->count = all - count; | ||
152 | + } | ||
153 | |||
154 | /* Insert PHI node for the call result if necessary. */ | ||
155 | if (gimple_call_lhs (icall_stmt) | ||
156 | -- | ||
157 | 1.7.0.4 | ||
158 | |||