diff options
author | Richard Biener <rguenther@suse.de> | 2023-06-28 11:27:45 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-06-28 15:52:16 +0200 |
commit | 4bf76b5b6db8e68755788ec91012c5a686440720 (patch) | |
tree | 623444b0bf98311c63d488beea66f18acc570e81 | |
parent | c7e87e82435b918084f305386b12b8fbcdcf3307 (diff) | |
download | gcc-4bf76b5b6db8e68755788ec91012c5a686440720.zip gcc-4bf76b5b6db8e68755788ec91012c5a686440720.tar.gz gcc-4bf76b5b6db8e68755788ec91012c5a686440720.tar.bz2 |
tree-optimization/110434 - avoid <retval> ={v} {CLOBBER} from NRV
When NRV replaces a local variable with <retval> it also replaces
occurences in clobbers. This leads to <retval> being clobbered
before the return of it which is strictly invalid but harmless in
practice since there's no pass after NRV which would remove
earlier stores.
The following fixes this nevertheless.
PR tree-optimization/110434
* tree-nrv.cc (pass_nrv::execute): Remove CLOBBERs of
VAR we replace with <retval>.
-rw-r--r-- | gcc/tree-nrv.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/tree-nrv.cc b/gcc/tree-nrv.cc index ff47439..99c4e21 100644 --- a/gcc/tree-nrv.cc +++ b/gcc/tree-nrv.cc @@ -264,7 +264,17 @@ pass_nrv::execute (function *fun) data.modified = 0; walk_gimple_op (stmt, finalize_nrv_r, &wi); if (data.modified) - update_stmt (stmt); + { + /* If this is a CLOBBER of VAR, remove it. */ + if (gimple_clobber_p (stmt)) + { + unlink_stmt_vdef (stmt); + gsi_remove (&gsi, true); + release_defs (stmt); + continue; + } + update_stmt (stmt); + } gsi_next (&gsi); } } |