[gcc(refs/users/aoliva/heads/testme)] [strub] tolerate call_stmt-less cgraph_edges
Alexandre Oliva
aoliva@gcc.gnu.org
Fri Jun 9 06:18:03 GMT 2023
https://gcc.gnu.org/g:88546c1d5326c907a9e38cd574423812c720f84a
commit 88546c1d5326c907a9e38cd574423812c720f84a
Author: Alexandre Oliva <oliva@adacore.com>
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 %<strub%> 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 %<strub%> "
"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;
More information about the Gcc-cvs
mailing list