On 3/22/23 06:29, Richard Biener via Gcc-patches wrote:
Most uses of last_stmt are interested in control transfer stmts
and for the testcase gimple_purge_dead_eh_edges shows up in
the profile. But last_stmt looks past trailing debug stmts but
those would be rejected by GIMPLEs verify_flow_info. The following
adds possible_ctrl_stmt besides last_stmt which does not look
past trailing debug stmts and adjusts gimple_purge_dead_eh_edges.
I've put checking code into possible_ctrl_stmt that it will not
miss a control statement if the real last stmt is a debug stmt.
The alternative would be to change last_stmt, explicitely introducing
last_nondebug_stmt. I remember we chickened out and made last_stmt
conservative here but not anticipating the compile-time issues this
creates. I count 227 last_stmt and 12 last_and_only_stmt uses.
Bootstrapped and tested on x86_64-unknown-linux-gnu.
Any opinions? I probably lean towards s/last_stmt/last_nondebug_stmt/
in next stage1 and then adding last_stmt and changing some
uses back - through for maintainance that's going to be a
nightmare (or maybe not, a "wrong" last_stmt should be safe to
backport and a last_nondebug_stmt will fail to build).
Sounds quite sensible to me. 227+12 isn't terrible and I bet the vast
majority, should be safe for last_nondebug_stmt.
Richard.
PR tree-optimization/109237
* tree-cfg.h (possible_ctrl_stmt): New function returning
the last stmt not skipping debug stmts.
(gimple_purge_dead_eh_edges): Use it.
OK
jeff