summaryrefslogtreecommitdiff
path: root/gcc/ipa-pure-const.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-01 12:09:16 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-01 12:09:16 +0000
commit1ee39ad10f3f6ef908c13c719397efed2156be2c (patch)
treec297be68d5ea3a6f11285be55676f17deb42f50b /gcc/ipa-pure-const.c
parent90b41bfa1b2a6e36eba791299cdd2a9d44d27a55 (diff)
downloadgcc-1ee39ad10f3f6ef908c13c719397efed2156be2c.tar.gz
2010-06-01 Richard Guenther <rguenther@suse.de>
PR lto/43853 * ipa-pure-const.c (get_function_state): Hand back varying state if we do not have one. (has_function_state): New function. (duplicate_node_data): Adjust. (remove_node_data): Likewise. (pure_const_write_summary): Likewise. (propagate): Likewise. Fix typo. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160099 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ipa-pure-const.c')
-rw-r--r--gcc/ipa-pure-const.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index 54238856e90..3bea566b510 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -186,14 +186,28 @@ finish_state (void)
}
+/* Return true if we have a function state for NODE. */
+
+static inline bool
+has_function_state (struct cgraph_node *node)
+{
+ if (!funct_state_vec
+ || VEC_length (funct_state, funct_state_vec) <= (unsigned int)node->uid)
+ return false;
+ return VEC_index (funct_state, funct_state_vec, node->uid) != NULL;
+}
+
/* Return the function state from NODE. */
static inline funct_state
get_function_state (struct cgraph_node *node)
{
+ static struct funct_state_d varying
+ = { IPA_NEITHER, IPA_NEITHER, true, true, true };
if (!funct_state_vec
|| VEC_length (funct_state, funct_state_vec) <= (unsigned int)node->uid)
- return NULL;
+ /* We might want to put correct previously_known state into varying. */
+ return &varying;
return VEC_index (funct_state, funct_state_vec, node->uid);
}
@@ -712,10 +726,10 @@ static void
duplicate_node_data (struct cgraph_node *src, struct cgraph_node *dst,
void *data ATTRIBUTE_UNUSED)
{
- if (get_function_state (src))
+ if (has_function_state (src))
{
funct_state l = XNEW (struct funct_state_d);
- gcc_assert (!get_function_state (dst));
+ gcc_assert (!has_function_state (dst));
memcpy (l, get_function_state (src), sizeof (*l));
set_function_state (dst, l);
}
@@ -726,7 +740,7 @@ duplicate_node_data (struct cgraph_node *src, struct cgraph_node *dst,
static void
remove_node_data (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
{
- if (get_function_state (node))
+ if (has_function_state (node))
{
free (get_function_state (node));
set_function_state (node, NULL);
@@ -799,7 +813,7 @@ pure_const_write_summary (cgraph_node_set set,
for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
{
node = csi_node (csi);
- if (node->analyzed && get_function_state (node) != NULL)
+ if (node->analyzed && has_function_state (node))
count++;
}
@@ -809,7 +823,7 @@ pure_const_write_summary (cgraph_node_set set,
for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
{
node = csi_node (csi);
- if (node->analyzed && get_function_state (node) != NULL)
+ if (node->analyzed && has_function_state (node))
{
struct bitpack_d *bp;
funct_state fs;
@@ -1041,8 +1055,8 @@ propagate (void)
pure_const_names[y_l->pure_const_state],
y_l->looping);
}
- else if (y_l->pure_const_state > ECF_PURE
- && cgraph_edge_cannot_lead_to_return (e))
+ if (y_l->pure_const_state > ECF_PURE
+ && cgraph_edge_cannot_lead_to_return (e))
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
@@ -1259,7 +1273,8 @@ propagate (void)
free (node->aux);
node->aux = NULL;
}
- if (cgraph_function_body_availability (node) >= AVAIL_OVERWRITABLE)
+ if (cgraph_function_body_availability (node) >= AVAIL_OVERWRITABLE
+ && has_function_state (node))
free (get_function_state (node));
}