diff options
author | Jan Hubicka <jh@suse.cz> | 2020-11-05 18:19:07 +0100 |
---|---|---|
committer | Jan Hubicka <jh@suse.cz> | 2020-11-05 18:19:07 +0100 |
commit | 58c9de46541ade795987b8949cfa685f02b0318a (patch) | |
tree | 611f10a41c0cdb8c0d952d3f4e210334748e4837 /gcc/gimple.c | |
parent | 9f87fcf3034d0e774c4dee380f9113d1453e0e72 (diff) | |
download | gcc-58c9de46541ade795987b8949cfa685f02b0318a.zip gcc-58c9de46541ade795987b8949cfa685f02b0318a.tar.gz gcc-58c9de46541ade795987b8949cfa685f02b0318a.tar.bz2 |
Add fnspecs for C++ new and delete operators
gcc/ChangeLog:
* gimple.c (gimple_call_fnspec): Handle C++ new and delete.
* gimple.h (gimple_call_from_new_or_delete): Constify parameter.
gcc/testsuite/ChangeLog:
* g++.dg/ipa/devirt-24.C: Update template.
Diffstat (limited to 'gcc/gimple.c')
-rw-r--r-- | gcc/gimple.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/gimple.c b/gcc/gimple.c index 469e6f3..1afed88 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1510,6 +1510,19 @@ gimple_call_fnspec (const gcall *stmt) } if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL)) return builtin_fnspec (gimple_call_fndecl (stmt)); + tree fndecl = gimple_call_fndecl (stmt); + /* If the call is to a replaceable operator delete and results + from a delete expression as opposed to a direct call to + such operator, then we can treat it as free. */ + if (fndecl + && DECL_IS_OPERATOR_DELETE_P (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) + && gimple_call_from_new_or_delete (stmt)) + return "mC"; return ""; } |