From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id 4073F3857726; Thu, 8 Jun 2023 10:44:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4073F3857726 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686221049; bh=HvHuJJimJoIWslKfEJaPt9JIel/Q8B3qDzaxZHUfs+8=; h=From:To:Subject:Date:From; b=wywzptxEL9Ww7Ld3BcEtngMdiCbgsOCUezUtSS12haRsrK+dQFhFi11Gjskeizi20 1E9MvCNLUxqFN4kJhBwv4JgqphZQ+ET5TRDEhKdWRZEahD5kzhmvmkE3Z9ego4XYZ0 aUsJJW3/9esTSw7hpPq2HcosIOnmEfzEggCFDoTI= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] [strub] tolerate call_stmt-less cgraph_edges X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: c46fded1c6f46a99d06b61cc1f07c4ab0f8a027f X-Git-Newrev: fa9110205846042e518a22d591d0ec92ff59d2ca Message-Id: <20230608104409.4073F3857726@sourceware.org> Date: Thu, 8 Jun 2023 10:44:09 +0000 (GMT) List-Id: https://gcc.gnu.org/g:fa9110205846042e518a22d591d0ec92ff59d2ca commit fa9110205846042e518a22d591d0ec92ff59d2ca Author: Alexandre Oliva Date: Thu Jun 8 01:44:03 2023 -0300 [strub] tolerate call_stmt-less cgraph_edges cgraph::analyze creates cgraph_edges without call_stmt for thunks. Skip edges without a call_stmt all over. for gcc/ChangeLog * ipa-strub.cc (calls_builtin_apply_args_p): Check for NULL call_stmt in cgraph_edges. (called_directly_with_type_override_p): Likewise. (can_strub_internally_p): Likewise. (distinctify_node_type): Likewise. (verify_strub): Likewise. (pass_ipa_strub::adjust_at_calls_calls): Likewise. (pass_ipa_strub::execute): Likewise. (pass_ipa_strub::adjust_at_calls_call): Require a call_stmt. Diff: --- gcc/ipa-strub.cc | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc index d61b7e2e36e..5fc4fca550d 100644 --- a/gcc/ipa-strub.cc +++ b/gcc/ipa-strub.cc @@ -489,7 +489,9 @@ calls_builtin_apply_args_p (cgraph_node *node, bool report = false) if (!report) break; - sorry_at (gimple_location (e->call_stmt), + sorry_at (e->call_stmt + ? gimple_location (e->call_stmt) + : DECL_SOURCE_LOCATION (node->decl), "at-calls % does not support call to %qD", cdecl); } @@ -607,7 +609,7 @@ static bool called_directly_with_type_override_p (cgraph_node *node, void *) { for (cgraph_edge *e = node->callers; e; e = e->next_caller) - if (strub_call_fntype_override_p (e->call_stmt)) + if (e->call_stmt && strub_call_fntype_override_p (e->call_stmt)) return true; return false; @@ -694,7 +696,9 @@ can_strub_internally_p (cgraph_node *node, bool report = false) if (!report) return result; - sorry_at (gimple_location (e->call_stmt), + sorry_at (e->call_stmt + ? gimple_location (e->call_stmt) + : DECL_SOURCE_LOCATION (node->decl), "%qD is not eligible for internal % " "because it calls %qD", node->decl, cdecl); @@ -1428,6 +1432,8 @@ distinctify_node_type (cgraph_node *node) we'll adjust their fntypes then. */ for (cgraph_edge *e = node->callers; e; e = e->next_caller) { + if (!e->call_stmt) + continue; tree fnaddr = gimple_call_fn (e->call_stmt); gcc_checking_assert (TREE_CODE (fnaddr) == ADDR_EXPR && TREE_OPERAND (fnaddr, 0) == node->decl); @@ -1494,6 +1500,9 @@ verify_strub () { gcc_checking_assert (e->indirect_unknown_callee); + if (!e->call_stmt) + continue; + enum strub_mode callee_mode = effective_strub_mode_for_call (e->call_stmt, NULL); @@ -1507,6 +1516,9 @@ verify_strub () { gcc_checking_assert (!e->indirect_unknown_callee); + if (!e->call_stmt) + continue; + tree callee_fntype; enum strub_mode callee_mode = effective_strub_mode_for_call (e->call_stmt, &callee_fntype); @@ -2282,6 +2294,7 @@ void pass_ipa_strub::adjust_at_calls_call (cgraph_edge *e, int named_args, tree callee_fntype) { + gcc_checking_assert (e->call_stmt); gcall *ocall = e->call_stmt; gimple_stmt_iterator gsi = gsi_for_stmt (ocall); @@ -2458,6 +2471,9 @@ pass_ipa_strub::adjust_at_calls_calls (cgraph_node *node) { gcc_checking_assert (e->indirect_unknown_callee); + if (!e->call_stmt) + continue; + tree callee_fntype; enum strub_mode callee_mode = effective_strub_mode_for_call (e->call_stmt, &callee_fntype); @@ -2480,6 +2496,9 @@ pass_ipa_strub::adjust_at_calls_calls (cgraph_node *node) { gcc_checking_assert (!e->indirect_unknown_callee); + if (!e->call_stmt) + continue; + tree callee_fntype; enum strub_mode callee_mode = effective_strub_mode_for_call (e->call_stmt, &callee_fntype); @@ -3283,6 +3302,9 @@ pass_ipa_strub::execute (function *) || is_stdarg || apply_args) for (cgraph_edge *e = nnode->callees, *enext; e; e = enext) { + if (!e->call_stmt) + continue; + gcall *call = e->call_stmt; gimple_stmt_iterator gsi = gsi_for_stmt (call); tree fndecl = e->callee->decl;