https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91508
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> --- @Richard: For the proper fix, I would like to backport following 3 commits from trunk: commit a413f183a85bc9a08e3dcd9e9d617086fce86460 (HEAD -> backport-9-v6, origin/backport-9-v6) Author: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Thu Aug 15 06:58:36 2019 +0000 Backport r274504 gcc/ChangeLog: 2019-08-15 Martin Liska <mli...@suse.cz> PR ipa/91438 * cgraph.c (cgraph_node::remove): When setting n->origin = NULL for all nested functions, reset also next_nested. commit 7fad5cd74a282bc49b14c4d9a5a95b3d1a212394 Author: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Thu Aug 15 06:58:26 2019 +0000 Backport r274503 gcc/ChangeLog: 2019-08-15 Martin Liska <mli...@suse.cz> * cgraph.c (cgraph_node::verify_node): Verify origin, nested and next_nested. commit ebcb363be811c20d678dc7b985e68ca86afe4707 Author: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Thu Aug 15 06:58:09 2019 +0000 Backport r274502 gcc/ChangeLog: 2019-08-15 Martin Liska <mli...@suse.cz> PR ipa/91404 * passes.c (order): Remove. (uid_hash_t): Likewise). (remove_cgraph_node_from_order): Remove from set of pointers (cgraph_node *). (insert_cgraph_node_to_order): New. (duplicate_cgraph_node_to_order): New. (do_per_function_toporder): Register all 3 cgraph hooks. Skip removed_nodes now as we know about all of them. I've just tested that on x86_64-linux-gnu. Are you fine with that approach?