- /* Try to insert the new pass to the pass lists. We need to check all
- three lists as the reference pass could be in one (or all) of them. */
- if (!position_pass (pass_info, &all_lowering_passes)
- && !position_pass (pass_info, &all_small_ipa_passes)
- && !position_pass (pass_info, &all_regular_ipa_passes)
- && !position_pass (pass_info, &all_lto_gen_passes)
- && !position_pass (pass_info, &all_passes))
- gcc_unreachable ();
- else
+ if (!pass_info->reference_pass_name)
+ fatal_error
+ ("plugin cannot register pass %qs without reference pass name",
+ pass_info->pass->name);
+
+ /* Try to insert the new pass to the pass lists. We need to check
+ all five lists as the reference pass could be in one (or all) of
+ them. */
+ all_instances = pass_info->ref_pass_instance_number == 0;
+ success = position_pass (pass_info, &all_lowering_passes);
+ if (!success || all_instances)
+ success |= position_pass (pass_info, &all_small_ipa_passes);
+ if (!success || all_instances)
+ success |= position_pass (pass_info, &all_regular_ipa_passes);
+ if (!success || all_instances)
+ success |= position_pass (pass_info, &all_lto_gen_passes);
+ if (!success || all_instances)
+ success |= position_pass (pass_info, &all_passes);
+ if (!success)
+ fatal_error
+ ("pass %qs not found but is referenced by new pass %qs",
+ pass_info->reference_pass_name, pass_info->pass->name);
+
+ /* OK, we have successfully inserted the new pass. We need to register
+ the dump files for the newly added pass and its duplicates (if any).
+ Because the registration of plugin/backend passes happens after the
+ command-line options are parsed, the options that specify single
+ pass dumping (e.g. -fdump-tree-PASSNAME) cannot be used for new
+ passes. Therefore we currently can only enable dumping of
+ new passes when the 'dump-all' flags (e.g. -fdump-tree-all)
+ are specified. While doing so, we also delete the pass_list_node
+ objects created during pass positioning. */
+ while (added_pass_nodes)