GCC Wikia
Advertisement

このページを編集する際は,編集に関する方針に従ってください.[]

概要[]

コメント

pass_hogehogeは

struct tree_opt_passを通じて

最適化作業の関数をよびだす

このinit_optimization passes関数がコンストラクターとなっている

引数[]

実装[]

423 /* Construct the pass tree.  */
424 
425 void
426 init_optimization_passes (void)
427 {
428   struct tree_opt_pass **p;
429 
430 #define NEXT_PASS(PASS)  (p = next_pass_1 (p, &PASS))
431   /* Interprocedural optimization passes.  */
432   p = &all_ipa_passes;
433   NEXT_PASS (pass_early_ipa_inline);
434   NEXT_PASS (pass_early_local_passes);
435   NEXT_PASS (pass_ipa_cp);
436   NEXT_PASS (pass_ipa_inline);
437   NEXT_PASS (pass_ipa_reference);
438   NEXT_PASS (pass_ipa_pure_const); 
439   NEXT_PASS (pass_ipa_type_escape);
440   *p = NULL;
441 
442   /* All passes needed to lower the function into shape optimizers can operate
443      on.  These passes are performed before interprocedural passes, unlike rest
444      of local passes (all_passes).  */
445   p = &all_lowering_passes;
446   NEXT_PASS (pass_remove_useless_stmts);
447   NEXT_PASS (pass_mudflap_1);
448   NEXT_PASS (pass_lower_cf);
449   NEXT_PASS (pass_lower_eh);
450   NEXT_PASS (pass_build_cfg);
451   NEXT_PASS (pass_lower_complex_O0);
452   NEXT_PASS (pass_lower_vector);
453   NEXT_PASS (pass_warn_function_return);
454   NEXT_PASS (pass_early_tree_profile);
455   *p = NULL;
456 
457   p = &pass_early_local_passes.sub;
458   NEXT_PASS (pass_tree_profile);
459   NEXT_PASS (pass_cleanup_cfg);
460   NEXT_PASS (pass_rebuild_cgraph_edges);
461   *p = NULL;
462 
463   p = &all_passes;
464   NEXT_PASS (pass_fixup_cfg);
465   NEXT_PASS (pass_init_datastructures);
466   NEXT_PASS (pass_all_optimizations);
467   NEXT_PASS (pass_warn_function_noreturn);
468   NEXT_PASS (pass_mudflap_2);
469   NEXT_PASS (pass_free_datastructures);
470   NEXT_PASS (pass_free_cfg_annotations);
471   NEXT_PASS (pass_expand);
472   NEXT_PASS (pass_rest_of_compilation);
473   NEXT_PASS (pass_clean_state);
474   *p = NULL;
475 
476   p = &pass_all_optimizations.sub;
477   NEXT_PASS (pass_referenced_vars);
478   NEXT_PASS (pass_create_structure_vars);
479   NEXT_PASS (pass_build_ssa);
480   NEXT_PASS (pass_may_alias);
481   NEXT_PASS (pass_return_slot);
482   NEXT_PASS (pass_rename_ssa_copies);
483   NEXT_PASS (pass_early_warn_uninitialized);
484   NEXT_PASS (pass_eliminate_useless_stores);
485 
486   /* Initial scalar cleanups.  */
487   NEXT_PASS (pass_ccp);
488   NEXT_PASS (pass_fre);
489   NEXT_PASS (pass_dce);
490   NEXT_PASS (pass_forwprop);
491   NEXT_PASS (pass_copy_prop);
492   NEXT_PASS (pass_vrp);
493   NEXT_PASS (pass_dce);
494   NEXT_PASS (pass_merge_phi);
495   NEXT_PASS (pass_dominator);
496 
497   /* The only copy propagation opportunities left after DOM
498      should be due to degenerate PHI nodes.  So rather than
499      run the full copy propagator, just discover and copy
500      propagate away the degenerate PHI nodes.  */
501   NEXT_PASS (pass_phi_only_copy_prop);
502 
503   NEXT_PASS (pass_phiopt);
504   NEXT_PASS (pass_may_alias);
505   NEXT_PASS (pass_tail_recursion);
506   NEXT_PASS (pass_profile);
507   NEXT_PASS (pass_ch);
508   NEXT_PASS (pass_stdarg);
509   NEXT_PASS (pass_lower_complex);
510   NEXT_PASS (pass_sra);
511   /* FIXME: SRA may generate arbitrary gimple code, exposing new
512      aliased and call-clobbered variables.  As mentioned below,
513      pass_may_alias should be a TODO item.  */
514   NEXT_PASS (pass_may_alias);
515   NEXT_PASS (pass_rename_ssa_copies);
516   NEXT_PASS (pass_dominator);
517 
518   /* The only copy propagation opportunities left after DOM
519      should be due to degenerate PHI nodes.  So rather than
520      run the full copy propagator, just discover and copy
521      propagate away the degenerate PHI nodes.  */
522   NEXT_PASS (pass_phi_only_copy_prop);
523 
524   NEXT_PASS (pass_dce);
525   NEXT_PASS (pass_dse);
526   NEXT_PASS (pass_may_alias);
527   NEXT_PASS (pass_forwprop);
528   NEXT_PASS (pass_phiopt);
529   NEXT_PASS (pass_object_sizes);
530   NEXT_PASS (pass_store_ccp);
531   NEXT_PASS (pass_store_copy_prop);
532   NEXT_PASS (pass_fold_builtins);
533   /* FIXME: May alias should a TODO but for 4.0.0,
534      we add may_alias right after fold builtins
535      which can create arbitrary GIMPLE.  */
536   NEXT_PASS (pass_may_alias);
537   NEXT_PASS (pass_split_crit_edges);
538   NEXT_PASS (pass_reassoc);
539   NEXT_PASS (pass_pre);
540   NEXT_PASS (pass_sink_code);
541   NEXT_PASS (pass_tree_loop);
542   NEXT_PASS (pass_cse_reciprocals);
543   NEXT_PASS (pass_dominator);
544 
545   /* The only copy propagation opportunities left after DOM
546      should be due to degenerate PHI nodes.  So rather than
547      run the full copy propagator, just discover and copy
548      propagate away the degenerate PHI nodes.  */
549   NEXT_PASS (pass_phi_only_copy_prop);
550 
551   NEXT_PASS (pass_cd_dce);
552 
553   /* FIXME: If DCE is not run before checking for uninitialized uses,
554      we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c).
555      However, this also causes us to misdiagnose cases that should be
556      real warnings (e.g., testsuite/gcc.dg/pr18501.c).
557      
558      To fix the false positives in uninit-5.c, we would have to
559      account for the predicates protecting the set and the use of each
560      variable.  Using a representation like Gated Single Assignment
561      may help.  */
562   NEXT_PASS (pass_late_warn_uninitialized);
563   NEXT_PASS (pass_dse);
564   NEXT_PASS (pass_forwprop);
565   NEXT_PASS (pass_phiopt);
566   NEXT_PASS (pass_tail_calls);
567   NEXT_PASS (pass_rename_ssa_copies);
568   NEXT_PASS (pass_uncprop);
569   NEXT_PASS (pass_del_ssa);
570   NEXT_PASS (pass_nrv);
571   NEXT_PASS (pass_remove_useless_vars);
572   NEXT_PASS (pass_mark_used_blocks);
573   NEXT_PASS (pass_cleanup_cfg_post_optimizing);
574   *p = NULL;
575 
576   p = &pass_tree_loop.sub;
577   NEXT_PASS (pass_tree_loop_init);
578   NEXT_PASS (pass_copy_prop);
579   NEXT_PASS (pass_lim);
580   NEXT_PASS (pass_tree_unswitch);
581   NEXT_PASS (pass_scev_cprop);
582   NEXT_PASS (pass_empty_loop);
583   NEXT_PASS (pass_record_bounds);
584   NEXT_PASS (pass_linear_transform);
585   NEXT_PASS (pass_iv_canon);
586   NEXT_PASS (pass_if_conversion);
587   NEXT_PASS (pass_vectorize);
588   /* NEXT_PASS (pass_may_alias) cannot be done again because the
589      vectorizer creates alias relations that are not supported by
590      pass_may_alias.  */
591   NEXT_PASS (pass_complete_unroll);
592   NEXT_PASS (pass_iv_optimize);
593   NEXT_PASS (pass_tree_loop_done);
594   *p = NULL;
595 
596   p = &pass_vectorize.sub;
597   NEXT_PASS (pass_lower_vector_ssa);
598   NEXT_PASS (pass_dce_loop);
599   *p = NULL;
600 
601   p = &pass_loop2.sub;
602   NEXT_PASS (pass_rtl_loop_init);
603   NEXT_PASS (pass_rtl_move_loop_invariants);
604   NEXT_PASS (pass_rtl_unswitch);
605   NEXT_PASS (pass_rtl_unroll_and_peel_loops);
606   NEXT_PASS (pass_rtl_doloop);
607   NEXT_PASS (pass_rtl_loop_done);
608   *p = NULL;
609   
610   p = &pass_rest_of_compilation.sub;
611   NEXT_PASS (pass_remove_unnecessary_notes);
612   NEXT_PASS (pass_init_function);
613   NEXT_PASS (pass_jump);
614   NEXT_PASS (pass_insn_locators_initialize);
615   NEXT_PASS (pass_rtl_eh);
616   NEXT_PASS (pass_initial_value_sets);
617   NEXT_PASS (pass_unshare_all_rtl);
618   NEXT_PASS (pass_instantiate_virtual_regs);
619   NEXT_PASS (pass_jump2);
620   NEXT_PASS (pass_cse);
621   NEXT_PASS (pass_gcse);
622   NEXT_PASS (pass_loop_optimize);
623   NEXT_PASS (pass_jump_bypass);
624   NEXT_PASS (pass_cfg);
625   NEXT_PASS (pass_branch_prob);
626   NEXT_PASS (pass_rtl_ifcvt);
627   NEXT_PASS (pass_tracer);
628   /* Perform loop optimizations.  It might be better to do them a bit
629      sooner, but we want the profile feedback to work more
630      efficiently.  */
631   NEXT_PASS (pass_loop2);
632   NEXT_PASS (pass_web);
633   NEXT_PASS (pass_cse2);
634   NEXT_PASS (pass_life);
635   NEXT_PASS (pass_combine);
636   NEXT_PASS (pass_if_after_combine);
637   NEXT_PASS (pass_partition_blocks);
638   NEXT_PASS (pass_regmove);
639   NEXT_PASS (pass_split_all_insns);
640   NEXT_PASS (pass_mode_switching);
641   NEXT_PASS (pass_recompute_reg_usage);
642   NEXT_PASS (pass_sms);
643   NEXT_PASS (pass_sched);
644   NEXT_PASS (pass_local_alloc);
645   NEXT_PASS (pass_global_alloc);
646   NEXT_PASS (pass_postreload);
647   *p = NULL;
648 
649   p = &pass_postreload.sub;
650   NEXT_PASS (pass_postreload_cse);
651   NEXT_PASS (pass_gcse2);
652   NEXT_PASS (pass_flow2);
653   NEXT_PASS (pass_stack_adjustments);
654   NEXT_PASS (pass_peephole2);
655   NEXT_PASS (pass_if_after_reload);
656   NEXT_PASS (pass_regrename);
657   NEXT_PASS (pass_reorder_blocks);
658   NEXT_PASS (pass_branch_target_load_optimize);
659   NEXT_PASS (pass_leaf_regs);
660   NEXT_PASS (pass_sched2);
661   NEXT_PASS (pass_split_before_regstack);
662   NEXT_PASS (pass_stack_regs);
663   NEXT_PASS (pass_compute_alignments);
664   NEXT_PASS (pass_duplicate_computed_gotos);
665   NEXT_PASS (pass_variable_tracking);
666   NEXT_PASS (pass_free_cfg);
667   NEXT_PASS (pass_machine_reorg);
668   NEXT_PASS (pass_purge_lineno_notes);
669   NEXT_PASS (pass_cleanup_barriers);
670   NEXT_PASS (pass_delay_slots);
671   NEXT_PASS (pass_split_for_shorten_branches);
672   NEXT_PASS (pass_convert_to_eh_region_ranges);
673   NEXT_PASS (pass_shorten_branches);
674   NEXT_PASS (pass_set_nothrow_function_flags);
675   NEXT_PASS (pass_final);
676   *p = NULL;
677 
678 #undef NEXT_PASS
679 
680   /* Register the passes with the tree dump code.  */
681   register_dump_files (all_ipa_passes, true, PROP_gimple_leh | PROP_cfg);
682   register_dump_files (all_lowering_passes, false, PROP_gimple_any);
683   register_dump_files (all_passes, false, PROP_gimple_leh | PROP_cfg);
684 }



リンク元