]> gcc.gnu.org Git - gcc.git/commit
tree-optimization/101373 - avoid PRE across externally throwing call
authorRichard Biener <rguenther@suse.de>
Thu, 8 Jul 2021 07:52:49 +0000 (09:52 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 12 Jul 2021 14:47:45 +0000 (16:47 +0200)
commitfedcf3c476aff7533741a1c61071200f0a38cf83
tree129cb5cb4d560a1bbfe468aa3684f0a9c2f4991a
parentfe610051a803131822bd02a8842a67b573b8e46a
tree-optimization/101373 - avoid PRE across externally throwing call

PRE already tries to avoid hoisting possibly trapping expressions
across calls that might not return normally but fails to consider
const calls that throw externally.  The following fixes that and
also plugs the hole of trapping references not pruned in case
they are not catched by the actuall call clobbering it.

At -Os we hit the same issue in RTL PRE and postreload-gcse has
even more incomplete checks so the patch adjusts both of those
as well.

2021-07-08  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101373
* tree-ssa-pre.c (prune_clobbered_mems): Also prune trapping
references when the BB may not return.
(compute_avail): Pass in the function we're working on and
replace cfun references with it.  Externally throwing
const calls also possibly terminate the function.
(pass_pre::execute): Pass down the function we're working on.
* gcse.c (compute_hash_table_work): Externally throwing
const/pure calls also need record_last_mem_set_info.
* postreload-gcse.c (record_opr_changes): Looping or externally
throwing const/pure calls also need record_last_mem_set_info.

* g++.dg/torture/pr101373.C: New testcase, XFAILed.
* gnat.dg/opt95.adb: Likewise.
gcc/gcse.c
gcc/postreload-gcse.c
gcc/testsuite/g++.dg/torture/pr101373.C [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt95.adb [new file with mode: 0644]
gcc/tree-ssa-pre.c
This page took 0.066638 seconds and 6 git commands to generate.