From 58c9de46541ade795987b8949cfa685f02b0318a Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Thu, 5 Nov 2020 18:19:07 +0100 Subject: 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. --- gcc/gimple.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gcc/gimple.c') 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 ""; } -- cgit v1.1