Thanks, the cause has now been identified. ipa-get_fun is placed after ipa-cp and before ipa-inline. Its call stack is as follows: #0 cgraph_edge::remove_caller #1 cgraph_edge::remove #2 delete_unreachable_blocks_update_callgraph #3 tree_function_versioning #4 cgraph_node::materialize_clone #5 cgraph_node::get_untransformed_body #6 get_all_nodes_untransformed_body #7 ipa_get_fun::execute #8 execute_one_pass #9 execute_ipa_pass_list #10 do_whole_program_analysis #11 lto_main #12 compile_file #13 do_compile #14 toplev::main #15 main
so cgraph_node::get_untransformed_body removed some edges in ipa-get_fun's WPA phase, which caused the assertion error in ipa-inline's WPA phase. However, I observed that the `cgraph_node::get_untransformed_body` function is also called within the `execute` function of the IPA-ICF WPA phase. The call stack is as follows, but no error was reported. Therefore, I want to know how can we prevent errors from occurring when calling `cgraph_node::get_untransformed_body`? pass_ipa_icf::execute ipa_icf_driver optimizer->execute merge_classes source->merge ipa_merge_profiles src->get_untransformed_body Martin Jambor <[email protected]> 于2025年11月4日周二 07:22写道: > On Mon, Nov 03 2025, ywgrit via Gcc wrote: > > I wrote an IPA PASS in the plugin: ipa-get_fun. This IPA PASS is placed > > before ipa-inline. The `generate_summary`, `write_summary`, > `read_summary`, > > `write_optimization_summary`, and `read_optimization_summary` functions > in > > `ipa-get_fun` do nothing—they are empty. In the `execute` function of > the > > WPA phase for `ipa-get_fun`, only the following code exists: it retrieves > > the function bodies for each function. cgraph_node *n; > > cgraph_node *n; > > FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (n) > > { > > if (n && n->decl) > > { > > n->get_untransformed_body (); > > } > > } > > > > > > Immediately afterward, within the execute function of the WPA phase in > > IPA-inline, estimate_calls_size_and_time was invoked. The following > segment > > of code in estimate_calls_size_and_time encountered an assertion error. > > estimate_calls_size_and_time_1 (node, &old_size, NULL, &old_time, NULL, > > possible_truths, avals); > > gcc_assert (*size == old_size); > > > > > > In this case, *size == 20 and old_size == 14. Why is this happening, and > > can I access the function body in this manner within the execute function > > of a WPA phase in an IPA PASS? > > IPA-ICF uses it to get at the body of functions it needs to compare in > detail (when hashes generated in generate_summary match), so it can be > used. But in order to scale, it should only be used seldomly, in > special circumstances. > > In any case I'm afraid that you'll need to debug yourself why you are > hitting the assert, why the size estimate differs.. I think it should > not happen though. > > Martin >
