aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2017-02-08 10:47:09 +0100
committerMartin Jambor <jamborm@gcc.gnu.org>2017-02-08 10:47:09 +0100
commit159f01f8a9bcc92e142ab70ad0df57f371db1096 (patch)
tree24264722d83b83fd458ec440fd846ad648c70a87 /gcc
parent50c1f4a5e1d41701ee9fcf251c3ce9ad37a51329 (diff)
downloadgcc-159f01f8a9bcc92e142ab70ad0df57f371db1096.zip
gcc-159f01f8a9bcc92e142ab70ad0df57f371db1096.tar.gz
gcc-159f01f8a9bcc92e142ab70ad0df57f371db1096.tar.bz2
[PR 79375] Avoid passing NULL by reference
2017-02-08 Martin Jambor <mjambor@suse.cz> PR ipa/79375 * ipa-prop.c (ipa_alloc_node_params): Make static, return bool whether allocation happened. (ipa_initialize_node_params): Do not call ipa_alloc_node_params if nothing was allocated. From-SVN: r245275
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/ipa-prop.c21
2 files changed, 20 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 67dc9b1..eea8bc7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2017-02-08 Martin Jambor <mjambor@suse.cz>
+
+ PR ipa/79375
+ * ipa-prop.c (ipa_alloc_node_params): Make static, return bool
+ whether allocation happened.
+ (ipa_initialize_node_params): Do not call ipa_alloc_node_params if
+ nothing was allocated.
+
2017-02-08 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/79408
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index d031a70..e4e44ce 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -176,16 +176,21 @@ ipa_dump_param (FILE *file, struct ipa_node_params *info, int i)
}
}
-/* Initialize the ipa_node_params structure associated with NODE
- to hold PARAM_COUNT parameters. */
+/* If necessary, allocate vector of parameter descriptors in info of NODE.
+ Return true if they were allocated, false if not. */
-void
+static bool
ipa_alloc_node_params (struct cgraph_node *node, int param_count)
{
struct ipa_node_params *info = IPA_NODE_REF (node);
if (!info->descriptors && param_count)
- vec_safe_grow_cleared (info->descriptors, param_count);
+ {
+ vec_safe_grow_cleared (info->descriptors, param_count);
+ return true;
+ }
+ else
+ return false;
}
/* Initialize the ipa_node_params structure associated with NODE by counting
@@ -197,11 +202,9 @@ ipa_initialize_node_params (struct cgraph_node *node)
{
struct ipa_node_params *info = IPA_NODE_REF (node);
- if (!info->descriptors)
- {
- ipa_alloc_node_params (node, count_formal_params (node->decl));
- ipa_populate_param_decls (node, *info->descriptors);
- }
+ if (!info->descriptors
+ && ipa_alloc_node_params (node, count_formal_params (node->decl)))
+ ipa_populate_param_decls (node, *info->descriptors);
}
/* Print the jump functions associated with call graph edge CS to file F. */