Mercurial > hg > CbC > CbC_gcc
comparison gcc/tree-cfg.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | b7f97abdc517 |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
27 #include "tm_p.h" | 27 #include "tm_p.h" |
28 #include "basic-block.h" | 28 #include "basic-block.h" |
29 #include "output.h" | 29 #include "output.h" |
30 #include "flags.h" | 30 #include "flags.h" |
31 #include "function.h" | 31 #include "function.h" |
32 #include "expr.h" | |
33 #include "ggc.h" | 32 #include "ggc.h" |
34 #include "langhooks.h" | 33 #include "langhooks.h" |
35 #include "diagnostic.h" | |
36 #include "tree-pretty-print.h" | 34 #include "tree-pretty-print.h" |
37 #include "gimple-pretty-print.h" | 35 #include "gimple-pretty-print.h" |
38 #include "tree-flow.h" | 36 #include "tree-flow.h" |
39 #include "timevar.h" | 37 #include "timevar.h" |
40 #include "tree-dump.h" | 38 #include "tree-dump.h" |
41 #include "tree-pass.h" | 39 #include "tree-pass.h" |
42 #include "toplev.h" | 40 #include "diagnostic-core.h" |
43 #include "except.h" | 41 #include "except.h" |
44 #include "cfgloop.h" | 42 #include "cfgloop.h" |
45 #include "cfglayout.h" | 43 #include "cfglayout.h" |
46 #include "tree-ssa-propagate.h" | 44 #include "tree-ssa-propagate.h" |
47 #include "value-prof.h" | 45 #include "value-prof.h" |
229 { | 227 { |
230 gimple_cfg2vcg (vcg_file); | 228 gimple_cfg2vcg (vcg_file); |
231 dump_end (TDI_vcg, vcg_file); | 229 dump_end (TDI_vcg, vcg_file); |
232 } | 230 } |
233 } | 231 } |
234 | |
235 #ifdef ENABLE_CHECKING | |
236 verify_stmts (); | |
237 #endif | |
238 } | 232 } |
239 | 233 |
240 static unsigned int | 234 static unsigned int |
241 execute_build_cfg (void) | 235 execute_build_cfg (void) |
242 { | 236 { |
436 basic_block bb; | 430 basic_block bb; |
437 | 431 |
438 gcc_assert (!e); | 432 gcc_assert (!e); |
439 | 433 |
440 /* Create and initialize a new basic block. Since alloc_block uses | 434 /* Create and initialize a new basic block. Since alloc_block uses |
441 ggc_alloc_cleared to allocate a basic block, we do not have to | 435 GC allocation that clears memory to allocate a basic block, we do |
442 clear the newly allocated basic block here. */ | 436 not have to clear the newly allocated basic block here. */ |
443 bb = alloc_block (); | 437 bb = alloc_block (); |
444 | 438 |
445 bb->index = last_basic_block; | 439 bb->index = last_basic_block; |
446 bb->flags = BB_NEW; | 440 bb->flags = BB_NEW; |
447 bb->il.gimple = GGC_CNEW (struct gimple_bb_info); | 441 bb->il.gimple = ggc_alloc_cleared_gimple_bb_info (); |
448 set_bb_seq (bb, h ? (gimple_seq) h : gimple_seq_alloc ()); | 442 set_bb_seq (bb, h ? (gimple_seq) h : gimple_seq_alloc ()); |
449 | 443 |
450 /* Add the new block to the linked list of blocks. */ | 444 /* Add the new block to the linked list of blocks. */ |
451 link_block (bb, after); | 445 link_block (bb, after); |
452 | 446 |
566 | 560 |
567 /* If this statement has reachable exception handlers, then | 561 /* If this statement has reachable exception handlers, then |
568 create abnormal edges to them. */ | 562 create abnormal edges to them. */ |
569 make_eh_edges (last); | 563 make_eh_edges (last); |
570 | 564 |
565 /* BUILTIN_RETURN is really a return statement. */ | |
566 if (gimple_call_builtin_p (last, BUILT_IN_RETURN)) | |
567 make_edge (bb, EXIT_BLOCK_PTR, 0), fallthru = false; | |
571 /* Some calls are known not to return. */ | 568 /* Some calls are known not to return. */ |
572 fallthru = !(gimple_call_flags (last) & ECF_NORETURN); | 569 else |
570 fallthru = !(gimple_call_flags (last) & ECF_NORETURN); | |
573 break; | 571 break; |
574 | 572 |
575 case GIMPLE_ASSIGN: | 573 case GIMPLE_ASSIGN: |
576 /* A GIMPLE_ASSIGN may throw internally and thus be considered | 574 /* A GIMPLE_ASSIGN may throw internally and thus be considered |
577 control-altering. */ | 575 control-altering. */ |
962 int uid = LABEL_DECL_UID (dest); | 960 int uid = LABEL_DECL_UID (dest); |
963 | 961 |
964 /* We would die hard when faced by an undefined label. Emit a label to | 962 /* We would die hard when faced by an undefined label. Emit a label to |
965 the very first basic block. This will hopefully make even the dataflow | 963 the very first basic block. This will hopefully make even the dataflow |
966 and undefined variable warnings quite right. */ | 964 and undefined variable warnings quite right. */ |
967 if ((errorcount || sorrycount) && uid < 0) | 965 if (seen_error () && uid < 0) |
968 { | 966 { |
969 gimple_stmt_iterator gsi = gsi_start_bb (BASIC_BLOCK (NUM_FIXED_BLOCKS)); | 967 gimple_stmt_iterator gsi = gsi_start_bb (BASIC_BLOCK (NUM_FIXED_BLOCKS)); |
970 gimple stmt; | 968 gimple stmt; |
971 | 969 |
972 stmt = gimple_build_label (dest); | 970 stmt = gimple_build_label (dest); |
1471 phis = phi_nodes (b); | 1469 phis = phi_nodes (b); |
1472 if (!gimple_seq_empty_p (phis) | 1470 if (!gimple_seq_empty_p (phis) |
1473 && name_mappings_registered_p ()) | 1471 && name_mappings_registered_p ()) |
1474 return false; | 1472 return false; |
1475 | 1473 |
1474 /* When not optimizing, don't merge if we'd lose goto_locus. */ | |
1475 if (!optimize | |
1476 && single_succ_edge (a)->goto_locus != UNKNOWN_LOCATION) | |
1477 { | |
1478 location_t goto_locus = single_succ_edge (a)->goto_locus; | |
1479 gimple_stmt_iterator prev, next; | |
1480 prev = gsi_last_nondebug_bb (a); | |
1481 next = gsi_after_labels (b); | |
1482 if (!gsi_end_p (next) && is_gimple_debug (gsi_stmt (next))) | |
1483 gsi_next_nondebug (&next); | |
1484 if ((gsi_end_p (prev) | |
1485 || gimple_location (gsi_stmt (prev)) != goto_locus) | |
1486 && (gsi_end_p (next) | |
1487 || gimple_location (gsi_stmt (next)) != goto_locus)) | |
1488 return false; | |
1489 } | |
1490 | |
1476 return true; | 1491 return true; |
1477 } | 1492 } |
1478 | 1493 |
1479 /* Return true if the var whose chain of uses starts at PTR has no | 1494 /* Return true if the var whose chain of uses starts at PTR has no |
1480 nondebug uses. */ | 1495 nondebug uses. */ |
1552 if (gimple_code (stmt) != GIMPLE_PHI) | 1567 if (gimple_code (stmt) != GIMPLE_PHI) |
1553 { | 1568 { |
1554 size_t i; | 1569 size_t i; |
1555 | 1570 |
1556 fold_stmt_inplace (stmt); | 1571 fold_stmt_inplace (stmt); |
1557 if (cfgcleanup_altered_bbs) | 1572 if (cfgcleanup_altered_bbs && !is_gimple_debug (stmt)) |
1558 bitmap_set_bit (cfgcleanup_altered_bbs, gimple_bb (stmt)->index); | 1573 bitmap_set_bit (cfgcleanup_altered_bbs, gimple_bb (stmt)->index); |
1559 | 1574 |
1560 /* FIXME. This should go in update_stmt. */ | 1575 /* FIXME. This should go in update_stmt. */ |
1561 for (i = 0; i < gimple_num_ops (stmt); i++) | 1576 for (i = 0; i < gimple_num_ops (stmt); i++) |
1562 { | 1577 { |
2108 | 2123 |
2109 | 2124 |
2110 /* Dump CFG statistics on stderr. Keep extern so that it's always | 2125 /* Dump CFG statistics on stderr. Keep extern so that it's always |
2111 linked in the final executable. */ | 2126 linked in the final executable. */ |
2112 | 2127 |
2113 void | 2128 DEBUG_FUNCTION void |
2114 debug_cfg_stats (void) | 2129 debug_cfg_stats (void) |
2115 { | 2130 { |
2116 dump_cfg_stats (stderr); | 2131 dump_cfg_stats (stderr); |
2117 } | 2132 } |
2118 | 2133 |
2240 { | 2255 { |
2241 int flags = gimple_call_flags (t); | 2256 int flags = gimple_call_flags (t); |
2242 | 2257 |
2243 /* A non-pure/const call alters flow control if the current | 2258 /* A non-pure/const call alters flow control if the current |
2244 function has nonlocal labels. */ | 2259 function has nonlocal labels. */ |
2245 if (!(flags & (ECF_CONST | ECF_PURE)) && cfun->has_nonlocal_label) | 2260 if (!(flags & (ECF_CONST | ECF_PURE | ECF_LEAF)) |
2261 && cfun->has_nonlocal_label) | |
2246 return true; | 2262 return true; |
2247 | 2263 |
2248 /* A call also alters control flow if it does not return. */ | 2264 /* A call also alters control flow if it does not return. */ |
2249 if (flags & ECF_NORETURN) | 2265 if (flags & ECF_NORETURN) |
2266 return true; | |
2267 | |
2268 /* BUILT_IN_RETURN call is same as return statement. */ | |
2269 if (gimple_call_builtin_p (t, BUILT_IN_RETURN)) | |
2250 return true; | 2270 return true; |
2251 } | 2271 } |
2252 break; | 2272 break; |
2253 | 2273 |
2254 case GIMPLE_EH_DISPATCH: | 2274 case GIMPLE_EH_DISPATCH: |
2292 stmt_can_make_abnormal_goto (gimple t) | 2312 stmt_can_make_abnormal_goto (gimple t) |
2293 { | 2313 { |
2294 if (computed_goto_p (t)) | 2314 if (computed_goto_p (t)) |
2295 return true; | 2315 return true; |
2296 if (is_gimple_call (t)) | 2316 if (is_gimple_call (t)) |
2297 return gimple_has_side_effects (t) && cfun->has_nonlocal_label; | 2317 return (gimple_has_side_effects (t) && cfun->has_nonlocal_label |
2318 && !(gimple_call_flags (t) & ECF_LEAF)); | |
2298 return false; | 2319 return false; |
2299 } | 2320 } |
2300 | 2321 |
2301 | 2322 |
2302 /* Return true if STMT should start a new basic block. PREV_STMT is | 2323 /* Return true if STMT should start a new basic block. PREV_STMT is |
2508 reinstall_phi_args (new_edge, e); | 2529 reinstall_phi_args (new_edge, e); |
2509 | 2530 |
2510 return new_bb; | 2531 return new_bb; |
2511 } | 2532 } |
2512 | 2533 |
2534 | |
2535 /* Verify properties of the address expression T with base object BASE. */ | |
2536 | |
2537 static tree | |
2538 verify_address (tree t, tree base) | |
2539 { | |
2540 bool old_constant; | |
2541 bool old_side_effects; | |
2542 bool new_constant; | |
2543 bool new_side_effects; | |
2544 | |
2545 old_constant = TREE_CONSTANT (t); | |
2546 old_side_effects = TREE_SIDE_EFFECTS (t); | |
2547 | |
2548 recompute_tree_invariant_for_addr_expr (t); | |
2549 new_side_effects = TREE_SIDE_EFFECTS (t); | |
2550 new_constant = TREE_CONSTANT (t); | |
2551 | |
2552 if (old_constant != new_constant) | |
2553 { | |
2554 error ("constant not recomputed when ADDR_EXPR changed"); | |
2555 return t; | |
2556 } | |
2557 if (old_side_effects != new_side_effects) | |
2558 { | |
2559 error ("side effects not recomputed when ADDR_EXPR changed"); | |
2560 return t; | |
2561 } | |
2562 | |
2563 if (!(TREE_CODE (base) == VAR_DECL | |
2564 || TREE_CODE (base) == PARM_DECL | |
2565 || TREE_CODE (base) == RESULT_DECL)) | |
2566 return NULL_TREE; | |
2567 | |
2568 if (DECL_GIMPLE_REG_P (base)) | |
2569 { | |
2570 error ("DECL_GIMPLE_REG_P set on a variable with address taken"); | |
2571 return base; | |
2572 } | |
2573 | |
2574 return NULL_TREE; | |
2575 } | |
2576 | |
2513 /* Callback for walk_tree, check that all elements with address taken are | 2577 /* Callback for walk_tree, check that all elements with address taken are |
2514 properly noticed as such. The DATA is an int* that is 1 if TP was seen | 2578 properly noticed as such. The DATA is an int* that is 1 if TP was seen |
2515 inside a PHI node. */ | 2579 inside a PHI node. */ |
2516 | 2580 |
2517 static tree | 2581 static tree |
2536 return *tp; | 2600 return *tp; |
2537 } | 2601 } |
2538 break; | 2602 break; |
2539 | 2603 |
2540 case INDIRECT_REF: | 2604 case INDIRECT_REF: |
2605 error ("INDIRECT_REF in gimple IL"); | |
2606 return t; | |
2607 | |
2608 case MEM_REF: | |
2541 x = TREE_OPERAND (t, 0); | 2609 x = TREE_OPERAND (t, 0); |
2542 if (!is_gimple_reg (x) && !is_gimple_min_invariant (x)) | 2610 if (!POINTER_TYPE_P (TREE_TYPE (x)) |
2543 { | 2611 || !is_gimple_mem_ref_addr (x)) |
2544 error ("Indirect reference's operand is not a register or a constant."); | 2612 { |
2613 error ("invalid first operand of MEM_REF"); | |
2545 return x; | 2614 return x; |
2546 } | 2615 } |
2616 if (TREE_CODE (TREE_OPERAND (t, 1)) != INTEGER_CST | |
2617 || !POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 1)))) | |
2618 { | |
2619 error ("invalid offset operand of MEM_REF"); | |
2620 return TREE_OPERAND (t, 1); | |
2621 } | |
2622 if (TREE_CODE (x) == ADDR_EXPR | |
2623 && (x = verify_address (x, TREE_OPERAND (x, 0)))) | |
2624 return x; | |
2625 *walk_subtrees = 0; | |
2547 break; | 2626 break; |
2548 | 2627 |
2549 case ASSERT_EXPR: | 2628 case ASSERT_EXPR: |
2550 x = fold (ASSERT_EXPR_COND (t)); | 2629 x = fold (ASSERT_EXPR_COND (t)); |
2551 if (x == boolean_false_node) | 2630 if (x == boolean_false_node) |
2554 return *tp; | 2633 return *tp; |
2555 } | 2634 } |
2556 break; | 2635 break; |
2557 | 2636 |
2558 case MODIFY_EXPR: | 2637 case MODIFY_EXPR: |
2559 error ("MODIFY_EXPR not expected while having tuples."); | 2638 error ("MODIFY_EXPR not expected while having tuples"); |
2560 return *tp; | 2639 return *tp; |
2561 | 2640 |
2562 case ADDR_EXPR: | 2641 case ADDR_EXPR: |
2563 { | 2642 { |
2564 bool old_constant; | 2643 tree tem; |
2565 bool old_side_effects; | |
2566 bool new_constant; | |
2567 bool new_side_effects; | |
2568 | 2644 |
2569 gcc_assert (is_gimple_address (t)); | 2645 gcc_assert (is_gimple_address (t)); |
2570 | |
2571 old_constant = TREE_CONSTANT (t); | |
2572 old_side_effects = TREE_SIDE_EFFECTS (t); | |
2573 | |
2574 recompute_tree_invariant_for_addr_expr (t); | |
2575 new_side_effects = TREE_SIDE_EFFECTS (t); | |
2576 new_constant = TREE_CONSTANT (t); | |
2577 | |
2578 if (old_constant != new_constant) | |
2579 { | |
2580 error ("constant not recomputed when ADDR_EXPR changed"); | |
2581 return t; | |
2582 } | |
2583 if (old_side_effects != new_side_effects) | |
2584 { | |
2585 error ("side effects not recomputed when ADDR_EXPR changed"); | |
2586 return t; | |
2587 } | |
2588 | 2646 |
2589 /* Skip any references (they will be checked when we recurse down the | 2647 /* Skip any references (they will be checked when we recurse down the |
2590 tree) and ensure that any variable used as a prefix is marked | 2648 tree) and ensure that any variable used as a prefix is marked |
2591 addressable. */ | 2649 addressable. */ |
2592 for (x = TREE_OPERAND (t, 0); | 2650 for (x = TREE_OPERAND (t, 0); |
2593 handled_component_p (x); | 2651 handled_component_p (x); |
2594 x = TREE_OPERAND (x, 0)) | 2652 x = TREE_OPERAND (x, 0)) |
2595 ; | 2653 ; |
2596 | 2654 |
2655 if ((tem = verify_address (t, x))) | |
2656 return tem; | |
2657 | |
2597 if (!(TREE_CODE (x) == VAR_DECL | 2658 if (!(TREE_CODE (x) == VAR_DECL |
2598 || TREE_CODE (x) == PARM_DECL | 2659 || TREE_CODE (x) == PARM_DECL |
2599 || TREE_CODE (x) == RESULT_DECL)) | 2660 || TREE_CODE (x) == RESULT_DECL)) |
2600 return NULL; | 2661 return NULL; |
2662 | |
2601 if (!TREE_ADDRESSABLE (x)) | 2663 if (!TREE_ADDRESSABLE (x)) |
2602 { | 2664 { |
2603 error ("address taken, but ADDRESSABLE bit not set"); | 2665 error ("address taken, but ADDRESSABLE bit not set"); |
2604 return x; | |
2605 } | |
2606 if (DECL_GIMPLE_REG_P (x)) | |
2607 { | |
2608 error ("DECL_GIMPLE_REG_P set on a variable with address taken"); | |
2609 return x; | 2666 return x; |
2610 } | 2667 } |
2611 | 2668 |
2612 break; | 2669 break; |
2613 } | 2670 } |
2723 sizetype. */ | 2780 sizetype. */ |
2724 if (!useless_type_conversion_p (sizetype, | 2781 if (!useless_type_conversion_p (sizetype, |
2725 TREE_TYPE (TREE_OPERAND (t, 1)))) | 2782 TREE_TYPE (TREE_OPERAND (t, 1)))) |
2726 { | 2783 { |
2727 error ("invalid operand to pointer plus, second operand is not an " | 2784 error ("invalid operand to pointer plus, second operand is not an " |
2728 "integer with type of sizetype."); | 2785 "integer with type of sizetype"); |
2729 return t; | 2786 return t; |
2730 } | 2787 } |
2731 /* FALLTHROUGH */ | 2788 /* FALLTHROUGH */ |
2732 case LT_EXPR: | 2789 case LT_EXPR: |
2733 case LE_EXPR: | 2790 case LE_EXPR: |
2790 tree op; | 2847 tree op; |
2791 | 2848 |
2792 if (is_gimple_id (expr)) | 2849 if (is_gimple_id (expr)) |
2793 return false; | 2850 return false; |
2794 | 2851 |
2795 if (!INDIRECT_REF_P (expr) | 2852 if (TREE_CODE (expr) != TARGET_MEM_REF |
2796 && TREE_CODE (expr) != TARGET_MEM_REF) | 2853 && TREE_CODE (expr) != MEM_REF) |
2797 { | 2854 { |
2798 error ("invalid expression for min lvalue"); | 2855 error ("invalid expression for min lvalue"); |
2799 return true; | 2856 return true; |
2800 } | 2857 } |
2801 | 2858 |
2808 { | 2865 { |
2809 error ("invalid operand in indirect reference"); | 2866 error ("invalid operand in indirect reference"); |
2810 debug_generic_stmt (op); | 2867 debug_generic_stmt (op); |
2811 return true; | 2868 return true; |
2812 } | 2869 } |
2813 if (!useless_type_conversion_p (TREE_TYPE (expr), | 2870 /* Memory references now generally can involve a value conversion. */ |
2814 TREE_TYPE (TREE_TYPE (op)))) | |
2815 { | |
2816 error ("type mismatch in indirect reference"); | |
2817 debug_generic_stmt (TREE_TYPE (expr)); | |
2818 debug_generic_stmt (TREE_TYPE (TREE_TYPE (op))); | |
2819 return true; | |
2820 } | |
2821 | 2871 |
2822 return false; | 2872 return false; |
2823 } | 2873 } |
2824 | 2874 |
2825 /* Verify if EXPR is a valid GIMPLE reference expression. If | 2875 /* Verify if EXPR is a valid GIMPLE reference expression. If |
2898 most invoke undefined behavior. */ | 2948 most invoke undefined behavior. */ |
2899 if (require_lvalue | 2949 if (require_lvalue |
2900 && (TREE_CODE (op) == SSA_NAME | 2950 && (TREE_CODE (op) == SSA_NAME |
2901 || is_gimple_min_invariant (op))) | 2951 || is_gimple_min_invariant (op))) |
2902 { | 2952 { |
2903 error ("Conversion of an SSA_NAME on the left hand side."); | 2953 error ("conversion of an SSA_NAME on the left hand side"); |
2954 debug_generic_stmt (expr); | |
2955 return true; | |
2956 } | |
2957 else if (TREE_CODE (op) == SSA_NAME | |
2958 && TYPE_SIZE (TREE_TYPE (expr)) != TYPE_SIZE (TREE_TYPE (op))) | |
2959 { | |
2960 error ("conversion of register to a different size"); | |
2904 debug_generic_stmt (expr); | 2961 debug_generic_stmt (expr); |
2905 return true; | 2962 return true; |
2906 } | 2963 } |
2907 else if (!handled_component_p (op)) | 2964 else if (!handled_component_p (op)) |
2908 return false; | 2965 return false; |
2909 } | 2966 } |
2910 | 2967 |
2911 expr = op; | 2968 expr = op; |
2969 } | |
2970 | |
2971 if (TREE_CODE (expr) == MEM_REF) | |
2972 { | |
2973 if (!is_gimple_mem_ref_addr (TREE_OPERAND (expr, 0))) | |
2974 { | |
2975 error ("invalid address operand in MEM_REF"); | |
2976 debug_generic_stmt (expr); | |
2977 return true; | |
2978 } | |
2979 if (TREE_CODE (TREE_OPERAND (expr, 1)) != INTEGER_CST | |
2980 || !POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (expr, 1)))) | |
2981 { | |
2982 error ("invalid offset operand in MEM_REF"); | |
2983 debug_generic_stmt (expr); | |
2984 return true; | |
2985 } | |
2986 } | |
2987 else if (TREE_CODE (expr) == TARGET_MEM_REF) | |
2988 { | |
2989 if (!TMR_BASE (expr) | |
2990 || !is_gimple_mem_ref_addr (TMR_BASE (expr))) | |
2991 { | |
2992 error ("invalid address operand in in TARGET_MEM_REF"); | |
2993 return true; | |
2994 } | |
2995 if (!TMR_OFFSET (expr) | |
2996 || TREE_CODE (TMR_OFFSET (expr)) != INTEGER_CST | |
2997 || !POINTER_TYPE_P (TREE_TYPE (TMR_OFFSET (expr)))) | |
2998 { | |
2999 error ("invalid offset operand in TARGET_MEM_REF"); | |
3000 debug_generic_stmt (expr); | |
3001 return true; | |
3002 } | |
2912 } | 3003 } |
2913 | 3004 |
2914 return ((require_lvalue || !is_gimple_min_invariant (expr)) | 3005 return ((require_lvalue || !is_gimple_min_invariant (expr)) |
2915 && verify_types_in_gimple_min_lval (expr)); | 3006 && verify_types_in_gimple_min_lval (expr)); |
2916 } | 3007 } |
3013 | 3104 |
3014 /* If there is a static chain argument, this should not be an indirect | 3105 /* If there is a static chain argument, this should not be an indirect |
3015 call, and the decl should have DECL_STATIC_CHAIN set. */ | 3106 call, and the decl should have DECL_STATIC_CHAIN set. */ |
3016 if (gimple_call_chain (stmt)) | 3107 if (gimple_call_chain (stmt)) |
3017 { | 3108 { |
3018 if (TREE_CODE (fn) != ADDR_EXPR | 3109 if (!gimple_call_fndecl (stmt)) |
3019 || TREE_CODE (TREE_OPERAND (fn, 0)) != FUNCTION_DECL) | |
3020 { | 3110 { |
3021 error ("static chain in indirect gimple call"); | 3111 error ("static chain in indirect gimple call"); |
3022 return true; | 3112 return true; |
3023 } | 3113 } |
3024 fn = TREE_OPERAND (fn, 0); | 3114 fn = TREE_OPERAND (fn, 0); |
3025 | 3115 |
3026 if (!DECL_STATIC_CHAIN (fn)) | 3116 if (!DECL_STATIC_CHAIN (fn)) |
3027 { | 3117 { |
3028 error ("static chain with function that doesn't use one"); | 3118 error ("static chain with function that doesn%'t use one"); |
3029 return true; | 3119 return true; |
3030 } | 3120 } |
3031 } | 3121 } |
3032 | 3122 |
3033 /* ??? The C frontend passes unpromoted arguments in case it | 3123 /* ??? The C frontend passes unpromoted arguments in case it |
3036 unit-at-a-time we have a chance to fix this. */ | 3126 unit-at-a-time we have a chance to fix this. */ |
3037 | 3127 |
3038 for (i = 0; i < gimple_call_num_args (stmt); ++i) | 3128 for (i = 0; i < gimple_call_num_args (stmt); ++i) |
3039 { | 3129 { |
3040 tree arg = gimple_call_arg (stmt, i); | 3130 tree arg = gimple_call_arg (stmt, i); |
3041 if (!is_gimple_operand (arg)) | 3131 if ((is_gimple_reg_type (TREE_TYPE (arg)) |
3132 && !is_gimple_val (arg)) | |
3133 || (!is_gimple_reg_type (TREE_TYPE (arg)) | |
3134 && !is_gimple_lvalue (arg))) | |
3042 { | 3135 { |
3043 error ("invalid argument to gimple call"); | 3136 error ("invalid argument to gimple call"); |
3044 debug_generic_expr (arg); | 3137 debug_generic_expr (arg); |
3138 return true; | |
3045 } | 3139 } |
3046 } | 3140 } |
3047 | 3141 |
3048 return false; | 3142 return false; |
3049 } | 3143 } |
3325 case VEC_LSHIFT_EXPR: | 3419 case VEC_LSHIFT_EXPR: |
3326 case VEC_RSHIFT_EXPR: | 3420 case VEC_RSHIFT_EXPR: |
3327 { | 3421 { |
3328 if (TREE_CODE (rhs1_type) != VECTOR_TYPE | 3422 if (TREE_CODE (rhs1_type) != VECTOR_TYPE |
3329 || !(INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type)) | 3423 || !(INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type)) |
3424 || POINTER_TYPE_P (TREE_TYPE (rhs1_type)) | |
3330 || FIXED_POINT_TYPE_P (TREE_TYPE (rhs1_type)) | 3425 || FIXED_POINT_TYPE_P (TREE_TYPE (rhs1_type)) |
3331 || SCALAR_FLOAT_TYPE_P (TREE_TYPE (rhs1_type))) | 3426 || SCALAR_FLOAT_TYPE_P (TREE_TYPE (rhs1_type))) |
3332 || (!INTEGRAL_TYPE_P (rhs2_type) | 3427 || (!INTEGRAL_TYPE_P (rhs2_type) |
3333 && (TREE_CODE (rhs2_type) != VECTOR_TYPE | 3428 && (TREE_CODE (rhs2_type) != VECTOR_TYPE |
3334 || !INTEGRAL_TYPE_P (TREE_TYPE (rhs2_type)))) | 3429 || !INTEGRAL_TYPE_P (TREE_TYPE (rhs2_type)))) |
3338 debug_generic_expr (lhs_type); | 3433 debug_generic_expr (lhs_type); |
3339 debug_generic_expr (rhs1_type); | 3434 debug_generic_expr (rhs1_type); |
3340 debug_generic_expr (rhs2_type); | 3435 debug_generic_expr (rhs2_type); |
3341 return true; | 3436 return true; |
3342 } | 3437 } |
3343 /* For shifting a vector of floating point components we | 3438 /* For shifting a vector of non-integral components we |
3344 only allow shifting by a constant multiple of the element size. */ | 3439 only allow shifting by a constant multiple of the element size. */ |
3345 if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (rhs1_type)) | 3440 if (!INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type)) |
3346 && (TREE_CODE (rhs2) != INTEGER_CST | 3441 && (TREE_CODE (rhs2) != INTEGER_CST |
3347 || !div_if_zero_remainder (EXACT_DIV_EXPR, rhs2, | 3442 || !div_if_zero_remainder (EXACT_DIV_EXPR, rhs2, |
3348 TYPE_SIZE (TREE_TYPE (rhs1_type))))) | 3443 TYPE_SIZE (TREE_TYPE (rhs1_type))))) |
3349 { | 3444 { |
3350 error ("non-element sized vector shift of floating point vector"); | 3445 error ("non-element sized vector shift of floating point vector"); |
3353 | 3448 |
3354 return false; | 3449 return false; |
3355 } | 3450 } |
3356 | 3451 |
3357 case PLUS_EXPR: | 3452 case PLUS_EXPR: |
3453 case MINUS_EXPR: | |
3358 { | 3454 { |
3359 /* We use regular PLUS_EXPR for vectors. | 3455 /* We use regular PLUS_EXPR and MINUS_EXPR for vectors. |
3360 ??? This just makes the checker happy and may not be what is | 3456 ??? This just makes the checker happy and may not be what is |
3361 intended. */ | 3457 intended. */ |
3362 if (TREE_CODE (lhs_type) == VECTOR_TYPE | 3458 if (TREE_CODE (lhs_type) == VECTOR_TYPE |
3363 && POINTER_TYPE_P (TREE_TYPE (lhs_type))) | 3459 && POINTER_TYPE_P (TREE_TYPE (lhs_type))) |
3364 { | 3460 { |
3379 rhs1_type = rhs2_type; | 3475 rhs1_type = rhs2_type; |
3380 rhs2_type = tem; | 3476 rhs2_type = tem; |
3381 } | 3477 } |
3382 goto do_pointer_plus_expr_check; | 3478 goto do_pointer_plus_expr_check; |
3383 } | 3479 } |
3384 } | |
3385 /* Fallthru. */ | |
3386 case MINUS_EXPR: | |
3387 { | |
3388 if (POINTER_TYPE_P (lhs_type) | 3480 if (POINTER_TYPE_P (lhs_type) |
3389 || POINTER_TYPE_P (rhs1_type) | 3481 || POINTER_TYPE_P (rhs1_type) |
3390 || POINTER_TYPE_P (rhs2_type)) | 3482 || POINTER_TYPE_P (rhs2_type)) |
3391 { | 3483 { |
3392 error ("invalid (pointer) operands to plus/minus"); | 3484 error ("invalid (pointer) operands to plus/minus"); |
3508 } | 3600 } |
3509 | 3601 |
3510 return false; | 3602 return false; |
3511 } | 3603 } |
3512 | 3604 |
3605 /* Verify a gimple assignment statement STMT with a ternary rhs. | |
3606 Returns true if anything is wrong. */ | |
3607 | |
3608 static bool | |
3609 verify_gimple_assign_ternary (gimple stmt) | |
3610 { | |
3611 enum tree_code rhs_code = gimple_assign_rhs_code (stmt); | |
3612 tree lhs = gimple_assign_lhs (stmt); | |
3613 tree lhs_type = TREE_TYPE (lhs); | |
3614 tree rhs1 = gimple_assign_rhs1 (stmt); | |
3615 tree rhs1_type = TREE_TYPE (rhs1); | |
3616 tree rhs2 = gimple_assign_rhs2 (stmt); | |
3617 tree rhs2_type = TREE_TYPE (rhs2); | |
3618 tree rhs3 = gimple_assign_rhs3 (stmt); | |
3619 tree rhs3_type = TREE_TYPE (rhs3); | |
3620 | |
3621 if (!is_gimple_reg (lhs) | |
3622 && !(optimize == 0 | |
3623 && TREE_CODE (lhs_type) == COMPLEX_TYPE)) | |
3624 { | |
3625 error ("non-register as LHS of ternary operation"); | |
3626 return true; | |
3627 } | |
3628 | |
3629 if (!is_gimple_val (rhs1) | |
3630 || !is_gimple_val (rhs2) | |
3631 || !is_gimple_val (rhs3)) | |
3632 { | |
3633 error ("invalid operands in ternary operation"); | |
3634 return true; | |
3635 } | |
3636 | |
3637 /* First handle operations that involve different types. */ | |
3638 switch (rhs_code) | |
3639 { | |
3640 case WIDEN_MULT_PLUS_EXPR: | |
3641 case WIDEN_MULT_MINUS_EXPR: | |
3642 if ((!INTEGRAL_TYPE_P (rhs1_type) | |
3643 && !FIXED_POINT_TYPE_P (rhs1_type)) | |
3644 || !useless_type_conversion_p (rhs1_type, rhs2_type) | |
3645 || !useless_type_conversion_p (lhs_type, rhs3_type) | |
3646 || 2 * TYPE_PRECISION (rhs1_type) != TYPE_PRECISION (lhs_type) | |
3647 || TYPE_PRECISION (rhs1_type) != TYPE_PRECISION (rhs2_type)) | |
3648 { | |
3649 error ("type mismatch in widening multiply-accumulate expression"); | |
3650 debug_generic_expr (lhs_type); | |
3651 debug_generic_expr (rhs1_type); | |
3652 debug_generic_expr (rhs2_type); | |
3653 debug_generic_expr (rhs3_type); | |
3654 return true; | |
3655 } | |
3656 break; | |
3657 | |
3658 case FMA_EXPR: | |
3659 if (!useless_type_conversion_p (lhs_type, rhs1_type) | |
3660 || !useless_type_conversion_p (lhs_type, rhs2_type) | |
3661 || !useless_type_conversion_p (lhs_type, rhs3_type)) | |
3662 { | |
3663 error ("type mismatch in fused multiply-add expression"); | |
3664 debug_generic_expr (lhs_type); | |
3665 debug_generic_expr (rhs1_type); | |
3666 debug_generic_expr (rhs2_type); | |
3667 debug_generic_expr (rhs3_type); | |
3668 return true; | |
3669 } | |
3670 break; | |
3671 | |
3672 default: | |
3673 gcc_unreachable (); | |
3674 } | |
3675 return false; | |
3676 } | |
3677 | |
3513 /* Verify a gimple assignment statement STMT with a single rhs. | 3678 /* Verify a gimple assignment statement STMT with a single rhs. |
3514 Returns true if anything is wrong. */ | 3679 Returns true if anything is wrong. */ |
3515 | 3680 |
3516 static bool | 3681 static bool |
3517 verify_gimple_assign_single (gimple stmt) | 3682 verify_gimple_assign_single (gimple stmt) |
3544 { | 3709 { |
3545 error ("invalid operand in unary expression"); | 3710 error ("invalid operand in unary expression"); |
3546 return true; | 3711 return true; |
3547 } | 3712 } |
3548 | 3713 |
3549 if (!types_compatible_p (TREE_TYPE (op), TREE_TYPE (TREE_TYPE (rhs1))) | 3714 /* Technically there is no longer a need for matching types, but |
3715 gimple hygiene asks for this check. In LTO we can end up | |
3716 combining incompatible units and thus end up with addresses | |
3717 of globals that change their type to a common one. */ | |
3718 if (!in_lto_p | |
3719 && !types_compatible_p (TREE_TYPE (op), | |
3720 TREE_TYPE (TREE_TYPE (rhs1))) | |
3550 && !one_pointer_to_useless_type_conversion_p (TREE_TYPE (rhs1), | 3721 && !one_pointer_to_useless_type_conversion_p (TREE_TYPE (rhs1), |
3551 TREE_TYPE (op))) | 3722 TREE_TYPE (op))) |
3552 { | 3723 { |
3553 error ("type mismatch in address expression"); | 3724 error ("type mismatch in address expression"); |
3554 debug_generic_stmt (TREE_TYPE (rhs1)); | 3725 debug_generic_stmt (TREE_TYPE (rhs1)); |
3558 | 3729 |
3559 return verify_types_in_gimple_reference (op, true); | 3730 return verify_types_in_gimple_reference (op, true); |
3560 } | 3731 } |
3561 | 3732 |
3562 /* tcc_reference */ | 3733 /* tcc_reference */ |
3734 case INDIRECT_REF: | |
3735 error ("INDIRECT_REF in gimple IL"); | |
3736 return true; | |
3737 | |
3563 case COMPONENT_REF: | 3738 case COMPONENT_REF: |
3564 case BIT_FIELD_REF: | 3739 case BIT_FIELD_REF: |
3565 case INDIRECT_REF: | |
3566 case ALIGN_INDIRECT_REF: | |
3567 case MISALIGNED_INDIRECT_REF: | |
3568 case ARRAY_REF: | 3740 case ARRAY_REF: |
3569 case ARRAY_RANGE_REF: | 3741 case ARRAY_RANGE_REF: |
3570 case VIEW_CONVERT_EXPR: | 3742 case VIEW_CONVERT_EXPR: |
3571 case REALPART_EXPR: | 3743 case REALPART_EXPR: |
3572 case IMAGPART_EXPR: | 3744 case IMAGPART_EXPR: |
3573 case TARGET_MEM_REF: | 3745 case TARGET_MEM_REF: |
3746 case MEM_REF: | |
3574 if (!is_gimple_reg (lhs) | 3747 if (!is_gimple_reg (lhs) |
3575 && is_gimple_reg_type (TREE_TYPE (lhs))) | 3748 && is_gimple_reg_type (TREE_TYPE (lhs))) |
3576 { | 3749 { |
3577 error ("invalid rhs for gimple memory store"); | 3750 error ("invalid rhs for gimple memory store"); |
3578 debug_generic_stmt (lhs); | 3751 debug_generic_stmt (lhs); |
3606 return true; | 3779 return true; |
3607 } | 3780 } |
3608 return res; | 3781 return res; |
3609 | 3782 |
3610 case COND_EXPR: | 3783 case COND_EXPR: |
3784 if (!is_gimple_reg (lhs) | |
3785 || (!is_gimple_reg (TREE_OPERAND (rhs1, 0)) | |
3786 && !COMPARISON_CLASS_P (TREE_OPERAND (rhs1, 0))) | |
3787 || (!is_gimple_reg (TREE_OPERAND (rhs1, 1)) | |
3788 && !is_gimple_min_invariant (TREE_OPERAND (rhs1, 1))) | |
3789 || (!is_gimple_reg (TREE_OPERAND (rhs1, 2)) | |
3790 && !is_gimple_min_invariant (TREE_OPERAND (rhs1, 2)))) | |
3791 { | |
3792 error ("invalid COND_EXPR in gimple assignment"); | |
3793 debug_generic_stmt (rhs1); | |
3794 return true; | |
3795 } | |
3796 return res; | |
3797 | |
3611 case CONSTRUCTOR: | 3798 case CONSTRUCTOR: |
3612 case OBJ_TYPE_REF: | 3799 case OBJ_TYPE_REF: |
3613 case ASSERT_EXPR: | 3800 case ASSERT_EXPR: |
3614 case WITH_SIZE_EXPR: | 3801 case WITH_SIZE_EXPR: |
3615 case POLYNOMIAL_CHREC: | 3802 case POLYNOMIAL_CHREC: |
3640 return verify_gimple_assign_unary (stmt); | 3827 return verify_gimple_assign_unary (stmt); |
3641 | 3828 |
3642 case GIMPLE_BINARY_RHS: | 3829 case GIMPLE_BINARY_RHS: |
3643 return verify_gimple_assign_binary (stmt); | 3830 return verify_gimple_assign_binary (stmt); |
3644 | 3831 |
3832 case GIMPLE_TERNARY_RHS: | |
3833 return verify_gimple_assign_ternary (stmt); | |
3834 | |
3645 default: | 3835 default: |
3646 gcc_unreachable (); | 3836 gcc_unreachable (); |
3647 } | 3837 } |
3648 } | 3838 } |
3649 | 3839 |
3667 error ("invalid operand in return statement"); | 3857 error ("invalid operand in return statement"); |
3668 debug_generic_stmt (op); | 3858 debug_generic_stmt (op); |
3669 return true; | 3859 return true; |
3670 } | 3860 } |
3671 | 3861 |
3672 if (!useless_type_conversion_p (restype, TREE_TYPE (op)) | 3862 if ((TREE_CODE (op) == RESULT_DECL |
3673 /* ??? With C++ we can have the situation that the result | 3863 && DECL_BY_REFERENCE (op)) |
3674 decl is a reference type while the return type is an aggregate. */ | 3864 || (TREE_CODE (op) == SSA_NAME |
3675 && !(TREE_CODE (op) == RESULT_DECL | 3865 && TREE_CODE (SSA_NAME_VAR (op)) == RESULT_DECL |
3676 && TREE_CODE (TREE_TYPE (op)) == REFERENCE_TYPE | 3866 && DECL_BY_REFERENCE (SSA_NAME_VAR (op)))) |
3677 && useless_type_conversion_p (restype, TREE_TYPE (TREE_TYPE (op))))) | 3867 op = TREE_TYPE (op); |
3868 | |
3869 if (!useless_type_conversion_p (restype, TREE_TYPE (op))) | |
3678 { | 3870 { |
3679 error ("invalid conversion in return statement"); | 3871 error ("invalid conversion in return statement"); |
3680 debug_generic_stmt (restype); | 3872 debug_generic_stmt (restype); |
3681 debug_generic_stmt (TREE_TYPE (op)); | 3873 debug_generic_stmt (TREE_TYPE (op)); |
3682 return true; | 3874 return true; |
3733 tree type = TREE_TYPE (gimple_phi_result (stmt)); | 3925 tree type = TREE_TYPE (gimple_phi_result (stmt)); |
3734 unsigned i; | 3926 unsigned i; |
3735 | 3927 |
3736 if (TREE_CODE (gimple_phi_result (stmt)) != SSA_NAME) | 3928 if (TREE_CODE (gimple_phi_result (stmt)) != SSA_NAME) |
3737 { | 3929 { |
3738 error ("Invalid PHI result"); | 3930 error ("invalid PHI result"); |
3739 return true; | 3931 return true; |
3740 } | 3932 } |
3741 | 3933 |
3742 for (i = 0; i < gimple_phi_num_args (stmt); i++) | 3934 for (i = 0; i < gimple_phi_num_args (stmt); i++) |
3743 { | 3935 { |
3745 if ((is_gimple_reg (gimple_phi_result (stmt)) | 3937 if ((is_gimple_reg (gimple_phi_result (stmt)) |
3746 && !is_gimple_val (arg)) | 3938 && !is_gimple_val (arg)) |
3747 || (!is_gimple_reg (gimple_phi_result (stmt)) | 3939 || (!is_gimple_reg (gimple_phi_result (stmt)) |
3748 && !is_gimple_addressable (arg))) | 3940 && !is_gimple_addressable (arg))) |
3749 { | 3941 { |
3750 error ("Invalid PHI argument"); | 3942 error ("invalid PHI argument"); |
3751 debug_generic_stmt (arg); | 3943 debug_generic_stmt (arg); |
3752 return true; | 3944 return true; |
3753 } | 3945 } |
3754 if (!useless_type_conversion_p (type, TREE_TYPE (arg))) | 3946 if (!useless_type_conversion_p (type, TREE_TYPE (arg))) |
3755 { | 3947 { |
3756 error ("Incompatible types in PHI argument %u", i); | 3948 error ("incompatible types in PHI argument %u", i); |
3757 debug_generic_stmt (type); | 3949 debug_generic_stmt (type); |
3758 debug_generic_stmt (TREE_TYPE (arg)); | 3950 debug_generic_stmt (TREE_TYPE (arg)); |
3759 return true; | 3951 return true; |
3760 } | 3952 } |
3761 } | 3953 } |
3979 lp_nr = lookup_stmt_eh_lp (stmt); | 4171 lp_nr = lookup_stmt_eh_lp (stmt); |
3980 if (lp_nr != 0) | 4172 if (lp_nr != 0) |
3981 { | 4173 { |
3982 if (!stmt_could_throw_p (stmt)) | 4174 if (!stmt_could_throw_p (stmt)) |
3983 { | 4175 { |
3984 /* During IPA passes, ipa-pure-const sets nothrow flags on calls | 4176 error ("statement marked for throw, but doesn%'t"); |
3985 and they are updated on statements only after fixup_cfg | 4177 goto fail; |
3986 is executed at beggining of expansion stage. */ | |
3987 if (cgraph_state != CGRAPH_STATE_IPA_SSA) | |
3988 { | |
3989 error ("statement marked for throw, but doesn%'t"); | |
3990 goto fail; | |
3991 } | |
3992 } | 4178 } |
3993 else if (lp_nr > 0 && !last_in_block && stmt_can_throw_internal (stmt)) | 4179 else if (lp_nr > 0 && !last_in_block && stmt_can_throw_internal (stmt)) |
3994 { | 4180 { |
3995 error ("statement marked for throw in middle of block"); | 4181 error ("statement marked for throw in middle of block"); |
3996 goto fail; | 4182 goto fail; |
4062 struct throw_stmt_node *node = (struct throw_stmt_node *)*slot; | 4248 struct throw_stmt_node *node = (struct throw_stmt_node *)*slot; |
4063 struct pointer_set_t *visited = (struct pointer_set_t *) data; | 4249 struct pointer_set_t *visited = (struct pointer_set_t *) data; |
4064 | 4250 |
4065 if (!pointer_set_contains (visited, node->stmt)) | 4251 if (!pointer_set_contains (visited, node->stmt)) |
4066 { | 4252 { |
4067 error ("Dead STMT in EH table"); | 4253 error ("dead STMT in EH table"); |
4068 debug_gimple_stmt (node->stmt); | 4254 debug_gimple_stmt (node->stmt); |
4069 eh_error_found = true; | 4255 eh_error_found = true; |
4070 } | 4256 } |
4071 return 1; | 4257 return 1; |
4072 } | 4258 } |
4073 | 4259 |
4074 | 4260 |
4075 /* Verify the GIMPLE statements in every basic block. */ | 4261 /* Verify the GIMPLE statements in every basic block. */ |
4076 | 4262 |
4077 void | 4263 DEBUG_FUNCTION void |
4078 verify_stmts (void) | 4264 verify_stmts (void) |
4079 { | 4265 { |
4080 basic_block bb; | 4266 basic_block bb; |
4081 gimple_stmt_iterator gsi; | 4267 gimple_stmt_iterator gsi; |
4082 bool err = false; | 4268 bool err = false; |
4420 err = 1; | 4606 err = 1; |
4421 } | 4607 } |
4422 } | 4608 } |
4423 break; | 4609 break; |
4424 | 4610 |
4611 case GIMPLE_CALL: | |
4612 if (!gimple_call_builtin_p (stmt, BUILT_IN_RETURN)) | |
4613 break; | |
4614 /* ... fallthru ... */ | |
4425 case GIMPLE_RETURN: | 4615 case GIMPLE_RETURN: |
4426 if (!single_succ_p (bb) | 4616 if (!single_succ_p (bb) |
4427 || (single_succ_edge (bb)->flags | 4617 || (single_succ_edge (bb)->flags |
4428 & (EDGE_FALLTHRU | EDGE_ABNORMAL | 4618 & (EDGE_FALLTHRU | EDGE_ABNORMAL |
4429 | EDGE_TRUE_VALUE | EDGE_FALSE_VALUE))) | 4619 | EDGE_TRUE_VALUE | EDGE_FALSE_VALUE))) |
5439 loc = pointer_map_insert (vars_map, t); | 5629 loc = pointer_map_insert (vars_map, t); |
5440 | 5630 |
5441 if (SSA_VAR_P (t)) | 5631 if (SSA_VAR_P (t)) |
5442 { | 5632 { |
5443 new_t = copy_var_decl (t, DECL_NAME (t), TREE_TYPE (t)); | 5633 new_t = copy_var_decl (t, DECL_NAME (t), TREE_TYPE (t)); |
5444 f->local_decls = tree_cons (NULL_TREE, new_t, f->local_decls); | 5634 add_local_decl (f, new_t); |
5445 } | 5635 } |
5446 else | 5636 else |
5447 { | 5637 { |
5448 gcc_assert (TREE_CODE (t) == CONST_DECL); | 5638 gcc_assert (TREE_CODE (t) == CONST_DECL); |
5449 new_t = copy_node (t); | 5639 new_t = copy_node (t); |
5691 } | 5881 } |
5692 break; | 5882 break; |
5693 } | 5883 } |
5694 | 5884 |
5695 return NULL_TREE; | 5885 return NULL_TREE; |
5696 } | |
5697 | |
5698 /* Marks virtual operands of all statements in basic blocks BBS for | |
5699 renaming. */ | |
5700 | |
5701 void | |
5702 mark_virtual_ops_in_bb (basic_block bb) | |
5703 { | |
5704 gimple_stmt_iterator gsi; | |
5705 | |
5706 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) | |
5707 mark_virtual_ops_for_renaming (gsi_stmt (gsi)); | |
5708 | |
5709 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) | |
5710 mark_virtual_ops_for_renaming (gsi_stmt (gsi)); | |
5711 } | 5886 } |
5712 | 5887 |
5713 /* Move basic block BB from function CFUN to function DEST_FN. The | 5888 /* Move basic block BB from function CFUN to function DEST_FN. The |
5714 block is moved out of the original linked list and placed after | 5889 block is moved out of the original linked list and placed after |
5715 block AFTER in the new list. Also, the block is removed from the | 5890 block AFTER in the new list. Also, the block is removed from the |
5925 replace_block_vars_by_duplicates (tree block, struct pointer_map_t *vars_map, | 6100 replace_block_vars_by_duplicates (tree block, struct pointer_map_t *vars_map, |
5926 tree to_context) | 6101 tree to_context) |
5927 { | 6102 { |
5928 tree *tp, t; | 6103 tree *tp, t; |
5929 | 6104 |
5930 for (tp = &BLOCK_VARS (block); *tp; tp = &TREE_CHAIN (*tp)) | 6105 for (tp = &BLOCK_VARS (block); *tp; tp = &DECL_CHAIN (*tp)) |
5931 { | 6106 { |
5932 t = *tp; | 6107 t = *tp; |
5933 if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != CONST_DECL) | 6108 if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != CONST_DECL) |
5934 continue; | 6109 continue; |
5935 replace_by_duplicate_decl (&t, vars_map, to_context); | 6110 replace_by_duplicate_decl (&t, vars_map, to_context); |
5938 if (TREE_CODE (*tp) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (*tp)) | 6113 if (TREE_CODE (*tp) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (*tp)) |
5939 { | 6114 { |
5940 SET_DECL_VALUE_EXPR (t, DECL_VALUE_EXPR (*tp)); | 6115 SET_DECL_VALUE_EXPR (t, DECL_VALUE_EXPR (*tp)); |
5941 DECL_HAS_VALUE_EXPR_P (t) = 1; | 6116 DECL_HAS_VALUE_EXPR_P (t) = 1; |
5942 } | 6117 } |
5943 TREE_CHAIN (t) = TREE_CHAIN (*tp); | 6118 DECL_CHAIN (t) = DECL_CHAIN (*tp); |
5944 *tp = t; | 6119 *tp = t; |
5945 } | 6120 } |
5946 } | 6121 } |
5947 | 6122 |
5948 for (block = BLOCK_SUBBLOCKS (block); block; block = BLOCK_CHAIN (block)) | 6123 for (block = BLOCK_SUBBLOCKS (block); block; block = BLOCK_CHAIN (block)) |
6055 new_label_map = NULL; | 6230 new_label_map = NULL; |
6056 if (saved_cfun->eh) | 6231 if (saved_cfun->eh) |
6057 { | 6232 { |
6058 eh_region region = NULL; | 6233 eh_region region = NULL; |
6059 | 6234 |
6060 for (i = 0; VEC_iterate (basic_block, bbs, i, bb); i++) | 6235 FOR_EACH_VEC_ELT (basic_block, bbs, i, bb) |
6061 region = find_outermost_region_in_block (saved_cfun, bb, region); | 6236 region = find_outermost_region_in_block (saved_cfun, bb, region); |
6062 | 6237 |
6063 init_eh_for_function (); | 6238 init_eh_for_function (); |
6064 if (region != NULL) | 6239 if (region != NULL) |
6065 { | 6240 { |
6084 d.vars_map = vars_map; | 6259 d.vars_map = vars_map; |
6085 d.new_label_map = new_label_map; | 6260 d.new_label_map = new_label_map; |
6086 d.eh_map = eh_map; | 6261 d.eh_map = eh_map; |
6087 d.remap_decls_p = true; | 6262 d.remap_decls_p = true; |
6088 | 6263 |
6089 for (i = 0; VEC_iterate (basic_block, bbs, i, bb); i++) | 6264 FOR_EACH_VEC_ELT (basic_block, bbs, i, bb) |
6090 { | 6265 { |
6091 /* No need to update edge counts on the last block. It has | 6266 /* No need to update edge counts on the last block. It has |
6092 already been updated earlier when we detached the region from | 6267 already been updated earlier when we detached the region from |
6093 the original CFG. */ | 6268 the original CFG. */ |
6094 move_block_to_fn (dest_cfun, bb, after, bb != exit_bb, &d); | 6269 move_block_to_fn (dest_cfun, bb, after, bb != exit_bb, &d); |
6149 e = make_edge (bb, exit_succ[i], exit_flag[i]); | 6324 e = make_edge (bb, exit_succ[i], exit_flag[i]); |
6150 e->probability = exit_prob[i]; | 6325 e->probability = exit_prob[i]; |
6151 } | 6326 } |
6152 | 6327 |
6153 set_immediate_dominator (CDI_DOMINATORS, bb, dom_entry); | 6328 set_immediate_dominator (CDI_DOMINATORS, bb, dom_entry); |
6154 for (i = 0; VEC_iterate (basic_block, dom_bbs, i, abb); i++) | 6329 FOR_EACH_VEC_ELT (basic_block, dom_bbs, i, abb) |
6155 set_immediate_dominator (CDI_DOMINATORS, abb, bb); | 6330 set_immediate_dominator (CDI_DOMINATORS, abb, bb); |
6156 VEC_free (basic_block, heap, dom_bbs); | 6331 VEC_free (basic_block, heap, dom_bbs); |
6157 | 6332 |
6158 if (exit_bb) | 6333 if (exit_bb) |
6159 { | 6334 { |
6174 */ | 6349 */ |
6175 | 6350 |
6176 void | 6351 void |
6177 dump_function_to_file (tree fn, FILE *file, int flags) | 6352 dump_function_to_file (tree fn, FILE *file, int flags) |
6178 { | 6353 { |
6179 tree arg, vars, var; | 6354 tree arg, var; |
6180 struct function *dsf; | 6355 struct function *dsf; |
6181 bool ignore_topmost_bind = false, any_var = false; | 6356 bool ignore_topmost_bind = false, any_var = false; |
6182 basic_block bb; | 6357 basic_block bb; |
6183 tree chain; | 6358 tree chain; |
6184 | 6359 |
6190 print_generic_expr (file, TREE_TYPE (arg), dump_flags); | 6365 print_generic_expr (file, TREE_TYPE (arg), dump_flags); |
6191 fprintf (file, " "); | 6366 fprintf (file, " "); |
6192 print_generic_expr (file, arg, dump_flags); | 6367 print_generic_expr (file, arg, dump_flags); |
6193 if (flags & TDF_VERBOSE) | 6368 if (flags & TDF_VERBOSE) |
6194 print_node (file, "", arg, 4); | 6369 print_node (file, "", arg, 4); |
6195 if (TREE_CHAIN (arg)) | 6370 if (DECL_CHAIN (arg)) |
6196 fprintf (file, ", "); | 6371 fprintf (file, ", "); |
6197 arg = TREE_CHAIN (arg); | 6372 arg = DECL_CHAIN (arg); |
6198 } | 6373 } |
6199 fprintf (file, ")\n"); | 6374 fprintf (file, ")\n"); |
6200 | 6375 |
6201 if (flags & TDF_VERBOSE) | 6376 if (flags & TDF_VERBOSE) |
6202 print_node (file, "", fn, 2); | 6377 print_node (file, "", fn, 2); |
6214 /* Switch CFUN to point to FN. */ | 6389 /* Switch CFUN to point to FN. */ |
6215 push_cfun (DECL_STRUCT_FUNCTION (fn)); | 6390 push_cfun (DECL_STRUCT_FUNCTION (fn)); |
6216 | 6391 |
6217 /* When GIMPLE is lowered, the variables are no longer available in | 6392 /* When GIMPLE is lowered, the variables are no longer available in |
6218 BIND_EXPRs, so display them separately. */ | 6393 BIND_EXPRs, so display them separately. */ |
6219 if (cfun && cfun->decl == fn && cfun->local_decls) | 6394 if (cfun && cfun->decl == fn && !VEC_empty (tree, cfun->local_decls)) |
6220 { | 6395 { |
6396 unsigned ix; | |
6221 ignore_topmost_bind = true; | 6397 ignore_topmost_bind = true; |
6222 | 6398 |
6223 fprintf (file, "{\n"); | 6399 fprintf (file, "{\n"); |
6224 for (vars = cfun->local_decls; vars; vars = TREE_CHAIN (vars)) | 6400 FOR_EACH_LOCAL_DECL (cfun, ix, var) |
6225 { | 6401 { |
6226 var = TREE_VALUE (vars); | |
6227 | |
6228 print_generic_decl (file, var, flags); | 6402 print_generic_decl (file, var, flags); |
6229 if (flags & TDF_VERBOSE) | 6403 if (flags & TDF_VERBOSE) |
6230 print_node (file, "", var, 4); | 6404 print_node (file, "", var, 4); |
6231 fprintf (file, "\n"); | 6405 fprintf (file, "\n"); |
6232 | 6406 |
6303 print_generic_stmt_indented (file, chain, flags, indent); | 6477 print_generic_stmt_indented (file, chain, flags, indent); |
6304 if (ignore_topmost_bind) | 6478 if (ignore_topmost_bind) |
6305 fprintf (file, "}\n"); | 6479 fprintf (file, "}\n"); |
6306 } | 6480 } |
6307 | 6481 |
6482 if (flags & TDF_ENUMERATE_LOCALS) | |
6483 dump_enumerated_decls (file, flags); | |
6308 fprintf (file, "\n\n"); | 6484 fprintf (file, "\n\n"); |
6309 | 6485 |
6310 /* Restore CFUN. */ | 6486 /* Restore CFUN. */ |
6311 pop_cfun (); | 6487 pop_cfun (); |
6312 } | 6488 } |
6313 | 6489 |
6314 | 6490 |
6315 /* Dump FUNCTION_DECL FN to stderr using FLAGS (see TDF_* in tree.h) */ | 6491 /* Dump FUNCTION_DECL FN to stderr using FLAGS (see TDF_* in tree.h) */ |
6316 | 6492 |
6317 void | 6493 DEBUG_FUNCTION void |
6318 debug_function (tree fn, int flags) | 6494 debug_function (tree fn, int flags) |
6319 { | 6495 { |
6320 dump_function_to_file (fn, stderr, flags); | 6496 dump_function_to_file (fn, stderr, flags); |
6321 } | 6497 } |
6322 | 6498 |
6453 } | 6629 } |
6454 | 6630 |
6455 | 6631 |
6456 /* Debugging loops structure at tree level, at some VERBOSITY level. */ | 6632 /* Debugging loops structure at tree level, at some VERBOSITY level. */ |
6457 | 6633 |
6458 void | 6634 DEBUG_FUNCTION void |
6459 debug_loops (int verbosity) | 6635 debug_loops (int verbosity) |
6460 { | 6636 { |
6461 print_loops (stderr, verbosity); | 6637 print_loops (stderr, verbosity); |
6462 } | 6638 } |
6463 | 6639 |
6464 /* Print on stderr the code of LOOP, at some VERBOSITY level. */ | 6640 /* Print on stderr the code of LOOP, at some VERBOSITY level. */ |
6465 | 6641 |
6466 void | 6642 DEBUG_FUNCTION void |
6467 debug_loop (struct loop *loop, int verbosity) | 6643 debug_loop (struct loop *loop, int verbosity) |
6468 { | 6644 { |
6469 print_loop (stderr, loop, 0, verbosity); | 6645 print_loop (stderr, loop, 0, verbosity); |
6470 } | 6646 } |
6471 | 6647 |
6472 /* Print on stderr the code of loop number NUM, at some VERBOSITY | 6648 /* Print on stderr the code of loop number NUM, at some VERBOSITY |
6473 level. */ | 6649 level. */ |
6474 | 6650 |
6475 void | 6651 DEBUG_FUNCTION void |
6476 debug_loop_num (unsigned num, int verbosity) | 6652 debug_loop_num (unsigned num, int verbosity) |
6477 { | 6653 { |
6478 debug_loop (get_loop (num), verbosity); | 6654 debug_loop (get_loop (num), verbosity); |
6479 } | 6655 } |
6480 | 6656 |
6484 | 6660 |
6485 static bool | 6661 static bool |
6486 gimple_block_ends_with_call_p (basic_block bb) | 6662 gimple_block_ends_with_call_p (basic_block bb) |
6487 { | 6663 { |
6488 gimple_stmt_iterator gsi = gsi_last_nondebug_bb (bb); | 6664 gimple_stmt_iterator gsi = gsi_last_nondebug_bb (bb); |
6489 return is_gimple_call (gsi_stmt (gsi)); | 6665 return !gsi_end_p (gsi) && is_gimple_call (gsi_stmt (gsi)); |
6490 } | 6666 } |
6491 | 6667 |
6492 | 6668 |
6493 /* Return true if BB ends with a conditional branch. Return false, | 6669 /* Return true if BB ends with a conditional branch. Return false, |
6494 otherwise. */ | 6670 otherwise. */ |
6585 | 6761 |
6586 Handle this by adding a dummy instruction in a new last basic block. */ | 6762 Handle this by adding a dummy instruction in a new last basic block. */ |
6587 if (check_last_block) | 6763 if (check_last_block) |
6588 { | 6764 { |
6589 basic_block bb = EXIT_BLOCK_PTR->prev_bb; | 6765 basic_block bb = EXIT_BLOCK_PTR->prev_bb; |
6590 gimple_stmt_iterator gsi = gsi_last_bb (bb); | 6766 gimple_stmt_iterator gsi = gsi_last_nondebug_bb (bb); |
6591 gimple t = NULL; | 6767 gimple t = NULL; |
6592 | 6768 |
6593 if (!gsi_end_p (gsi)) | 6769 if (!gsi_end_p (gsi)) |
6594 t = gsi_stmt (gsi); | 6770 t = gsi_stmt (gsi); |
6595 | 6771 |
6619 continue; | 6795 continue; |
6620 | 6796 |
6621 if (blocks && !TEST_BIT (blocks, i)) | 6797 if (blocks && !TEST_BIT (blocks, i)) |
6622 continue; | 6798 continue; |
6623 | 6799 |
6624 gsi = gsi_last_bb (bb); | 6800 gsi = gsi_last_nondebug_bb (bb); |
6625 if (!gsi_end_p (gsi)) | 6801 if (!gsi_end_p (gsi)) |
6626 { | 6802 { |
6627 last_stmt = gsi_stmt (gsi); | 6803 last_stmt = gsi_stmt (gsi); |
6628 do | 6804 do |
6629 { | 6805 { |
6665 verify_flow_info (); | 6841 verify_flow_info (); |
6666 | 6842 |
6667 return blocks_split; | 6843 return blocks_split; |
6668 } | 6844 } |
6669 | 6845 |
6670 /* Purge dead abnormal call edges from basic block BB. */ | |
6671 | |
6672 bool | |
6673 gimple_purge_dead_abnormal_call_edges (basic_block bb) | |
6674 { | |
6675 bool changed = gimple_purge_dead_eh_edges (bb); | |
6676 | |
6677 if (cfun->has_nonlocal_label) | |
6678 { | |
6679 gimple stmt = last_stmt (bb); | |
6680 edge_iterator ei; | |
6681 edge e; | |
6682 | |
6683 if (!(stmt && stmt_can_make_abnormal_goto (stmt))) | |
6684 for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); ) | |
6685 { | |
6686 if (e->flags & EDGE_ABNORMAL) | |
6687 { | |
6688 remove_edge (e); | |
6689 changed = true; | |
6690 } | |
6691 else | |
6692 ei_next (&ei); | |
6693 } | |
6694 | |
6695 /* See gimple_purge_dead_eh_edges below. */ | |
6696 if (changed) | |
6697 free_dominance_info (CDI_DOMINATORS); | |
6698 } | |
6699 | |
6700 return changed; | |
6701 } | |
6702 | |
6703 /* Removes edge E and all the blocks dominated by it, and updates dominance | 6846 /* Removes edge E and all the blocks dominated by it, and updates dominance |
6704 information. The IL in E->src needs to be updated separately. | 6847 information. The IL in E->src needs to be updated separately. |
6705 If dominance info is not available, only the edge E is removed.*/ | 6848 If dominance info is not available, only the edge E is removed.*/ |
6706 | 6849 |
6707 void | 6850 void |
6758 bitmap_set_bit (df_idom, | 6901 bitmap_set_bit (df_idom, |
6759 get_immediate_dominator (CDI_DOMINATORS, e->dest)->index); | 6902 get_immediate_dominator (CDI_DOMINATORS, e->dest)->index); |
6760 else | 6903 else |
6761 { | 6904 { |
6762 bbs_to_remove = get_all_dominated_blocks (CDI_DOMINATORS, e->dest); | 6905 bbs_to_remove = get_all_dominated_blocks (CDI_DOMINATORS, e->dest); |
6763 for (i = 0; VEC_iterate (basic_block, bbs_to_remove, i, bb); i++) | 6906 FOR_EACH_VEC_ELT (basic_block, bbs_to_remove, i, bb) |
6764 { | 6907 { |
6765 FOR_EACH_EDGE (f, ei, bb->succs) | 6908 FOR_EACH_EDGE (f, ei, bb->succs) |
6766 { | 6909 { |
6767 if (f->dest != EXIT_BLOCK_PTR) | 6910 if (f->dest != EXIT_BLOCK_PTR) |
6768 bitmap_set_bit (df, f->dest->index); | 6911 bitmap_set_bit (df, f->dest->index); |
6769 } | 6912 } |
6770 } | 6913 } |
6771 for (i = 0; VEC_iterate (basic_block, bbs_to_remove, i, bb); i++) | 6914 FOR_EACH_VEC_ELT (basic_block, bbs_to_remove, i, bb) |
6772 bitmap_clear_bit (df, bb->index); | 6915 bitmap_clear_bit (df, bb->index); |
6773 | 6916 |
6774 EXECUTE_IF_SET_IN_BITMAP (df, 0, i, bi) | 6917 EXECUTE_IF_SET_IN_BITMAP (df, 0, i, bi) |
6775 { | 6918 { |
6776 bb = BASIC_BLOCK (i); | 6919 bb = BASIC_BLOCK (i); |
6851 } | 6994 } |
6852 | 6995 |
6853 return changed; | 6996 return changed; |
6854 } | 6997 } |
6855 | 6998 |
6999 /* Purge dead EH edges from basic block listed in BLOCKS. */ | |
7000 | |
6856 bool | 7001 bool |
6857 gimple_purge_all_dead_eh_edges (const_bitmap blocks) | 7002 gimple_purge_all_dead_eh_edges (const_bitmap blocks) |
6858 { | 7003 { |
6859 bool changed = false; | 7004 bool changed = false; |
6860 unsigned i; | 7005 unsigned i; |
6867 /* Earlier gimple_purge_dead_eh_edges could have removed | 7012 /* Earlier gimple_purge_dead_eh_edges could have removed |
6868 this basic block already. */ | 7013 this basic block already. */ |
6869 gcc_assert (bb || changed); | 7014 gcc_assert (bb || changed); |
6870 if (bb != NULL) | 7015 if (bb != NULL) |
6871 changed |= gimple_purge_dead_eh_edges (bb); | 7016 changed |= gimple_purge_dead_eh_edges (bb); |
7017 } | |
7018 | |
7019 return changed; | |
7020 } | |
7021 | |
7022 /* Purge dead abnormal call edges from basic block BB. */ | |
7023 | |
7024 bool | |
7025 gimple_purge_dead_abnormal_call_edges (basic_block bb) | |
7026 { | |
7027 bool changed = false; | |
7028 edge e; | |
7029 edge_iterator ei; | |
7030 gimple stmt = last_stmt (bb); | |
7031 | |
7032 if (!cfun->has_nonlocal_label) | |
7033 return false; | |
7034 | |
7035 if (stmt && stmt_can_make_abnormal_goto (stmt)) | |
7036 return false; | |
7037 | |
7038 for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); ) | |
7039 { | |
7040 if (e->flags & EDGE_ABNORMAL) | |
7041 { | |
7042 remove_edge_and_dominated_blocks (e); | |
7043 changed = true; | |
7044 } | |
7045 else | |
7046 ei_next (&ei); | |
7047 } | |
7048 | |
7049 return changed; | |
7050 } | |
7051 | |
7052 /* Purge dead abnormal call edges from basic block listed in BLOCKS. */ | |
7053 | |
7054 bool | |
7055 gimple_purge_all_dead_abnormal_call_edges (const_bitmap blocks) | |
7056 { | |
7057 bool changed = false; | |
7058 unsigned i; | |
7059 bitmap_iterator bi; | |
7060 | |
7061 EXECUTE_IF_SET_IN_BITMAP (blocks, 0, i, bi) | |
7062 { | |
7063 basic_block bb = BASIC_BLOCK (i); | |
7064 | |
7065 /* Earlier gimple_purge_dead_abnormal_call_edges could have removed | |
7066 this basic block already. */ | |
7067 gcc_assert (bb || changed); | |
7068 if (bb != NULL) | |
7069 changed |= gimple_purge_dead_abnormal_call_edges (bb); | |
6872 } | 7070 } |
6873 | 7071 |
6874 return changed; | 7072 return changed; |
6875 } | 7073 } |
6876 | 7074 |
6978 gimple_split_block, /* split_block */ | 7176 gimple_split_block, /* split_block */ |
6979 gimple_move_block_after, /* move_block_after */ | 7177 gimple_move_block_after, /* move_block_after */ |
6980 gimple_can_merge_blocks_p, /* can_merge_blocks_p */ | 7178 gimple_can_merge_blocks_p, /* can_merge_blocks_p */ |
6981 gimple_merge_blocks, /* merge_blocks */ | 7179 gimple_merge_blocks, /* merge_blocks */ |
6982 gimple_predict_edge, /* predict_edge */ | 7180 gimple_predict_edge, /* predict_edge */ |
6983 gimple_predicted_by_p, /* predicted_by_p */ | 7181 gimple_predicted_by_p, /* predicted_by_p */ |
6984 gimple_can_duplicate_bb_p, /* can_duplicate_block_p */ | 7182 gimple_can_duplicate_bb_p, /* can_duplicate_block_p */ |
6985 gimple_duplicate_bb, /* duplicate_block */ | 7183 gimple_duplicate_bb, /* duplicate_block */ |
6986 gimple_split_edge, /* split_edge */ | 7184 gimple_split_edge, /* split_edge */ |
6987 gimple_make_forwarder_block, /* make_forward_block */ | 7185 gimple_make_forwarder_block, /* make_forward_block */ |
6988 NULL, /* tidy_fallthru_edge */ | 7186 NULL, /* tidy_fallthru_edge */ |
6989 gimple_block_ends_with_call_p,/* block_ends_with_call_p */ | 7187 gimple_block_ends_with_call_p,/* block_ends_with_call_p */ |
6990 gimple_block_ends_with_condjump_p, /* block_ends_with_condjump_p */ | 7188 gimple_block_ends_with_condjump_p, /* block_ends_with_condjump_p */ |
6991 gimple_flow_call_edges_add, /* flow_call_edges_add */ | 7189 gimple_flow_call_edges_add, /* flow_call_edges_add */ |
6992 gimple_execute_on_growing_pred, /* execute_on_growing_pred */ | 7190 gimple_execute_on_growing_pred, /* execute_on_growing_pred */ |
6993 gimple_execute_on_shrinking_pred, /* execute_on_shrinking_pred */ | 7191 gimple_execute_on_shrinking_pred, /* execute_on_shrinking_pred */ |
6994 gimple_duplicate_loop_to_header_edge, /* duplicate loop for trees */ | 7192 gimple_duplicate_loop_to_header_edge, /* duplicate loop for trees */ |
6995 gimple_lv_add_condition_to_bb, /* lv_add_condition_to_bb */ | 7193 gimple_lv_add_condition_to_bb, /* lv_add_condition_to_bb */ |
6996 gimple_lv_adjust_loop_header_phi, /* lv_adjust_loop_header_phi*/ | 7194 gimple_lv_adjust_loop_header_phi, /* lv_adjust_loop_header_phi*/ |
7034 gimple_stmt_iterator gsi; | 7232 gimple_stmt_iterator gsi; |
7035 | 7233 |
7036 gsi = gsi_last_bb (e->src); | 7234 gsi = gsi_last_bb (e->src); |
7037 if (!gsi_end_p (gsi) | 7235 if (!gsi_end_p (gsi) |
7038 && stmt_ends_bb_p (gsi_stmt (gsi)) | 7236 && stmt_ends_bb_p (gsi_stmt (gsi)) |
7039 && gimple_code (gsi_stmt (gsi)) != GIMPLE_RETURN) | 7237 && (gimple_code (gsi_stmt (gsi)) != GIMPLE_RETURN |
7238 && !gimple_call_builtin_p (gsi_stmt (gsi), | |
7239 BUILT_IN_RETURN))) | |
7040 split_edge (e); | 7240 split_edge (e); |
7041 } | 7241 } |
7042 } | 7242 } |
7043 } | 7243 } |
7044 end_recording_case_labels (); | 7244 end_recording_case_labels (); |
7132 { | 7332 { |
7133 location = UNKNOWN_LOCATION; | 7333 location = UNKNOWN_LOCATION; |
7134 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds) | 7334 FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds) |
7135 { | 7335 { |
7136 last = last_stmt (e->src); | 7336 last = last_stmt (e->src); |
7137 if (gimple_code (last) == GIMPLE_RETURN | 7337 if ((gimple_code (last) == GIMPLE_RETURN |
7338 || gimple_call_builtin_p (last, BUILT_IN_RETURN)) | |
7138 && (location = gimple_location (last)) != UNKNOWN_LOCATION) | 7339 && (location = gimple_location (last)) != UNKNOWN_LOCATION) |
7139 break; | 7340 break; |
7140 } | 7341 } |
7141 if (location == UNKNOWN_LOCATION) | 7342 if (location == UNKNOWN_LOCATION) |
7142 location = cfun->function_end_locus; | 7343 location = cfun->function_end_locus; |
7216 /* Emit noreturn warnings. */ | 7417 /* Emit noreturn warnings. */ |
7217 | 7418 |
7218 static unsigned int | 7419 static unsigned int |
7219 execute_warn_function_noreturn (void) | 7420 execute_warn_function_noreturn (void) |
7220 { | 7421 { |
7221 if (warn_missing_noreturn | 7422 if (!TREE_THIS_VOLATILE (current_function_decl) |
7222 && !TREE_THIS_VOLATILE (cfun->decl) | 7423 && EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 0) |
7223 && EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 0 | 7424 warn_function_noreturn (current_function_decl); |
7224 && !lang_hooks.missing_noreturn_ok_p (cfun->decl)) | |
7225 warning_at (DECL_SOURCE_LOCATION (cfun->decl), OPT_Wmissing_noreturn, | |
7226 "function might be possible candidate " | |
7227 "for attribute %<noreturn%>"); | |
7228 return 0; | 7425 return 0; |
7426 } | |
7427 | |
7428 static bool | |
7429 gate_warn_function_noreturn (void) | |
7430 { | |
7431 return warn_suggest_attribute_noreturn; | |
7229 } | 7432 } |
7230 | 7433 |
7231 struct gimple_opt_pass pass_warn_function_noreturn = | 7434 struct gimple_opt_pass pass_warn_function_noreturn = |
7232 { | 7435 { |
7233 { | 7436 { |
7234 GIMPLE_PASS, | 7437 GIMPLE_PASS, |
7235 "*warn_function_noreturn", /* name */ | 7438 "*warn_function_noreturn", /* name */ |
7236 NULL, /* gate */ | 7439 gate_warn_function_noreturn, /* gate */ |
7237 execute_warn_function_noreturn, /* execute */ | 7440 execute_warn_function_noreturn, /* execute */ |
7238 NULL, /* sub */ | 7441 NULL, /* sub */ |
7239 NULL, /* next */ | 7442 NULL, /* next */ |
7240 0, /* static_pass_number */ | 7443 0, /* static_pass_number */ |
7241 TV_NONE, /* tv_id */ | 7444 TV_NONE, /* tv_id */ |