diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-12-04 19:10:56 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-12-04 19:10:56 +0100 |
commit | 78c4a9feceaccf487516aa1eff417e0741556e10 (patch) | |
tree | 7859396b43ee48402bc959acd0bc4572bb0ee56a /gcc/gimple.c | |
parent | ac2a6962b91128e700ee52db686dcdb2bab93790 (diff) | |
download | gcc-78c4a9feceaccf487516aa1eff417e0741556e10.zip gcc-78c4a9feceaccf487516aa1eff417e0741556e10.tar.gz gcc-78c4a9feceaccf487516aa1eff417e0741556e10.tar.bz2 |
gimple: Return fnspec only for replaceable new/delete operators called from new/delete [PR98130]
As mentioned in the PR, we shouldn't treat non-replaceable operator
new/delete (e.g. with the placement new) as replaceable ones.
There is some pending discussion that perhaps operator delete called from
delete if not replaceable should return some other fnspec, but can we handle
that incrementally, fix this wrong-code and then deal with a missed
optimization? I really don't know what exactly should be returned.
2020-12-04 Jakub Jelinek <jakub@redhat.com>
PR c++/98130
* gimple.c (gimple_call_fnspec): Only return ".co " for replaceable
operator delete or ".mC" for replaceable operator new called from
new/delete.
* g++.dg/opt/pr98130.C: New test.
Diffstat (limited to 'gcc/gimple.c')
-rw-r--r-- | gcc/gimple.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/gimple.c b/gcc/gimple.c index e8246b7..bb13458 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1514,11 +1514,12 @@ gimple_call_fnspec (const gcall *stmt) such operator, then we can treat it as free. */ if (fndecl && DECL_IS_OPERATOR_DELETE_P (fndecl) + && DECL_IS_REPLACEABLE_OPERATOR (fndecl) && gimple_call_from_new_or_delete (stmt)) return ".co "; /* Similarly operator new can be treated as malloc. */ if (fndecl - && DECL_IS_OPERATOR_NEW_P (fndecl) + && DECL_IS_REPLACEABLE_OPERATOR_NEW_P (fndecl) && gimple_call_from_new_or_delete (stmt)) return "mC"; return ""; |