Add -f{,no-}assume-sane-operators-new-delete options [PR110137]
The following patch adds a new option for optimizations related to replaceable global operators new/delete. The option isn't called -fassume-sane-operator-new (which clang++ implements), because 1) clang++ option means something different; initially it was an option to add malloc attribute to those declarations (but we have malloc attribute on all <new> calls already unconditionally); later it was changed to add noalias attribute rather than malloc, whatever it means, but it is certainly about the return value from the operator new (whether it can alias with other pointers); we already assume malloc-ish behavior that it doesn't alias any other pointers 2) the option only affects operator new, we want it affect also operator delete The option basically allows to choose between pre-PR101480 behavior (now the default, more optimistic) and post-PR101480 behavior (safer but penalizing most of the code in the wild for rare needs). I've tried to explain stuff in the documentation too. 2024-11-22 Jakub Jelinek <jakub@redhat.com> PR c++/110137 PR middle-end/101480 gcc/ * doc/invoke.texi (-fassume-sane-operators-new-delete, -fno-assume-sane-operators-new-delete): Document. * gimple.cc (gimple_call_fnspec): Handle -f{,no-}assume-sane-operators-new-delete. * ipa-inline-transform.cc (inline_call): Also clear flag_assume_sane_operators_new_delete on caller when inlining -fno-assume-sane-operators-new-delete callee into -fassume-sane-operators-new-delete caller. gcc/c-family/ * c.opt (fassume-sane-operators-new-delete): New option. gcc/testsuite/ * g++.dg/tree-ssa/pr110137-1.C: New test. * g++.dg/tree-ssa/pr110137-2.C: New test. * g++.dg/tree-ssa/pr110137-3.C: New test. * g++.dg/tree-ssa/pr110137-4.C: New test. * g++.dg/torture/pr10148.C: Add -fno-assume-sane-operators-new-delete as dg-additional-options. * g++.dg/warn/Warray-bounds-16.C: Revert 2021-11-10 changes.
Showing
- gcc/c-family/c.opt 4 additions, 0 deletionsgcc/c-family/c.opt
- gcc/doc/invoke.texi 32 additions, 1 deletiongcc/doc/invoke.texi
- gcc/gimple.cc 12 additions, 2 deletionsgcc/gimple.cc
- gcc/ipa-inline-transform.cc 22 additions, 6 deletionsgcc/ipa-inline-transform.cc
- gcc/testsuite/g++.dg/torture/pr10148.C 1 addition, 0 deletionsgcc/testsuite/g++.dg/torture/pr10148.C
- gcc/testsuite/g++.dg/tree-ssa/pr110137-1.C 74 additions, 0 deletionsgcc/testsuite/g++.dg/tree-ssa/pr110137-1.C
- gcc/testsuite/g++.dg/tree-ssa/pr110137-2.C 74 additions, 0 deletionsgcc/testsuite/g++.dg/tree-ssa/pr110137-2.C
- gcc/testsuite/g++.dg/tree-ssa/pr110137-3.C 76 additions, 0 deletionsgcc/testsuite/g++.dg/tree-ssa/pr110137-3.C
- gcc/testsuite/g++.dg/tree-ssa/pr110137-4.C 124 additions, 0 deletionsgcc/testsuite/g++.dg/tree-ssa/pr110137-4.C
- gcc/testsuite/g++.dg/warn/Warray-bounds-16.C 3 additions, 3 deletionsgcc/testsuite/g++.dg/warn/Warray-bounds-16.C
Loading
Please register or sign in to comment