1 /* Function splitting pass
2 Copyright (C) 2010, 2011
3 Free Software Foundation, Inc.
4 Contributed by Jan Hubicka <jh@suse.cz>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 /* The purpose of this pass is to split function bodies to improve
23 inlining. I.e. for function of the form:
48 When func becomes inlinable and when cheap_test is often true, inlining func,
49 but not fund.part leads to performance improvement similar as inlining
50 original func while the code size growth is smaller.
52 The pass is organized in three stages:
53 1) Collect local info about basic block into BB_INFO structure and
54 compute function body estimated size and time.
55 2) Via DFS walk find all possible basic blocks where we can split
57 3) If split point is found, split at the specified BB by creating a clone
58 and updating function to call it.
60 The decisions what functions to split are in execute_split_functions
63 There are several possible future improvements for this pass including:
65 1) Splitting to break up large functions
66 2) Splitting to reduce stack frame usage
67 3) Allow split part of function to use values computed in the header part.
68 The values needs to be passed to split function, perhaps via same
69 interface as for nested functions or as argument.
70 4) Support for simple rematerialization. I.e. when split part use
71 value computed in header from function parameter in very cheap way, we
72 can just recompute it.
73 5) Support splitting of nested functions.
74 6) Support non-SSA arguments.
75 7) There is nothing preventing us from producing multiple parts of single function
76 when needed or splitting also the parts. */
80 #include "coretypes.h"
85 #include "tree-flow.h"
86 #include "tree-pass.h"
89 #include "diagnostic.h"
90 #include "tree-dump.h"
91 #include "tree-inline.h"
94 #include "gimple-pretty-print.h"
95 #include "ipa-inline.h"
97 /* Per basic block info. */
105 DEF_VEC_ALLOC_O(bb_info
,heap
);
107 static VEC(bb_info
, heap
) *bb_info_vec
;
109 /* Description of split point. */
113 /* Size of the partitions. */
114 unsigned int header_time
, header_size
, split_time
, split_size
;
116 /* SSA names that need to be passed into spit function. */
117 bitmap ssa_names_to_pass
;
119 /* Basic block where we split (that will become entry point of new function. */
120 basic_block entry_bb
;
122 /* Basic blocks we are splitting away. */
125 /* True when return value is computed on split part and thus it needs
127 bool split_part_set_retval
;
130 /* Best split point found. */
132 struct split_point best_split_point
;
134 static tree
find_retval (basic_block return_bb
);
136 /* Callback for walk_stmt_load_store_addr_ops. If T is non-SSA automatic
137 variable, check it if it is present in bitmap passed via DATA. */
140 test_nonssa_use (gimple stmt ATTRIBUTE_UNUSED
, tree t
, void *data
)
142 t
= get_base_address (t
);
144 if (!t
|| is_gimple_reg (t
))
147 if (TREE_CODE (t
) == PARM_DECL
148 || (TREE_CODE (t
) == VAR_DECL
149 && auto_var_in_fn_p (t
, current_function_decl
))
150 || TREE_CODE (t
) == RESULT_DECL
151 || TREE_CODE (t
) == LABEL_DECL
)
152 return bitmap_bit_p ((bitmap
)data
, DECL_UID (t
));
154 /* For DECL_BY_REFERENCE, the return value is actually a pointer. We want
155 to pretend that the value pointed to is actual result decl. */
156 if ((TREE_CODE (t
) == MEM_REF
|| INDIRECT_REF_P (t
))
157 && TREE_CODE (TREE_OPERAND (t
, 0)) == SSA_NAME
158 && TREE_CODE (SSA_NAME_VAR (TREE_OPERAND (t
, 0))) == RESULT_DECL
159 && DECL_BY_REFERENCE (DECL_RESULT (current_function_decl
)))
161 bitmap_bit_p ((bitmap
)data
,
162 DECL_UID (DECL_RESULT (current_function_decl
)));
167 /* Dump split point CURRENT. */
170 dump_split_point (FILE * file
, struct split_point
*current
)
173 "Split point at BB %i\n"
174 " header time: %i header size: %i\n"
175 " split time: %i split size: %i\n bbs: ",
176 current
->entry_bb
->index
, current
->header_time
,
177 current
->header_size
, current
->split_time
, current
->split_size
);
178 dump_bitmap (file
, current
->split_bbs
);
179 fprintf (file
, " SSA names to pass: ");
180 dump_bitmap (file
, current
->ssa_names_to_pass
);
183 /* Look for all BBs in header that might lead to the split part and verify
184 that they are not defining any non-SSA var used by the split part.
185 Parameters are the same as for consider_split. */
188 verify_non_ssa_vars (struct split_point
*current
, bitmap non_ssa_vars
,
189 basic_block return_bb
)
191 bitmap seen
= BITMAP_ALLOC (NULL
);
192 VEC (basic_block
,heap
) *worklist
= NULL
;
197 FOR_EACH_EDGE (e
, ei
, current
->entry_bb
->preds
)
198 if (e
->src
!= ENTRY_BLOCK_PTR
199 && !bitmap_bit_p (current
->split_bbs
, e
->src
->index
))
201 VEC_safe_push (basic_block
, heap
, worklist
, e
->src
);
202 bitmap_set_bit (seen
, e
->src
->index
);
205 while (!VEC_empty (basic_block
, worklist
))
207 gimple_stmt_iterator bsi
;
208 basic_block bb
= VEC_pop (basic_block
, worklist
);
210 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
211 if (e
->src
!= ENTRY_BLOCK_PTR
212 && bitmap_set_bit (seen
, e
->src
->index
))
214 gcc_checking_assert (!bitmap_bit_p (current
->split_bbs
,
216 VEC_safe_push (basic_block
, heap
, worklist
, e
->src
);
218 for (bsi
= gsi_start_bb (bb
); !gsi_end_p (bsi
); gsi_next (&bsi
))
220 gimple stmt
= gsi_stmt (bsi
);
221 if (is_gimple_debug (stmt
))
223 if (walk_stmt_load_store_addr_ops
224 (stmt
, non_ssa_vars
, test_nonssa_use
, test_nonssa_use
,
230 if (gimple_code (stmt
) == GIMPLE_LABEL
231 && test_nonssa_use (stmt
, gimple_label_label (stmt
),
238 for (bsi
= gsi_start_phis (bb
); !gsi_end_p (bsi
); gsi_next (&bsi
))
240 if (walk_stmt_load_store_addr_ops
241 (gsi_stmt (bsi
), non_ssa_vars
, test_nonssa_use
, test_nonssa_use
,
248 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
250 if (e
->dest
!= return_bb
)
252 for (bsi
= gsi_start_phis (return_bb
); !gsi_end_p (bsi
);
255 gimple stmt
= gsi_stmt (bsi
);
256 tree op
= gimple_phi_arg_def (stmt
, e
->dest_idx
);
258 if (!is_gimple_reg (gimple_phi_result (stmt
)))
260 if (TREE_CODE (op
) != SSA_NAME
261 && test_nonssa_use (stmt
, op
, non_ssa_vars
))
271 VEC_free (basic_block
, heap
, worklist
);
275 /* We found an split_point CURRENT. NON_SSA_VARS is bitmap of all non ssa
276 variables used and RETURN_BB is return basic block.
277 See if we can split function here. */
280 consider_split (struct split_point
*current
, bitmap non_ssa_vars
,
281 basic_block return_bb
)
284 unsigned int num_args
= 0;
285 unsigned int call_overhead
;
288 gimple_stmt_iterator bsi
;
290 int incoming_freq
= 0;
293 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
294 dump_split_point (dump_file
, current
);
296 FOR_EACH_EDGE (e
, ei
, current
->entry_bb
->preds
)
297 if (!bitmap_bit_p (current
->split_bbs
, e
->src
->index
))
298 incoming_freq
+= EDGE_FREQUENCY (e
);
300 /* Do not split when we would end up calling function anyway. */
302 >= (ENTRY_BLOCK_PTR
->frequency
303 * PARAM_VALUE (PARAM_PARTIAL_INLINING_ENTRY_PROBABILITY
) / 100))
305 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
307 " Refused: incoming frequency is too large.\n");
311 if (!current
->header_size
)
313 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
314 fprintf (dump_file
, " Refused: header empty\n");
318 /* Verify that PHI args on entry are either virtual or all their operands
319 incoming from header are the same. */
320 for (bsi
= gsi_start_phis (current
->entry_bb
); !gsi_end_p (bsi
); gsi_next (&bsi
))
322 gimple stmt
= gsi_stmt (bsi
);
325 if (!is_gimple_reg (gimple_phi_result (stmt
)))
327 for (i
= 0; i
< gimple_phi_num_args (stmt
); i
++)
329 edge e
= gimple_phi_arg_edge (stmt
, i
);
330 if (!bitmap_bit_p (current
->split_bbs
, e
->src
->index
))
332 tree edge_val
= gimple_phi_arg_def (stmt
, i
);
333 if (val
&& edge_val
!= val
)
335 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
337 " Refused: entry BB has PHI with multiple variants\n");
346 /* See what argument we will pass to the split function and compute
348 call_overhead
= eni_size_weights
.call_cost
;
349 for (parm
= DECL_ARGUMENTS (current_function_decl
); parm
;
350 parm
= DECL_CHAIN (parm
))
352 if (!is_gimple_reg (parm
))
354 if (bitmap_bit_p (non_ssa_vars
, DECL_UID (parm
)))
356 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
358 " Refused: need to pass non-ssa param values\n");
362 else if (gimple_default_def (cfun
, parm
)
363 && bitmap_bit_p (current
->ssa_names_to_pass
,
364 SSA_NAME_VERSION (gimple_default_def
367 if (!VOID_TYPE_P (TREE_TYPE (parm
)))
368 call_overhead
+= estimate_move_cost (TREE_TYPE (parm
));
372 if (!VOID_TYPE_P (TREE_TYPE (current_function_decl
)))
373 call_overhead
+= estimate_move_cost (TREE_TYPE (current_function_decl
));
375 if (current
->split_size
<= call_overhead
)
377 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
379 " Refused: split size is smaller than call overhead\n");
382 if (current
->header_size
+ call_overhead
383 >= (unsigned int)(DECL_DECLARED_INLINE_P (current_function_decl
)
384 ? MAX_INLINE_INSNS_SINGLE
385 : MAX_INLINE_INSNS_AUTO
))
387 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
389 " Refused: header size is too large for inline candidate\n");
393 /* FIXME: we currently can pass only SSA function parameters to the split
394 arguments. Once parm_adjustment infrastructure is supported by cloning,
395 we can pass more than that. */
396 if (num_args
!= bitmap_count_bits (current
->ssa_names_to_pass
))
399 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
401 " Refused: need to pass non-param values\n");
405 /* When there are non-ssa vars used in the split region, see if they
406 are used in the header region. If so, reject the split.
407 FIXME: we can use nested function support to access both. */
408 if (!bitmap_empty_p (non_ssa_vars
)
409 && !verify_non_ssa_vars (current
, non_ssa_vars
, return_bb
))
411 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
413 " Refused: split part has non-ssa uses\n");
416 /* See if retval used by return bb is computed by header or split part.
417 When it is computed by split part, we need to produce return statement
418 in the split part and add code to header to pass it around.
420 This is bit tricky to test:
421 1) When there is no return_bb or no return value, we always pass
423 2) Invariants are always computed by caller.
424 3) For SSA we need to look if defining statement is in header or split part
425 4) For non-SSA we need to look where the var is computed. */
426 retval
= find_retval (return_bb
);
428 current
->split_part_set_retval
= true;
429 else if (is_gimple_min_invariant (retval
))
430 current
->split_part_set_retval
= false;
431 /* Special case is value returned by reference we record as if it was non-ssa
432 set to result_decl. */
433 else if (TREE_CODE (retval
) == SSA_NAME
434 && TREE_CODE (SSA_NAME_VAR (retval
)) == RESULT_DECL
435 && DECL_BY_REFERENCE (DECL_RESULT (current_function_decl
)))
436 current
->split_part_set_retval
437 = bitmap_bit_p (non_ssa_vars
, DECL_UID (SSA_NAME_VAR (retval
)));
438 else if (TREE_CODE (retval
) == SSA_NAME
)
439 current
->split_part_set_retval
440 = (!SSA_NAME_IS_DEFAULT_DEF (retval
)
441 && (bitmap_bit_p (current
->split_bbs
,
442 gimple_bb (SSA_NAME_DEF_STMT (retval
))->index
)
443 || gimple_bb (SSA_NAME_DEF_STMT (retval
)) == return_bb
));
444 else if (TREE_CODE (retval
) == PARM_DECL
)
445 current
->split_part_set_retval
= false;
446 else if (TREE_CODE (retval
) == VAR_DECL
447 || TREE_CODE (retval
) == RESULT_DECL
)
448 current
->split_part_set_retval
449 = bitmap_bit_p (non_ssa_vars
, DECL_UID (retval
));
451 current
->split_part_set_retval
= true;
453 /* split_function fixes up at most one PHI non-virtual PHI node in return_bb,
454 for the return value. If there are other PHIs, give up. */
455 if (return_bb
!= EXIT_BLOCK_PTR
)
457 gimple_stmt_iterator psi
;
459 for (psi
= gsi_start_phis (return_bb
); !gsi_end_p (psi
); gsi_next (&psi
))
460 if (is_gimple_reg (gimple_phi_result (gsi_stmt (psi
)))
462 && current
->split_part_set_retval
463 && TREE_CODE (retval
) == SSA_NAME
464 && !DECL_BY_REFERENCE (DECL_RESULT (current_function_decl
))
465 && SSA_NAME_DEF_STMT (retval
) == gsi_stmt (psi
)))
467 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
469 " Refused: return bb has extra PHIs\n");
474 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
475 fprintf (dump_file
, " Accepted!\n");
477 /* At the moment chose split point with lowest frequency and that leaves
478 out smallest size of header.
479 In future we might re-consider this heuristics. */
480 if (!best_split_point
.split_bbs
481 || best_split_point
.entry_bb
->frequency
> current
->entry_bb
->frequency
482 || (best_split_point
.entry_bb
->frequency
== current
->entry_bb
->frequency
483 && best_split_point
.split_size
< current
->split_size
))
486 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
487 fprintf (dump_file
, " New best split point!\n");
488 if (best_split_point
.ssa_names_to_pass
)
490 BITMAP_FREE (best_split_point
.ssa_names_to_pass
);
491 BITMAP_FREE (best_split_point
.split_bbs
);
493 best_split_point
= *current
;
494 best_split_point
.ssa_names_to_pass
= BITMAP_ALLOC (NULL
);
495 bitmap_copy (best_split_point
.ssa_names_to_pass
,
496 current
->ssa_names_to_pass
);
497 best_split_point
.split_bbs
= BITMAP_ALLOC (NULL
);
498 bitmap_copy (best_split_point
.split_bbs
, current
->split_bbs
);
502 /* Return basic block containing RETURN statement. We allow basic blocks
506 but return_bb can not be more complex than this.
507 If nothing is found, return EXIT_BLOCK_PTR.
509 When there are multiple RETURN statement, chose one with return value,
510 since that one is more likely shared by multiple code paths.
512 Return BB is special, because for function splitting it is the only
513 basic block that is duplicated in between header and split part of the
516 TODO: We might support multiple return blocks. */
519 find_return_bb (void)
522 basic_block return_bb
= EXIT_BLOCK_PTR
;
523 gimple_stmt_iterator bsi
;
524 bool found_return
= false;
525 tree retval
= NULL_TREE
;
527 if (!single_pred_p (EXIT_BLOCK_PTR
))
530 e
= single_pred_edge (EXIT_BLOCK_PTR
);
531 for (bsi
= gsi_last_bb (e
->src
); !gsi_end_p (bsi
); gsi_prev (&bsi
))
533 gimple stmt
= gsi_stmt (bsi
);
534 if (gimple_code (stmt
) == GIMPLE_LABEL
|| is_gimple_debug (stmt
))
536 else if (gimple_code (stmt
) == GIMPLE_ASSIGN
538 && gimple_assign_single_p (stmt
)
539 && (auto_var_in_fn_p (gimple_assign_rhs1 (stmt
),
540 current_function_decl
)
541 || is_gimple_min_invariant (gimple_assign_rhs1 (stmt
)))
542 && retval
== gimple_assign_lhs (stmt
))
544 else if (gimple_code (stmt
) == GIMPLE_RETURN
)
547 retval
= gimple_return_retval (stmt
);
552 if (gsi_end_p (bsi
) && found_return
)
558 /* Given return basic block RETURN_BB, see where return value is really
561 find_retval (basic_block return_bb
)
563 gimple_stmt_iterator bsi
;
564 for (bsi
= gsi_start_bb (return_bb
); !gsi_end_p (bsi
); gsi_next (&bsi
))
565 if (gimple_code (gsi_stmt (bsi
)) == GIMPLE_RETURN
)
566 return gimple_return_retval (gsi_stmt (bsi
));
567 else if (gimple_code (gsi_stmt (bsi
)) == GIMPLE_ASSIGN
)
568 return gimple_assign_rhs1 (gsi_stmt (bsi
));
572 /* Callback for walk_stmt_load_store_addr_ops. If T is non-SSA automatic
573 variable, mark it as used in bitmap passed via DATA.
574 Return true when access to T prevents splitting the function. */
577 mark_nonssa_use (gimple stmt ATTRIBUTE_UNUSED
, tree t
, void *data
)
579 t
= get_base_address (t
);
581 if (!t
|| is_gimple_reg (t
))
584 /* At present we can't pass non-SSA arguments to split function.
585 FIXME: this can be relaxed by passing references to arguments. */
586 if (TREE_CODE (t
) == PARM_DECL
)
588 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
590 "Cannot split: use of non-ssa function parameter.\n");
594 if ((TREE_CODE (t
) == VAR_DECL
595 && auto_var_in_fn_p (t
, current_function_decl
))
596 || TREE_CODE (t
) == RESULT_DECL
597 || TREE_CODE (t
) == LABEL_DECL
)
598 bitmap_set_bit ((bitmap
)data
, DECL_UID (t
));
600 /* For DECL_BY_REFERENCE, the return value is actually a pointer. We want
601 to pretend that the value pointed to is actual result decl. */
602 if ((TREE_CODE (t
) == MEM_REF
|| INDIRECT_REF_P (t
))
603 && TREE_CODE (TREE_OPERAND (t
, 0)) == SSA_NAME
604 && TREE_CODE (SSA_NAME_VAR (TREE_OPERAND (t
, 0))) == RESULT_DECL
605 && DECL_BY_REFERENCE (DECL_RESULT (current_function_decl
)))
607 bitmap_bit_p ((bitmap
)data
,
608 DECL_UID (DECL_RESULT (current_function_decl
)));
613 /* Compute local properties of basic block BB we collect when looking for
614 split points. We look for ssa defs and store them in SET_SSA_NAMES,
615 for ssa uses and store them in USED_SSA_NAMES and for any non-SSA automatic
616 vars stored in NON_SSA_VARS.
618 When BB has edge to RETURN_BB, collect uses in RETURN_BB too.
620 Return false when BB contains something that prevents it from being put into
624 visit_bb (basic_block bb
, basic_block return_bb
,
625 bitmap set_ssa_names
, bitmap used_ssa_names
,
628 gimple_stmt_iterator bsi
;
631 bool can_split
= true;
633 for (bsi
= gsi_start_bb (bb
); !gsi_end_p (bsi
); gsi_next (&bsi
))
635 gimple stmt
= gsi_stmt (bsi
);
640 if (is_gimple_debug (stmt
))
643 /* FIXME: We can split regions containing EH. We can not however
644 split RESX, EH_DISPATCH and EH_POINTER referring to same region
645 into different partitions. This would require tracking of
646 EH regions and checking in consider_split_point if they
647 are not used elsewhere. */
648 if (gimple_code (stmt
) == GIMPLE_RESX
)
650 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
651 fprintf (dump_file
, "Cannot split: resx.\n");
654 if (gimple_code (stmt
) == GIMPLE_EH_DISPATCH
)
656 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
657 fprintf (dump_file
, "Cannot split: eh dispatch.\n");
661 /* Check builtins that prevent splitting. */
662 if (gimple_code (stmt
) == GIMPLE_CALL
663 && (decl
= gimple_call_fndecl (stmt
)) != NULL_TREE
664 && DECL_BUILT_IN (decl
)
665 && DECL_BUILT_IN_CLASS (decl
) == BUILT_IN_NORMAL
)
666 switch (DECL_FUNCTION_CODE (decl
))
668 /* FIXME: once we will allow passing non-parm values to split part,
669 we need to be sure to handle correct builtin_stack_save and
670 builtin_stack_restore. At the moment we are safe; there is no
671 way to store builtin_stack_save result in non-SSA variable
672 since all calls to those are compiler generated. */
674 case BUILT_IN_APPLY_ARGS
:
675 case BUILT_IN_VA_START
:
676 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
678 "Cannot split: builtin_apply and va_start.\n");
681 case BUILT_IN_EH_POINTER
:
682 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
683 fprintf (dump_file
, "Cannot split: builtin_eh_pointer.\n");
690 FOR_EACH_SSA_TREE_OPERAND (op
, stmt
, iter
, SSA_OP_DEF
)
691 bitmap_set_bit (set_ssa_names
, SSA_NAME_VERSION (op
));
692 FOR_EACH_SSA_TREE_OPERAND (op
, stmt
, iter
, SSA_OP_USE
)
693 bitmap_set_bit (used_ssa_names
, SSA_NAME_VERSION (op
));
694 can_split
&= !walk_stmt_load_store_addr_ops (stmt
, non_ssa_vars
,
699 for (bsi
= gsi_start_phis (bb
); !gsi_end_p (bsi
); gsi_next (&bsi
))
701 gimple stmt
= gsi_stmt (bsi
);
704 if (is_gimple_debug (stmt
))
706 if (!is_gimple_reg (gimple_phi_result (stmt
)))
708 bitmap_set_bit (set_ssa_names
,
709 SSA_NAME_VERSION (gimple_phi_result (stmt
)));
710 for (i
= 0; i
< gimple_phi_num_args (stmt
); i
++)
712 tree op
= gimple_phi_arg_def (stmt
, i
);
713 if (TREE_CODE (op
) == SSA_NAME
)
714 bitmap_set_bit (used_ssa_names
, SSA_NAME_VERSION (op
));
716 can_split
&= !walk_stmt_load_store_addr_ops (stmt
, non_ssa_vars
,
721 /* Record also uses coming from PHI operand in return BB. */
722 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
723 if (e
->dest
== return_bb
)
725 for (bsi
= gsi_start_phis (return_bb
); !gsi_end_p (bsi
); gsi_next (&bsi
))
727 gimple stmt
= gsi_stmt (bsi
);
728 tree op
= gimple_phi_arg_def (stmt
, e
->dest_idx
);
730 if (is_gimple_debug (stmt
))
732 if (!is_gimple_reg (gimple_phi_result (stmt
)))
734 if (TREE_CODE (op
) == SSA_NAME
)
735 bitmap_set_bit (used_ssa_names
, SSA_NAME_VERSION (op
));
737 can_split
&= !mark_nonssa_use (stmt
, op
, non_ssa_vars
);
743 /* Stack entry for recursive DFS walk in find_split_point. */
747 /* Basic block we are examining. */
750 /* SSA names set and used by the BB and all BBs reachable
751 from it via DFS walk. */
752 bitmap set_ssa_names
, used_ssa_names
;
755 /* All BBS visited from this BB via DFS walk. */
758 /* Last examined edge in DFS walk. Since we walk unoriented graph,
759 the value is up to sum of incoming and outgoing edges of BB. */
760 unsigned int edge_num
;
762 /* Stack entry index of earliest BB reachable from current BB
763 or any BB visited later in DFS walk. */
766 /* Overall time and size of all BBs reached from this BB in DFS walk. */
767 int overall_time
, overall_size
;
769 /* When false we can not split on this BB. */
772 DEF_VEC_O(stack_entry
);
773 DEF_VEC_ALLOC_O(stack_entry
,heap
);
776 /* Find all articulations and call consider_split on them.
777 OVERALL_TIME and OVERALL_SIZE is time and size of the function.
779 We perform basic algorithm for finding an articulation in a graph
780 created from CFG by considering it to be an unoriented graph.
782 The articulation is discovered via DFS walk. We collect earliest
783 basic block on stack that is reachable via backward edge. Articulation
784 is any basic block such that there is no backward edge bypassing it.
785 To reduce stack usage we maintain heap allocated stack in STACK vector.
786 AUX pointer of BB is set to index it appears in the stack or -1 once
787 it is visited and popped off the stack.
789 The algorithm finds articulation after visiting the whole component
790 reachable by it. This makes it convenient to collect information about
791 the component used by consider_split. */
794 find_split_points (int overall_time
, int overall_size
)
797 VEC(stack_entry
, heap
) *stack
= NULL
;
799 basic_block return_bb
= find_return_bb ();
800 struct split_point current
;
802 current
.header_time
= overall_time
;
803 current
.header_size
= overall_size
;
804 current
.split_time
= 0;
805 current
.split_size
= 0;
806 current
.ssa_names_to_pass
= BITMAP_ALLOC (NULL
);
808 first
.bb
= ENTRY_BLOCK_PTR
;
810 first
.overall_time
= 0;
811 first
.overall_size
= 0;
812 first
.earliest
= INT_MAX
;
813 first
.set_ssa_names
= 0;
814 first
.used_ssa_names
= 0;
815 first
.bbs_visited
= 0;
816 VEC_safe_push (stack_entry
, heap
, stack
, &first
);
817 ENTRY_BLOCK_PTR
->aux
= (void *)(intptr_t)-1;
819 while (!VEC_empty (stack_entry
, stack
))
821 stack_entry
*entry
= VEC_last (stack_entry
, stack
);
823 /* We are walking an acyclic graph, so edge_num counts
824 succ and pred edges together. However when considering
825 articulation, we want to have processed everything reachable
826 from articulation but nothing that reaches into it. */
827 if (entry
->edge_num
== EDGE_COUNT (entry
->bb
->succs
)
828 && entry
->bb
!= ENTRY_BLOCK_PTR
)
830 int pos
= VEC_length (stack_entry
, stack
);
831 entry
->can_split
&= visit_bb (entry
->bb
, return_bb
,
832 entry
->set_ssa_names
,
833 entry
->used_ssa_names
,
834 entry
->non_ssa_vars
);
835 if (pos
<= entry
->earliest
&& !entry
->can_split
836 && dump_file
&& (dump_flags
& TDF_DETAILS
))
838 "found articulation at bb %i but can not split\n",
840 if (pos
<= entry
->earliest
&& entry
->can_split
)
842 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
843 fprintf (dump_file
, "found articulation at bb %i\n",
845 current
.entry_bb
= entry
->bb
;
846 current
.ssa_names_to_pass
= BITMAP_ALLOC (NULL
);
847 bitmap_and_compl (current
.ssa_names_to_pass
,
848 entry
->used_ssa_names
, entry
->set_ssa_names
);
849 current
.header_time
= overall_time
- entry
->overall_time
;
850 current
.header_size
= overall_size
- entry
->overall_size
;
851 current
.split_time
= entry
->overall_time
;
852 current
.split_size
= entry
->overall_size
;
853 current
.split_bbs
= entry
->bbs_visited
;
854 consider_split (¤t
, entry
->non_ssa_vars
, return_bb
);
855 BITMAP_FREE (current
.ssa_names_to_pass
);
858 /* Do actual DFS walk. */
860 < (EDGE_COUNT (entry
->bb
->succs
)
861 + EDGE_COUNT (entry
->bb
->preds
)))
865 if (entry
->edge_num
< EDGE_COUNT (entry
->bb
->succs
))
867 e
= EDGE_SUCC (entry
->bb
, entry
->edge_num
);
872 e
= EDGE_PRED (entry
->bb
, entry
->edge_num
873 - EDGE_COUNT (entry
->bb
->succs
));
879 /* New BB to visit, push it to the stack. */
880 if (dest
!= return_bb
&& dest
!= EXIT_BLOCK_PTR
883 stack_entry new_entry
;
886 new_entry
.edge_num
= 0;
887 new_entry
.overall_time
888 = VEC_index (bb_info
, bb_info_vec
, dest
->index
)->time
;
889 new_entry
.overall_size
890 = VEC_index (bb_info
, bb_info_vec
, dest
->index
)->size
;
891 new_entry
.earliest
= INT_MAX
;
892 new_entry
.set_ssa_names
= BITMAP_ALLOC (NULL
);
893 new_entry
.used_ssa_names
= BITMAP_ALLOC (NULL
);
894 new_entry
.bbs_visited
= BITMAP_ALLOC (NULL
);
895 new_entry
.non_ssa_vars
= BITMAP_ALLOC (NULL
);
896 new_entry
.can_split
= true;
897 bitmap_set_bit (new_entry
.bbs_visited
, dest
->index
);
898 VEC_safe_push (stack_entry
, heap
, stack
, &new_entry
);
899 dest
->aux
= (void *)(intptr_t)VEC_length (stack_entry
, stack
);
901 /* Back edge found, record the earliest point. */
902 else if ((intptr_t)dest
->aux
> 0
903 && (intptr_t)dest
->aux
< entry
->earliest
)
904 entry
->earliest
= (intptr_t)dest
->aux
;
906 /* We are done with examining the edges. Pop off the value from stack
907 and merge stuff we accumulate during the walk. */
908 else if (entry
->bb
!= ENTRY_BLOCK_PTR
)
910 stack_entry
*prev
= VEC_index (stack_entry
, stack
,
911 VEC_length (stack_entry
, stack
) - 2);
913 entry
->bb
->aux
= (void *)(intptr_t)-1;
914 prev
->can_split
&= entry
->can_split
;
915 if (prev
->set_ssa_names
)
917 bitmap_ior_into (prev
->set_ssa_names
, entry
->set_ssa_names
);
918 bitmap_ior_into (prev
->used_ssa_names
, entry
->used_ssa_names
);
919 bitmap_ior_into (prev
->bbs_visited
, entry
->bbs_visited
);
920 bitmap_ior_into (prev
->non_ssa_vars
, entry
->non_ssa_vars
);
922 if (prev
->earliest
> entry
->earliest
)
923 prev
->earliest
= entry
->earliest
;
924 prev
->overall_time
+= entry
->overall_time
;
925 prev
->overall_size
+= entry
->overall_size
;
926 BITMAP_FREE (entry
->set_ssa_names
);
927 BITMAP_FREE (entry
->used_ssa_names
);
928 BITMAP_FREE (entry
->bbs_visited
);
929 BITMAP_FREE (entry
->non_ssa_vars
);
930 VEC_pop (stack_entry
, stack
);
933 VEC_pop (stack_entry
, stack
);
935 ENTRY_BLOCK_PTR
->aux
= NULL
;
938 VEC_free (stack_entry
, heap
, stack
);
939 BITMAP_FREE (current
.ssa_names_to_pass
);
942 /* Split function at SPLIT_POINT. */
945 split_function (struct split_point
*split_point
)
947 VEC (tree
, heap
) *args_to_pass
= NULL
;
951 struct cgraph_node
*node
, *cur_node
= cgraph_get_node (current_function_decl
);
952 basic_block return_bb
= find_return_bb ();
954 gimple_stmt_iterator gsi
;
958 tree retval
= NULL
, real_retval
= NULL
;
959 bool split_part_return_p
= false;
960 gimple last_stmt
= NULL
;
961 bool conv_needed
= false;
967 fprintf (dump_file
, "\n\nSplitting function at:\n");
968 dump_split_point (dump_file
, split_point
);
971 if (cur_node
->local
.can_change_signature
)
972 args_to_skip
= BITMAP_ALLOC (NULL
);
976 /* Collect the parameters of new function and args_to_skip bitmap. */
977 for (parm
= DECL_ARGUMENTS (current_function_decl
);
978 parm
; parm
= DECL_CHAIN (parm
), num
++)
980 && (!is_gimple_reg (parm
)
981 || !gimple_default_def (cfun
, parm
)
982 || !bitmap_bit_p (split_point
->ssa_names_to_pass
,
983 SSA_NAME_VERSION (gimple_default_def (cfun
,
985 bitmap_set_bit (args_to_skip
, num
);
988 arg
= gimple_default_def (cfun
, parm
);
991 arg
= make_ssa_name (parm
, gimple_build_nop ());
992 set_default_def (parm
, arg
);
995 if (TYPE_MAIN_VARIANT (DECL_ARG_TYPE (parm
))
996 != TYPE_MAIN_VARIANT (TREE_TYPE (arg
)))
999 arg
= fold_convert (DECL_ARG_TYPE (parm
), arg
);
1001 VEC_safe_push (tree
, heap
, args_to_pass
, arg
);
1004 /* See if the split function will return. */
1005 FOR_EACH_EDGE (e
, ei
, return_bb
->preds
)
1006 if (bitmap_bit_p (split_point
->split_bbs
, e
->src
->index
))
1009 split_part_return_p
= true;
1011 /* Add return block to what will become the split function.
1012 We do not return; no return block is needed. */
1013 if (!split_part_return_p
)
1015 /* We have no return block, so nothing is needed. */
1016 else if (return_bb
== EXIT_BLOCK_PTR
)
1018 /* When we do not want to return value, we need to construct
1019 new return block with empty return statement.
1020 FIXME: Once we are able to change return type, we should change function
1021 to return void instead of just outputting function with undefined return
1022 value. For structures this affects quality of codegen. */
1023 else if (!split_point
->split_part_set_retval
1024 && find_retval (return_bb
))
1026 bool redirected
= true;
1027 basic_block new_return_bb
= create_basic_block (NULL
, 0, return_bb
);
1028 gimple_stmt_iterator gsi
= gsi_start_bb (new_return_bb
);
1029 gsi_insert_after (&gsi
, gimple_build_return (NULL
), GSI_NEW_STMT
);
1033 FOR_EACH_EDGE (e
, ei
, return_bb
->preds
)
1034 if (bitmap_bit_p (split_point
->split_bbs
, e
->src
->index
))
1036 new_return_bb
->count
+= e
->count
;
1037 new_return_bb
->frequency
+= EDGE_FREQUENCY (e
);
1038 redirect_edge_and_branch (e
, new_return_bb
);
1043 e
= make_edge (new_return_bb
, EXIT_BLOCK_PTR
, 0);
1044 e
->probability
= REG_BR_PROB_BASE
;
1045 e
->count
= new_return_bb
->count
;
1046 bitmap_set_bit (split_point
->split_bbs
, new_return_bb
->index
);
1048 /* When we pass around the value, use existing return block. */
1050 bitmap_set_bit (split_point
->split_bbs
, return_bb
->index
);
1052 /* If RETURN_BB has virtual operand PHIs, they must be removed and the
1053 virtual operand marked for renaming as we change the CFG in a way that
1054 tree-inline is not able to compensate for.
1056 Note this can happen whether or not we have a return value. If we have
1057 a return value, then RETURN_BB may have PHIs for real operands too. */
1058 if (return_bb
!= EXIT_BLOCK_PTR
)
1061 for (gsi
= gsi_start_phis (return_bb
); !gsi_end_p (gsi
);)
1063 gimple stmt
= gsi_stmt (gsi
);
1064 if (is_gimple_reg (gimple_phi_result (stmt
)))
1069 mark_virtual_phi_result_for_renaming (stmt
);
1070 remove_phi_node (&gsi
, true);
1073 /* In reality we have to rename the reaching definition of the
1074 virtual operand at return_bb as we will eventually release it
1075 when we remove the code region we outlined.
1076 So we have to rename all immediate virtual uses of that region
1077 if we didn't see a PHI definition yet. */
1078 /* ??? In real reality we want to set the reaching vdef of the
1079 entry of the SESE region as the vuse of the call and the reaching
1080 vdef of the exit of the SESE region as the vdef of the call. */
1082 for (gsi
= gsi_start_bb (return_bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
1084 gimple stmt
= gsi_stmt (gsi
);
1085 if (gimple_vuse (stmt
))
1087 gimple_set_vuse (stmt
, NULL_TREE
);
1090 if (gimple_vdef (stmt
))
1095 /* Now create the actual clone. */
1096 rebuild_cgraph_edges ();
1097 node
= cgraph_function_versioning (cur_node
, NULL
, NULL
, args_to_skip
,
1098 split_point
->split_bbs
,
1099 split_point
->entry_bb
, "part");
1100 /* For usual cloning it is enough to clear builtin only when signature
1101 changes. For partial inlining we however can not expect the part
1102 of builtin implementation to have same semantic as the whole. */
1103 if (DECL_BUILT_IN (node
->decl
))
1105 DECL_BUILT_IN_CLASS (node
->decl
) = NOT_BUILT_IN
;
1106 DECL_FUNCTION_CODE (node
->decl
) = (enum built_in_function
) 0;
1108 cgraph_node_remove_callees (cur_node
);
1109 if (!split_part_return_p
)
1110 TREE_THIS_VOLATILE (node
->decl
) = 1;
1112 dump_function_to_file (node
->decl
, dump_file
, dump_flags
);
1114 /* Create the basic block we place call into. It is the entry basic block
1115 split after last label. */
1116 call_bb
= split_point
->entry_bb
;
1117 for (gsi
= gsi_start_bb (call_bb
); !gsi_end_p (gsi
);)
1118 if (gimple_code (gsi_stmt (gsi
)) == GIMPLE_LABEL
)
1120 last_stmt
= gsi_stmt (gsi
);
1125 e
= split_block (split_point
->entry_bb
, last_stmt
);
1128 /* Produce the call statement. */
1129 gsi
= gsi_last_bb (call_bb
);
1131 FOR_EACH_VEC_ELT (tree
, args_to_pass
, i
, arg
)
1132 if (!is_gimple_val (arg
))
1134 arg
= force_gimple_operand_gsi (&gsi
, arg
, true, NULL_TREE
,
1135 false, GSI_NEW_STMT
);
1136 VEC_replace (tree
, args_to_pass
, i
, arg
);
1138 call
= gimple_build_call_vec (node
->decl
, args_to_pass
);
1139 gimple_set_block (call
, DECL_INITIAL (current_function_decl
));
1141 /* We avoid address being taken on any variable used by split part,
1142 so return slot optimization is always possible. Moreover this is
1143 required to make DECL_BY_REFERENCE work. */
1144 if (aggregate_value_p (DECL_RESULT (current_function_decl
),
1145 TREE_TYPE (current_function_decl
)))
1146 gimple_call_set_return_slot_opt (call
, true);
1148 /* Update return value. This is bit tricky. When we do not return,
1149 do nothing. When we return we might need to update return_bb
1150 or produce a new return statement. */
1151 if (!split_part_return_p
)
1152 gsi_insert_after (&gsi
, call
, GSI_NEW_STMT
);
1155 e
= make_edge (call_bb
, return_bb
,
1156 return_bb
== EXIT_BLOCK_PTR
? 0 : EDGE_FALLTHRU
);
1157 e
->count
= call_bb
->count
;
1158 e
->probability
= REG_BR_PROB_BASE
;
1160 /* If there is return basic block, see what value we need to store
1161 return value into and put call just before it. */
1162 if (return_bb
!= EXIT_BLOCK_PTR
)
1164 real_retval
= retval
= find_retval (return_bb
);
1166 if (real_retval
&& split_point
->split_part_set_retval
)
1168 gimple_stmt_iterator psi
;
1170 /* See if we need new SSA_NAME for the result.
1171 When DECL_BY_REFERENCE is true, retval is actually pointer to
1172 return value and it is constant in whole function. */
1173 if (TREE_CODE (retval
) == SSA_NAME
1174 && !DECL_BY_REFERENCE (DECL_RESULT (current_function_decl
)))
1176 retval
= make_ssa_name (SSA_NAME_VAR (retval
), call
);
1178 /* See if there is PHI defining return value. */
1179 for (psi
= gsi_start_phis (return_bb
);
1180 !gsi_end_p (psi
); gsi_next (&psi
))
1181 if (is_gimple_reg (gimple_phi_result (gsi_stmt (psi
))))
1184 /* When there is PHI, just update its value. */
1185 if (TREE_CODE (retval
) == SSA_NAME
1186 && !gsi_end_p (psi
))
1187 add_phi_arg (gsi_stmt (psi
), retval
, e
, UNKNOWN_LOCATION
);
1188 /* Otherwise update the return BB itself.
1189 find_return_bb allows at most one assignment to return value,
1190 so update first statement. */
1193 gimple_stmt_iterator bsi
;
1194 for (bsi
= gsi_start_bb (return_bb
); !gsi_end_p (bsi
);
1196 if (gimple_code (gsi_stmt (bsi
)) == GIMPLE_RETURN
)
1198 gimple_return_set_retval (gsi_stmt (bsi
), retval
);
1201 else if (gimple_code (gsi_stmt (bsi
)) == GIMPLE_ASSIGN
)
1203 gimple_assign_set_rhs1 (gsi_stmt (bsi
), retval
);
1206 update_stmt (gsi_stmt (bsi
));
1209 if (DECL_BY_REFERENCE (DECL_RESULT (current_function_decl
)))
1211 gimple_call_set_lhs (call
, build_simple_mem_ref (retval
));
1212 gsi_insert_after (&gsi
, call
, GSI_NEW_STMT
);
1217 restype
= TREE_TYPE (DECL_RESULT (current_function_decl
));
1218 gsi_insert_after (&gsi
, call
, GSI_NEW_STMT
);
1219 if (!useless_type_conversion_p (TREE_TYPE (retval
), restype
))
1222 tree tem
= create_tmp_reg (restype
, NULL
);
1223 tem
= make_ssa_name (tem
, call
);
1224 cpy
= gimple_build_assign_with_ops (NOP_EXPR
, retval
,
1226 gsi_insert_after (&gsi
, cpy
, GSI_NEW_STMT
);
1229 gimple_call_set_lhs (call
, retval
);
1234 gsi_insert_after (&gsi
, call
, GSI_NEW_STMT
);
1236 /* We don't use return block (there is either no return in function or
1237 multiple of them). So create new basic block with return statement.
1242 if (split_point
->split_part_set_retval
1243 && !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl
))))
1245 retval
= DECL_RESULT (current_function_decl
);
1247 /* We use temporary register to hold value when aggregate_value_p
1248 is false. Similarly for DECL_BY_REFERENCE we must avoid extra
1250 if (!aggregate_value_p (retval
, TREE_TYPE (current_function_decl
))
1251 && !DECL_BY_REFERENCE (retval
))
1252 retval
= create_tmp_reg (TREE_TYPE (retval
), NULL
);
1253 if (is_gimple_reg (retval
))
1255 /* When returning by reference, there is only one SSA name
1256 assigned to RESULT_DECL (that is pointer to return value).
1257 Look it up or create new one if it is missing. */
1258 if (DECL_BY_REFERENCE (retval
))
1261 if ((retval_name
= gimple_default_def (cfun
, retval
))
1263 retval
= retval_name
;
1266 retval_name
= make_ssa_name (retval
,
1267 gimple_build_nop ());
1268 set_default_def (retval
, retval_name
);
1269 retval
= retval_name
;
1272 /* Otherwise produce new SSA name for return value. */
1274 retval
= make_ssa_name (retval
, call
);
1276 if (DECL_BY_REFERENCE (DECL_RESULT (current_function_decl
)))
1277 gimple_call_set_lhs (call
, build_simple_mem_ref (retval
));
1279 gimple_call_set_lhs (call
, retval
);
1281 gsi_insert_after (&gsi
, call
, GSI_NEW_STMT
);
1282 ret
= gimple_build_return (retval
);
1283 gsi_insert_after (&gsi
, ret
, GSI_NEW_STMT
);
1286 free_dominance_info (CDI_DOMINATORS
);
1287 free_dominance_info (CDI_POST_DOMINATORS
);
1288 compute_inline_parameters (node
, true);
1291 /* Execute function splitting pass. */
1294 execute_split_functions (void)
1296 gimple_stmt_iterator bsi
;
1298 int overall_time
= 0, overall_size
= 0;
1300 struct cgraph_node
*node
= cgraph_get_node (current_function_decl
);
1302 if (flags_from_decl_or_type (current_function_decl
) & ECF_NORETURN
)
1305 fprintf (dump_file
, "Not splitting: noreturn function.\n");
1308 if (MAIN_NAME_P (DECL_NAME (current_function_decl
)))
1311 fprintf (dump_file
, "Not splitting: main function.\n");
1314 /* This can be relaxed; function might become inlinable after splitting
1315 away the uninlinable part. */
1316 if (!inline_summary (node
)->inlinable
)
1319 fprintf (dump_file
, "Not splitting: not inlinable.\n");
1322 if (DECL_DISREGARD_INLINE_LIMITS (node
->decl
))
1325 fprintf (dump_file
, "Not splitting: disregarding inline limits.\n");
1328 /* This can be relaxed; most of versioning tests actually prevents
1330 if (!tree_versionable_function_p (current_function_decl
))
1333 fprintf (dump_file
, "Not splitting: not versionable.\n");
1336 /* FIXME: we could support this. */
1337 if (DECL_STRUCT_FUNCTION (current_function_decl
)->static_chain_decl
)
1340 fprintf (dump_file
, "Not splitting: nested function.\n");
1344 /* See if it makes sense to try to split.
1345 It makes sense to split if we inline, that is if we have direct calls to
1346 handle or direct calls are possibly going to appear as result of indirect
1347 inlining or LTO. Also handle -fprofile-generate as LTO to allow non-LTO
1348 training for LTO -fprofile-use build.
1350 Note that we are not completely conservative about disqualifying functions
1351 called once. It is possible that the caller is called more then once and
1352 then inlining would still benefit. */
1353 if ((!node
->callers
|| !node
->callers
->next_caller
)
1354 && !node
->address_taken
1355 && (!flag_lto
|| !node
->local
.externally_visible
))
1358 fprintf (dump_file
, "Not splitting: not called directly "
1359 "or called once.\n");
1363 /* FIXME: We can actually split if splitting reduces call overhead. */
1364 if (!flag_inline_small_functions
1365 && !DECL_DECLARED_INLINE_P (current_function_decl
))
1368 fprintf (dump_file
, "Not splitting: not autoinlining and function"
1369 " is not inline.\n");
1373 /* Compute local info about basic blocks and determine function size/time. */
1374 VEC_safe_grow_cleared (bb_info
, heap
, bb_info_vec
, last_basic_block
+ 1);
1375 memset (&best_split_point
, 0, sizeof (best_split_point
));
1380 int freq
= compute_call_stmt_bb_frequency (current_function_decl
, bb
);
1382 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
1383 fprintf (dump_file
, "Basic block %i\n", bb
->index
);
1385 for (bsi
= gsi_start_bb (bb
); !gsi_end_p (bsi
); gsi_next (&bsi
))
1387 int this_time
, this_size
;
1388 gimple stmt
= gsi_stmt (bsi
);
1390 this_size
= estimate_num_insns (stmt
, &eni_size_weights
);
1391 this_time
= estimate_num_insns (stmt
, &eni_time_weights
) * freq
;
1395 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
1397 fprintf (dump_file
, " freq:%6i size:%3i time:%3i ",
1398 freq
, this_size
, this_time
);
1399 print_gimple_stmt (dump_file
, stmt
, 0, 0);
1402 overall_time
+= time
;
1403 overall_size
+= size
;
1404 VEC_index (bb_info
, bb_info_vec
, bb
->index
)->time
= time
;
1405 VEC_index (bb_info
, bb_info_vec
, bb
->index
)->size
= size
;
1407 find_split_points (overall_time
, overall_size
);
1408 if (best_split_point
.split_bbs
)
1410 split_function (&best_split_point
);
1411 BITMAP_FREE (best_split_point
.ssa_names_to_pass
);
1412 BITMAP_FREE (best_split_point
.split_bbs
);
1413 todo
= TODO_update_ssa
| TODO_cleanup_cfg
;
1415 VEC_free (bb_info
, heap
, bb_info_vec
);
1420 /* Gate function splitting pass. When doing profile feedback, we want
1421 to execute the pass after profiling is read. So disable one in
1422 early optimization. */
1425 gate_split_functions (void)
1427 return (flag_partial_inlining
1428 && !profile_arc_flag
&& !flag_branch_probabilities
);
1431 struct gimple_opt_pass pass_split_functions
=
1435 "fnsplit", /* name */
1436 gate_split_functions
, /* gate */
1437 execute_split_functions
, /* execute */
1440 0, /* static_pass_number */
1441 TV_IPA_FNSPLIT
, /* tv_id */
1442 PROP_cfg
, /* properties_required */
1443 0, /* properties_provided */
1444 0, /* properties_destroyed */
1445 0, /* todo_flags_start */
1446 0 /* todo_flags_finish */
1450 /* Gate feedback driven function splitting pass.
1451 We don't need to split when profiling at all, we are producing
1452 lousy code anyway. */
1455 gate_feedback_split_functions (void)
1457 return (flag_partial_inlining
1458 && flag_branch_probabilities
);
1461 /* Execute function splitting pass. */
1464 execute_feedback_split_functions (void)
1466 unsigned int retval
= execute_split_functions ();
1468 retval
|= TODO_rebuild_cgraph_edges
;
1472 struct gimple_opt_pass pass_feedback_split_functions
=
1476 "feedback_fnsplit", /* name */
1477 gate_feedback_split_functions
, /* gate */
1478 execute_feedback_split_functions
, /* execute */
1481 0, /* static_pass_number */
1482 TV_IPA_FNSPLIT
, /* tv_id */
1483 PROP_cfg
, /* properties_required */
1484 0, /* properties_provided */
1485 0, /* properties_destroyed */
1486 0, /* todo_flags_start */
1487 0 /* todo_flags_finish */