aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-utils.h
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2014-08-16 11:10:23 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2014-08-16 09:10:23 +0000
commit4d7cf10d2194682a8dbb606631728c612bfaf3bb (patch)
treeb907ef9a6a408c9953805ab48b6f020422eeead2 /gcc/ipa-utils.h
parent1a985ca83a4da70b0810727942e02badc70852ab (diff)
downloadgcc-4d7cf10d2194682a8dbb606631728c612bfaf3bb.zip
gcc-4d7cf10d2194682a8dbb606631728c612bfaf3bb.tar.gz
gcc-4d7cf10d2194682a8dbb606631728c612bfaf3bb.tar.bz2
ipa-utils.h (ipa_polymorphic_call_context): Turn into class; add ctors.
* ipa-utils.h (ipa_polymorphic_call_context): Turn into class; add ctors. (possible_polymorphic_call_targets, dump_possible_polymorphic_call_targets, possible_polymorphic_call_target_p, possible_polymorphic_call_target_p): Simplify. (get_dynamic_type): Remove. * ipa-devirt.c (ipa_dummy_polymorphic_call_context): Remove. (clear_speculation): Bring to ipa-deivrt.h (get_class_context): Rename to ... (ipa_polymorphic_call_context::restrict_to_inner_class): ... this one. (contains_type_p): Update. (get_dynamic_type): Rename to ... ipa_polymorphic_call_context::get_dynamic_type(): ... this one. (possible_polymorphic_call_targets): UPdate. * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Update. * ipa-prop.c (ipa_analyze_call_uses): Update. From-SVN: r214060
Diffstat (limited to 'gcc/ipa-utils.h')
-rw-r--r--gcc/ipa-utils.h82
1 files changed, 58 insertions, 24 deletions
diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h
index 30adc69..d4980eb 100644
--- a/gcc/ipa-utils.h
+++ b/gcc/ipa-utils.h
@@ -36,7 +36,9 @@ struct ipa_dfs_info {
/* Context of polymorphic call. This is used by ipa-devirt walkers of the
type inheritance graph. */
-struct ipa_polymorphic_call_context {
+
+class ipa_polymorphic_call_context {
+public:
/* The called object appears in an object of type OUTER_TYPE
at offset OFFSET. When information is not 100% reliable, we
use SPECULATIVE_OUTER_TYPE and SPECULATIVE_OFFSET. */
@@ -51,10 +53,58 @@ struct ipa_polymorphic_call_context {
/* True if speculative outer object may be of derived type. We always
speculate that construction does not happen. */
bool speculative_maybe_derived_type;
+
+ /* Build empty "I know nothing" context. */
+ ipa_polymorphic_call_context ();
+
+ /* Build polymorphic call context for indirect call E. */
+ ipa_polymorphic_call_context (cgraph_edge *e);
+
+ /* Make context non-speculative. */
+ void clear_speculation ();
+
+ /* Walk container types and modify context to point to actual class
+ containing EXPECTED_TYPE as base class. */
+ bool restrict_to_inner_class (tree expected_type);
+
+ /* Look for vtable stores or constructor calls to work out dynamic type
+ of memory location. */
+ bool get_dynamic_type (tree, tree, tree, gimple);
};
-/* Context representing "I know nothing". */
-extern const ipa_polymorphic_call_context ipa_dummy_polymorphic_call_context;
+/* Build polymorphic call context for indirect call E. */
+
+inline
+ipa_polymorphic_call_context::ipa_polymorphic_call_context (cgraph_edge *e)
+{
+ offset = e->indirect_info->offset;
+ speculative_offset = e->indirect_info->speculative_offset;
+ outer_type = e->indirect_info->outer_type;
+ speculative_outer_type = e->indirect_info->speculative_outer_type;
+ maybe_in_construction = e->indirect_info->maybe_in_construction;
+ maybe_derived_type = e->indirect_info->maybe_derived_type;
+ speculative_maybe_derived_type = e->indirect_info->speculative_maybe_derived_type;
+}
+
+/* Build empty "I know nothing" context. */
+
+inline
+ipa_polymorphic_call_context::ipa_polymorphic_call_context ()
+ : offset(0), speculative_offset(0), outer_type(NULL),
+ speculative_outer_type(NULL), maybe_in_construction(false),
+ maybe_derived_type(false), speculative_maybe_derived_type(false)
+{
+}
+
+/* Make context non-speculative. */
+
+inline void
+ipa_polymorphic_call_context::clear_speculation ()
+{
+ speculative_outer_type = NULL;
+ speculative_offset = 0;
+ speculative_maybe_derived_type = false;
+}
/* In ipa-utils.c */
void ipa_print_order (FILE*, const char *, struct cgraph_node**, int);
@@ -95,7 +145,6 @@ tree get_polymorphic_call_info (tree, tree, tree *,
HOST_WIDE_INT *,
ipa_polymorphic_call_context *,
gimple call = NULL);
-bool get_dynamic_type (tree, ipa_polymorphic_call_context *, tree, tree, gimple);
bool get_polymorphic_call_info_from_invariant (ipa_polymorphic_call_context *,
tree, tree, HOST_WIDE_INT);
bool decl_maybe_in_construction_p (tree, tree, gimple, tree);
@@ -121,13 +170,7 @@ possible_polymorphic_call_targets (struct cgraph_edge *e,
int *nonconstruction_targets = NULL)
{
gcc_checking_assert (e->indirect_info->polymorphic);
- ipa_polymorphic_call_context context = {e->indirect_info->offset,
- e->indirect_info->speculative_offset,
- e->indirect_info->outer_type,
- e->indirect_info->speculative_outer_type,
- e->indirect_info->maybe_in_construction,
- e->indirect_info->maybe_derived_type,
- e->indirect_info->speculative_maybe_derived_type};
+ ipa_polymorphic_call_context context(e);
return possible_polymorphic_call_targets (e->indirect_info->otr_type,
e->indirect_info->otr_token,
context,
@@ -163,13 +206,7 @@ inline void
dump_possible_polymorphic_call_targets (FILE *f, struct cgraph_edge *e)
{
gcc_checking_assert (e->indirect_info->polymorphic);
- ipa_polymorphic_call_context context = {e->indirect_info->offset,
- e->indirect_info->speculative_offset,
- e->indirect_info->outer_type,
- e->indirect_info->speculative_outer_type,
- e->indirect_info->maybe_in_construction,
- e->indirect_info->maybe_derived_type,
- e->indirect_info->speculative_maybe_derived_type};
+ ipa_polymorphic_call_context context(e);
dump_possible_polymorphic_call_targets (f, e->indirect_info->otr_type,
e->indirect_info->otr_token,
context);
@@ -182,11 +219,7 @@ inline bool
possible_polymorphic_call_target_p (struct cgraph_edge *e,
struct cgraph_node *n)
{
- ipa_polymorphic_call_context context = {e->indirect_info->offset, 0,
- e->indirect_info->outer_type, NULL,
- e->indirect_info->maybe_in_construction,
- e->indirect_info->maybe_derived_type,
- false};
+ ipa_polymorphic_call_context context(e);
return possible_polymorphic_call_target_p (e->indirect_info->otr_type,
e->indirect_info->otr_token,
context, n);
@@ -199,10 +232,11 @@ inline bool
possible_polymorphic_call_target_p (tree call,
struct cgraph_node *n)
{
+ ipa_polymorphic_call_context context;
return possible_polymorphic_call_target_p (obj_type_ref_class (call),
tree_to_uhwi
(OBJ_TYPE_REF_TOKEN (call)),
- ipa_dummy_polymorphic_call_context,
+ context,
n);
}
#endif /* GCC_IPA_UTILS_H */