Mercurial > hg > CbC > CbC_gcc
comparison gcc/gimple-ssa-isolate-paths.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Detect paths through the CFG which can never be executed in a conforming | 1 /* Detect paths through the CFG which can never be executed in a conforming |
2 program and isolate them. | 2 program and isolate them. |
3 | 3 |
4 Copyright (C) 2013-2017 Free Software Foundation, Inc. | 4 Copyright (C) 2013-2018 Free Software Foundation, Inc. |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
8 GCC is free software; you can redistribute it and/or modify | 8 GCC is free software; you can redistribute it and/or modify |
9 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
136 { | 136 { |
137 gimple_stmt_iterator si, si2; | 137 gimple_stmt_iterator si, si2; |
138 edge_iterator ei; | 138 edge_iterator ei; |
139 edge e2; | 139 edge e2; |
140 bool impossible = true; | 140 bool impossible = true; |
141 profile_count count = e->count (); | |
141 | 142 |
142 for (si = gsi_start_bb (bb); gsi_stmt (si) != stmt; gsi_next (&si)) | 143 for (si = gsi_start_bb (bb); gsi_stmt (si) != stmt; gsi_next (&si)) |
143 if (stmt_can_terminate_bb_p (gsi_stmt (si))) | 144 if (stmt_can_terminate_bb_p (gsi_stmt (si))) |
144 { | 145 { |
145 impossible = false; | 146 impossible = false; |
152 trap. Removing the outgoing edges is both an optimization and ensures | 153 trap. Removing the outgoing edges is both an optimization and ensures |
153 we don't need to do any PHI node updates. */ | 154 we don't need to do any PHI node updates. */ |
154 if (!duplicate) | 155 if (!duplicate) |
155 { | 156 { |
156 duplicate = duplicate_block (bb, NULL, NULL); | 157 duplicate = duplicate_block (bb, NULL, NULL); |
157 bb->frequency = 0; | 158 duplicate->count = profile_count::zero (); |
158 bb->count = profile_count::zero (); | |
159 if (!ret_zero) | 159 if (!ret_zero) |
160 for (ei = ei_start (duplicate->succs); (e2 = ei_safe_edge (ei)); ) | 160 for (ei = ei_start (duplicate->succs); (e2 = ei_safe_edge (ei)); ) |
161 remove_edge (e2); | 161 remove_edge (e2); |
162 } | 162 } |
163 bb->count -= count; | |
163 | 164 |
164 /* Complete the isolation step by redirecting E to reach DUPLICATE. */ | 165 /* Complete the isolation step by redirecting E to reach DUPLICATE. */ |
165 e2 = redirect_edge_and_branch (e, duplicate); | 166 e2 = redirect_edge_and_branch (e, duplicate); |
166 if (e2) | 167 if (e2) |
167 { | 168 { |
168 flush_pending_stmts (e2); | 169 flush_pending_stmts (e2); |
169 | 170 |
170 /* Update profile only when redirection is really processed. */ | 171 /* Update profile only when redirection is really processed. */ |
171 bb->frequency += EDGE_FREQUENCY (e); | 172 bb->count += e->count (); |
172 } | 173 } |
173 | 174 |
174 /* There may be more than one statement in DUPLICATE which exhibits | 175 /* There may be more than one statement in DUPLICATE which exhibits |
175 undefined behavior. Ultimately we want the first such statement in | 176 undefined behavior. Ultimately we want the first such statement in |
176 DUPLCIATE so that we're able to delete as much code as possible. | 177 DUPLCIATE so that we're able to delete as much code as possible. |
418 continue; | 419 continue; |
419 | 420 |
420 if (gimple_return_retval (return_stmt) != lhs) | 421 if (gimple_return_retval (return_stmt) != lhs) |
421 continue; | 422 continue; |
422 | 423 |
423 if (warning_at (gimple_location (use_stmt), | 424 { |
424 OPT_Wreturn_local_addr, | 425 auto_diagnostic_group d; |
425 "function may return address " | 426 if (warning_at (gimple_location (use_stmt), |
426 "of local variable")) | 427 OPT_Wreturn_local_addr, |
427 inform (DECL_SOURCE_LOCATION(valbase), | 428 "function may return address " |
428 "declared here"); | 429 "of local variable")) |
430 inform (DECL_SOURCE_LOCATION(valbase), | |
431 "declared here"); | |
432 } | |
429 | 433 |
430 if (gimple_bb (use_stmt) == bb) | 434 if (gimple_bb (use_stmt) == bb) |
431 { | 435 { |
432 duplicate = isolate_path (bb, duplicate, e, | 436 duplicate = isolate_path (bb, duplicate, e, |
433 use_stmt, lhs, true); | 437 use_stmt, lhs, true); |
540 if (always_executed) | 544 if (always_executed) |
541 msg = N_("function returns address of local variable"); | 545 msg = N_("function returns address of local variable"); |
542 else | 546 else |
543 msg = N_("function may return address of " | 547 msg = N_("function may return address of " |
544 "local variable"); | 548 "local variable"); |
545 | 549 { |
546 if (warning_at (gimple_location (stmt), | 550 auto_diagnostic_group d; |
547 OPT_Wreturn_local_addr, msg)) | 551 if (warning_at (gimple_location (stmt), |
548 inform (DECL_SOURCE_LOCATION(valbase), "declared here"); | 552 OPT_Wreturn_local_addr, msg)) |
553 inform (DECL_SOURCE_LOCATION(valbase), | |
554 "declared here"); | |
555 } | |
549 tree zero = build_zero_cst (TREE_TYPE (val)); | 556 tree zero = build_zero_cst (TREE_TYPE (val)); |
550 gimple_return_set_retval (return_stmt, zero); | 557 gimple_return_set_retval (return_stmt, zero); |
551 update_stmt (stmt); | 558 update_stmt (stmt); |
552 } | 559 } |
553 } | 560 } |