along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
-/* Brief vocalburary:
+/* Brief vocabulary:
ODR = One Definition Rule
In short, the ODR states that:
1 In any translation unit, a template, type, function, or object can
BINFO
This is the type inheritance information attached to each tree
- RECORD_TYPE by the C++ frotend. It provides information about base
+ RECORD_TYPE by the C++ frontend. It provides information about base
types and virtual tables.
BINFO is linked to the RECORD_TYPE by TYPE_BINFO.
or from DECL_VINDEX of a given virtual table.
polymorphic (indirect) call
- This is callgraph represention of virtual method call. Every
+ This is callgraph representation of virtual method call. Every
polymorphic call contains otr_type and otr_token taken from
original OBJ_TYPE_REF at callgraph construction time.
static hash_set<cgraph_node *> *cached_polymorphic_call_targets;
/* The node of type inheritance graph. For each type unique in
- One Defintion Rule (ODR) sense, we produce one node linking all
+ One Definition Rule (ODR) sense, we produce one node linking all
main variants of types equivalent to it, bases and derived types. */
struct GTY(()) odr_type_d
{
/* leader type. */
tree type;
- /* All bases; built only for main variants of types */
+ /* All bases; built only for main variants of types. */
vec<odr_type> GTY((skip)) bases;
- /* All derrived types with virtual methods seen in unit;
- built only for main variants oftypes */
+ /* All derived types with virtual methods seen in unit;
+ built only for main variants of types. */
vec<odr_type> GTY((skip)) derived_types;
/* All equivalent types, if more than one. */
return (decl_function_context (TYPE_NAME (t)) != NULL);
}
-/* Return TURE if type's constructors are all visible. */
+/* Return TRUE if type's constructors are all visible. */
static bool
type_all_ctors_visible_p (tree t)
/* For languages with One Definition Rule, work out if
types are the same based on their name.
- This is non-trivial for LTO where minnor differences in
+ This is non-trivial for LTO where minor differences in
the type representation may have prevented type merging
to merge two copies of otherwise equivalent type.
/* ODR name of the type is set in DECL_ASSEMBLER_NAME of its TYPE_NAME.
- Ideally we should never meed types without ODR names here. It can however
+ Ideally we should never need types without ODR names here. It can however
happen in two cases:
1) for builtin types that are not streamed but rebuilt in lto/lto-lang.c
if ((!TYPE_NAME (type1) || !DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (type1)))
|| (!TYPE_NAME (type2) || !DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (type2))))
{
- /* See if types are obvoiusly different (i.e. different codes
- or polymorphis wrt non-polymorphic). This is not strictly correct
+ /* See if types are obviously different (i.e. different codes
+ or polymorphic wrt non-polymorphic). This is not strictly correct
for ODR violating programs, but we can't do better without streaming
ODR names. */
if (TREE_CODE (type1) != TREE_CODE (type2))
!= (BINFO_VTABLE (TYPE_BINFO (type2)) == NULL_TREE))
return false;
- /* At the moment we have no way to establish ODR equivlaence at LTO
- other than comparing virtual table pointrs of polymorphic types.
+ /* At the moment we have no way to establish ODR equivalence at LTO
+ other than comparing virtual table pointers of polymorphic types.
Eventually we should start saving mangled names in TYPE_NAME.
Then this condition will become non-trivial. */
ggc_free (v);
}
-/* ODR type hash used to lookup ODR type based on tree type node. */
+/* ODR type hash used to look up ODR type based on tree type node. */
typedef hash_table<odr_hasher> odr_hash_type;
static odr_hash_type *odr_hash;
return true;
}
- /* Component types, builtins and possibly vioalting ODR types
+ /* Component types, builtins and possibly violating ODR types
have to be compared structurally. */
if (TREE_CODE (t1) != TREE_CODE (t2))
return false;
}
/* Compare two virtual tables, PREVAILING and VTABLE and output ODR
- violation warings. */
+ violation warnings. */
void
compare_virtual_tables (varpool_node *prevailing, varpool_node *vtable)
&& !get_odr_type (t, true)->derived_types.length())));
}
-/* Dump ODR type T and all its derrived type. INDENT specify indentation for
- recusive printing. */
+/* Dump ODR type T and all its derived types. INDENT specifies indentation for
+ recursive printing. */
static void
dump_odr_type (FILE *f, odr_type t, int indent=0)
}
/* Given method type T, return type of class it belongs to.
- Lookup this pointer and get its type. */
+ Look up this pointer and get its type. */
tree
method_class_type (const_tree t)
target_node = cgraph_node::get (target);
- /* Preffer alias target over aliases, so we do not get confused by
+ /* Prefer alias target over aliases, so we do not get confused by
fake duplicates. */
if (target_node)
{
}
/* Method can only be called by polymorphic call if any
- of vtables refering to it are alive.
+ of vtables referring to it are alive.
While this holds for non-anonymous functions, too, there are
cases where we want to keep them in the list; for example
Currently we ignore these functions in speculative devirtualization.
??? Maybe it would make sense to be more aggressive for LTO even
- eslewhere. */
+ elsewhere. */
if (!flag_ltrans
&& type_in_anonymous_namespace_p (DECL_CONTEXT (target))
&& (!target_node
*completep = false;
}
-/* See if BINFO's type match OUTER_TYPE. If so, lookup
+/* See if BINFO's type matches OUTER_TYPE. If so, look up
BINFO of subtype of OTR_TYPE at OFFSET and in that BINFO find
method in vtable and insert method to NODES array
or BASES_TO_CONSIDER if this array is non-NULL.
Otherwise recurse to base BINFOs.
- This match what get_binfo_at_offset does, but with offset
+ This matches what get_binfo_at_offset does, but with offset
being unknown.
TYPE_BINFOS is a stack of BINFOS of types with defined
int i;
tree type_binfo = NULL;
- /* Lookup BINFO with virtual table. For normal types it is always last
+ /* Look up BINFO with virtual table. For normal types it is always last
binfo on stack. */
for (i = type_binfos.length () - 1; i >= 0; i--)
if (BINFO_OFFSET (type_binfos[i]) == BINFO_OFFSET (binfo))
/* Walk bases. */
for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
- /* Walking bases that have no virtual method is pointless excercise. */
+ /* Walking bases that have no virtual method is pointless exercise. */
if (polymorphic_type_binfo_p (base_binfo))
record_target_from_binfo (nodes, bases_to_consider, base_binfo, otr_type,
type_binfos,
type_binfos.pop ();
}
-/* Lookup virtual methods matching OTR_TYPE (with OFFSET and OTR_TOKEN)
+/* Look up virtual methods matching OTR_TYPE (with OFFSET and OTR_TOKEN)
of TYPE, insert them to NODES, recurse into derived nodes.
INSERTED is used to avoid duplicate insertions of methods into NODES.
MATCHED_VTABLES are used to avoid duplicate walking vtables.
Clear COMPLETEP if unreferable target is found.
- If CONSIDER_CONSTURCTION is true, record to BASES_TO_CONSDIER
+ If CONSIDER_CONSTRUCTION is true, record to BASES_TO_CONSIDER
all cases where BASE_SKIPPED is true (because the base is abstract
class). */
free_polymorphic_call_targets_hash ();
}
-/* Lookup base of BINFO that has virtual table VTABLE with OFFSET. */
+/* Look up base of BINFO that has virtual table VTABLE with OFFSET. */
tree
subbinfo_with_vtable_at_offset (tree binfo, unsigned HOST_WIDE_INT offset,
/* We expect &MEM[(void *)&virtual_table + 16B].
We obtain object's BINFO from the context of the virtual table.
This one contains pointer to virtual table represented via
- POINTER_PLUS_EXPR. Verify that this pointer match to what
+ POINTER_PLUS_EXPR. Verify that this pointer matches what
we propagated through.
In the case of virtual inheritance, the virtual tables may
because we do not have BINFO for those. Eventually we should fix
our representation to allow this case to be handled, too.
In the case we see store of BINFO we however may assume
- that standard folding will be ale to cope with it. */
+ that standard folding will be able to cope with it. */
return subbinfo_with_vtable_at_offset (TYPE_BINFO (DECL_CONTEXT (vtable)),
offset, vtable);
}
/* Walk bases of OUTER_TYPE that contain OTR_TYPE at OFFSET.
- Lookup their respecitve virtual methods for OTR_TOKEN and OTR_TYPE
- and insert them to NODES.
+ Look up their respective virtual methods for OTR_TOKEN and OTR_TYPE
+ and insert them in NODES.
MATCHED_VTABLES and INSERTED is used to avoid duplicated work. */
&& polymorphic_type_binfo_p (TYPE_BINFO (TREE_TYPE (fld))))
break;
}
- /* Within a class type we should always find correcponding fields. */
+ /* Within a class type we should always find corresponding fields. */
gcc_assert (fld && TREE_CODE (TREE_TYPE (fld)) == RECORD_TYPE);
- /* Nonbasetypes should have been stripped by outer_class_type. */
+ /* Nonbase types should have been stripped by outer_class_type. */
gcc_assert (DECL_ARTIFICIAL (fld));
outer_type = TREE_TYPE (fld);
struct final_warning_record *final_warning_records;
/* Return vector containing possible targets of polymorphic call of type
- OTR_TYPE caling method OTR_TOKEN within type of OTR_OUTER_TYPE and OFFSET.
- If INCLUDE_BASES is true, walk also base types of OUTER_TYPES containig
+ OTR_TYPE calling method OTR_TOKEN within type of OTR_OUTER_TYPE and OFFSET.
+ If INCLUDE_BASES is true, walk also base types of OUTER_TYPES containing
OTR_TYPE and include their virtual method. This is useful for types
possibly in construction or destruction where the virtual table may
temporarily change to one of base types. INCLUDE_DERIVER_TYPES make
otr_type = TYPE_MAIN_VARIANT (otr_type);
- /* If ODR is not initialized or the constext is invalid, return empty
+ /* If ODR is not initialized or the context is invalid, return empty
incomplete list. */
if (!odr_hash || context.invalid || !TYPE_BINFO (otr_type))
{
type = get_odr_type (otr_type, true);
- /* Recording type variants would wast results cache. */
+ /* Recording type variants would waste results cache. */
gcc_assert (!context.outer_type
|| TYPE_MAIN_VARIANT (context.outer_type) == context.outer_type);
- /* Lookup the outer class type we want to walk.
+ /* Look up the outer class type we want to walk.
If we fail to do so, the context is invalid. */
if ((context.outer_type || context.speculative_outer_type)
&& !context.restrict_to_inner_class (otr_type))
/* We canonicalize our query, so we do not need extra hashtable entries. */
/* Without outer type, we have no use for offset. Just do the
- basic search from innter type */
+ basic search from inner type. */
if (!context.outer_type)
context.clear_outer_type (otr_type);
- /* We need to update our hiearchy if the type does not exist. */
+ /* We need to update our hierarchy if the type does not exist. */
outer_type = get_odr_type (context.outer_type, true);
/* If the type is complete, there are no derivations. */
if (TYPE_FINAL_P (outer_type->type))
= get_odr_type (context.speculative_outer_type, true)->type;
}
- /* Lookup cached answer. */
+ /* Look up cached answer. */
key.type = type;
key.otr_token = otr_token;
key.speculative = speculative;
odr_type speculative_outer_type;
bool speculation_complete = true;
- /* First insert target from type itself and check if it may have derived types. */
+ /* First insert target from type itself and check if it may have
+ derived types. */
speculative_outer_type = get_odr_type (context.speculative_outer_type, true);
if (TYPE_FINAL_P (speculative_outer_type->type))
context.speculative_maybe_derived_type = false;
if (!speculative)
{
/* Destructors are never called through construction virtual tables,
- because the type is always known. One of entries may be cxa_pure_virtual
- so look to at least two of them. */
+ because the type is always known. One of entries may be
+ cxa_pure_virtual so look to at least two of them. */
if (context.maybe_in_construction)
for (i =0 ; i < MIN (nodes.length (), 2); i++)
if (DECL_CXX_DESTRUCTOR_P (nodes[i]->decl))
return false;
if (n->frequency < NODE_FREQUENCY_NORMAL)
return false;
- /* If there are no virtual tables refering the target alive,
- the only way the target can be called is an instance comming from other
- compilation unit; speculative devirtualization is build around an
+ /* If there are no live virtual tables referring the target,
+ the only way the target can be called is an instance coming from other
+ compilation unit; speculative devirtualization is built around an
assumption that won't happen. */
if (!referenced_from_vtable_p (n))
return false;
return true;
}
-/* Compare type warning records P1 and P2 and chose one with larger count;
+/* Compare type warning records P1 and P2 and choose one with larger count;
helper for qsort. */
int
return t2->count - t1->count;
}
-/* Compare decl warning records P1 and P2 and chose one with larger count;
+/* Compare decl warning records P1 and P2 and choose one with larger count;
helper for qsort. */
int
}
-/* Try speculatively devirtualize call to OTR_TYPE with OTR_TOKEN with
+/* Try to speculatively devirtualize call to OTR_TYPE with OTR_TOKEN with
context CTX. */
struct cgraph_node *
/* The ipa-devirt pass.
When polymorphic call has only one likely target in the unit,
- turn it into speculative call. */
+ turn it into a speculative call. */
static unsigned int
ipa_devirt (void)
if (e->speculative)
{
if (dump_file)
- fprintf (dump_file, "Call is aready speculated\n\n");
+ fprintf (dump_file, "Call is already speculated\n\n");
nspeculated++;
/* When dumping see if we agree with speculation. */
if (!likely_target->definition)
{
if (dump_file)
- fprintf (dump_file, "Target is not an definition\n\n");
+ fprintf (dump_file, "Target is not a definition\n\n");
nnotdefined++;
continue;
}