本文整理汇总了C++中DECL_COMDAT函数的典型用法代码示例。如果您正苦于以下问题:C++ DECL_COMDAT函数的具体用法?C++ DECL_COMDAT怎么用?C++ DECL_COMDAT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DECL_COMDAT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DECL_DECLARED_INLINE_P
void
symtab_node::fixup_same_cpp_alias_visibility (symtab_node *target)
{
if (is_a <cgraph_node *> (this))
{
DECL_DECLARED_INLINE_P (decl)
= DECL_DECLARED_INLINE_P (target->decl);
DECL_DISREGARD_INLINE_LIMITS (decl)
= DECL_DISREGARD_INLINE_LIMITS (target->decl);
}
/* FIXME: It is not really clear why those flags should not be copied for
functions, too. */
else
{
DECL_WEAK (decl) = DECL_WEAK (target->decl);
DECL_EXTERNAL (decl) = DECL_EXTERNAL (target->decl);
DECL_VISIBILITY (decl) = DECL_VISIBILITY (target->decl);
}
DECL_VIRTUAL_P (decl) = DECL_VIRTUAL_P (target->decl);
if (TREE_PUBLIC (decl))
{
tree group;
DECL_EXTERNAL (decl) = DECL_EXTERNAL (target->decl);
DECL_COMDAT (decl) = DECL_COMDAT (target->decl);
group = target->get_comdat_group ();
set_comdat_group (group);
if (group && !same_comdat_group)
add_to_same_comdat_group (target);
}
externally_visible = target->externally_visible;
}
示例2: fixup_same_cpp_alias_visibility
void
fixup_same_cpp_alias_visibility (symtab_node node, symtab_node target)
{
if (is_a <cgraph_node> (node))
{
DECL_DECLARED_INLINE_P (node->symbol.decl)
= DECL_DECLARED_INLINE_P (target->symbol.decl);
DECL_DISREGARD_INLINE_LIMITS (node->symbol.decl)
= DECL_DISREGARD_INLINE_LIMITS (target->symbol.decl);
}
/* FIXME: It is not really clear why those flags should not be copied for
functions, too. */
else
{
DECL_WEAK (node->symbol.decl) = DECL_WEAK (target->symbol.decl);
DECL_EXTERNAL (node->symbol.decl) = DECL_EXTERNAL (target->symbol.decl);
DECL_VISIBILITY (node->symbol.decl) = DECL_VISIBILITY (target->symbol.decl);
}
DECL_VIRTUAL_P (node->symbol.decl) = DECL_VIRTUAL_P (target->symbol.decl);
if (TREE_PUBLIC (node->symbol.decl))
{
DECL_EXTERNAL (node->symbol.decl) = DECL_EXTERNAL (target->symbol.decl);
DECL_COMDAT (node->symbol.decl) = DECL_COMDAT (target->symbol.decl);
DECL_COMDAT_GROUP (node->symbol.decl)
= DECL_COMDAT_GROUP (target->symbol.decl);
if (DECL_ONE_ONLY (target->symbol.decl)
&& !node->symbol.same_comdat_group)
symtab_add_to_same_comdat_group ((symtab_node)node, (symtab_node)target);
}
node->symbol.externally_visible = target->symbol.externally_visible;
}
示例3: function_and_variable_visibility
static unsigned int
function_and_variable_visibility (void)
{
struct cgraph_node *node;
struct varpool_node *vnode;
for (node = cgraph_nodes; node; node = node->next)
{
if (node->reachable
&& (DECL_COMDAT (node->decl)
|| (!flag_whole_program
&& TREE_PUBLIC (node->decl) && !DECL_EXTERNAL (node->decl))))
node->local.externally_visible = true;
if (!node->local.externally_visible && node->analyzed
&& !DECL_EXTERNAL (node->decl))
{
gcc_assert (flag_whole_program || !TREE_PUBLIC (node->decl));
TREE_PUBLIC (node->decl) = 0;
}
node->local.local = (!node->needed
&& node->analyzed
&& !DECL_EXTERNAL (node->decl)
&& !node->local.externally_visible);
}
for (vnode = varpool_nodes_queue; vnode; vnode = vnode->next_needed)
{
if (vnode->needed
&& !flag_whole_program
&& (DECL_COMDAT (vnode->decl) || TREE_PUBLIC (vnode->decl)))
vnode->externally_visible = 1;
if (!vnode->externally_visible)
{
gcc_assert (flag_whole_program || !TREE_PUBLIC (vnode->decl));
TREE_PUBLIC (vnode->decl) = 0;
}
/* Static variables defined in auxiliary modules are externalized to
allow cross module inlining. */
gcc_assert (TREE_STATIC (vnode->decl)
|| varpool_is_auxiliary (vnode));
}
if (dump_file)
{
fprintf (dump_file, "\nMarking local functions:");
for (node = cgraph_nodes; node; node = node->next)
if (node->local.local)
fprintf (dump_file, " %s", cgraph_node_name (node));
fprintf (dump_file, "\n\n");
fprintf (dump_file, "\nMarking externally visible functions:");
for (node = cgraph_nodes; node; node = node->next)
if (node->local.externally_visible)
fprintf (dump_file, " %s", cgraph_node_name (node));
fprintf (dump_file, "\n\n");
}
cgraph_function_flags_ready = true;
return 0;
}
示例4: symtab_make_decl_local
/* Make DECL local. FIXME: We shouldn't need to mess with rtl this early,
but other code such as notice_global_symbol generates rtl. */
void
symtab_make_decl_local (tree decl)
{
rtx rtl, symbol;
if (TREE_CODE (decl) == VAR_DECL)
DECL_COMMON (decl) = 0;
else gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
if (DECL_ONE_ONLY (decl) || DECL_COMDAT (decl))
{
/* It is possible that we are linking against library defining same COMDAT
function. To avoid conflict we need to rename our local name of the
function just in the case WHOPR partitioning decide to make it hidden
to avoid cross partition references. */
if (flag_wpa)
{
const char *old_name;
symtab_node node = symtab_get_node (decl);
old_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
change_decl_assembler_name (decl,
clone_function_name (decl, "local"));
if (node->symbol.lto_file_data)
lto_record_renamed_decl (node->symbol.lto_file_data,
old_name,
IDENTIFIER_POINTER
(DECL_ASSEMBLER_NAME (decl)));
}
DECL_SECTION_NAME (decl) = 0;
DECL_COMDAT (decl) = 0;
}
DECL_COMDAT_GROUP (decl) = 0;
DECL_WEAK (decl) = 0;
DECL_EXTERNAL (decl) = 0;
TREE_PUBLIC (decl) = 0;
if (!DECL_RTL_SET_P (decl))
return;
/* Update rtl flags. */
make_decl_rtl (decl);
rtl = DECL_RTL (decl);
if (!MEM_P (rtl))
return;
symbol = XEXP (rtl, 0);
if (GET_CODE (symbol) != SYMBOL_REF)
return;
SYMBOL_REF_WEAK (symbol) = DECL_WEAK (decl);
}
示例5: pack_ts_decl_with_vis_value_fields
static void
pack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr)
{
bp_pack_value (bp, DECL_COMMON (expr), 1);
bp_pack_value (bp, DECL_DLLIMPORT_P (expr), 1);
bp_pack_value (bp, DECL_WEAK (expr), 1);
bp_pack_value (bp, DECL_SEEN_IN_BIND_EXPR_P (expr), 1);
bp_pack_value (bp, DECL_COMDAT (expr), 1);
bp_pack_value (bp, DECL_VISIBILITY (expr), 2);
bp_pack_value (bp, DECL_VISIBILITY_SPECIFIED (expr), 1);
if (TREE_CODE (expr) == VAR_DECL)
{
bp_pack_value (bp, DECL_HARD_REGISTER (expr), 1);
/* DECL_IN_TEXT_SECTION is set during final asm output only. */
bp_pack_value (bp, DECL_IN_CONSTANT_POOL (expr), 1);
}
if (TREE_CODE (expr) == FUNCTION_DECL)
{
bp_pack_value (bp, DECL_FINAL_P (expr), 1);
bp_pack_value (bp, DECL_CXX_CONSTRUCTOR_P (expr), 1);
bp_pack_value (bp, DECL_CXX_DESTRUCTOR_P (expr), 1);
}
}
示例6: unpack_ts_decl_with_vis_value_fields
static void
unpack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr)
{
DECL_DEFER_OUTPUT (expr) = (unsigned) bp_unpack_value (bp, 1);
DECL_COMMON (expr) = (unsigned) bp_unpack_value (bp, 1);
DECL_DLLIMPORT_P (expr) = (unsigned) bp_unpack_value (bp, 1);
DECL_WEAK (expr) = (unsigned) bp_unpack_value (bp, 1);
DECL_SEEN_IN_BIND_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
DECL_COMDAT (expr) = (unsigned) bp_unpack_value (bp, 1);
DECL_VISIBILITY (expr) = (enum symbol_visibility) bp_unpack_value (bp, 2);
DECL_VISIBILITY_SPECIFIED (expr) = (unsigned) bp_unpack_value (bp, 1);
if (TREE_CODE (expr) == VAR_DECL)
{
DECL_HARD_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1);
DECL_IN_TEXT_SECTION (expr) = (unsigned) bp_unpack_value (bp, 1);
DECL_IN_CONSTANT_POOL (expr) = (unsigned) bp_unpack_value (bp, 1);
DECL_TLS_MODEL (expr) = (enum tls_model) bp_unpack_value (bp, 3);
}
if (VAR_OR_FUNCTION_DECL_P (expr))
{
priority_type p;
p = (priority_type) bp_unpack_var_len_unsigned (bp);
SET_DECL_INIT_PRIORITY (expr, p);
}
}
示例7: DECL_COMMON
void
symtab_node::make_decl_local (void)
{
rtx rtl, symbol;
/* Avoid clearing comdat_groups on comdat-local decls. */
if (TREE_PUBLIC (decl) == 0)
return;
if (TREE_CODE (decl) == VAR_DECL)
DECL_COMMON (decl) = 0;
else gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
DECL_COMDAT (decl) = 0;
DECL_WEAK (decl) = 0;
DECL_EXTERNAL (decl) = 0;
DECL_VISIBILITY_SPECIFIED (decl) = 0;
DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
TREE_PUBLIC (decl) = 0;
if (!DECL_RTL_SET_P (decl))
return;
/* Update rtl flags. */
make_decl_rtl (decl);
rtl = DECL_RTL (decl);
if (!MEM_P (rtl))
return;
symbol = XEXP (rtl, 0);
if (GET_CODE (symbol) != SYMBOL_REF)
return;
SYMBOL_REF_WEAK (symbol) = DECL_WEAK (decl);
}
示例8: decide_is_variable_needed
/* Determine if variable DECL is needed. That is, visible to something
either outside this translation unit, something magic in the system
configury */
bool
decide_is_variable_needed (struct varpool_node *node, tree decl)
{
/* If the user told us it is used, then it must be so. */
if ((node->externally_visible && !DECL_COMDAT (decl))
|| node->force_output)
return true;
/* ??? If the assembler name is set by hand, it is possible to assemble
the name later after finalizing the function and the fact is noticed
in assemble_name then. This is arguably a bug. */
if (DECL_ASSEMBLER_NAME_SET_P (decl)
&& TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
return true;
/* Externally visible variables must be output. The exception is
COMDAT variables that must be output only when they are needed. */
if (TREE_PUBLIC (decl)
&& !flag_whole_program
&& !flag_lto
&& !flag_whopr
&& !DECL_COMDAT (decl)
&& !DECL_EXTERNAL (decl))
return true;
/* When emulating tls, we actually see references to the control
variable, rather than the user-level variable. */
if (!targetm.have_tls
&& TREE_CODE (decl) == VAR_DECL
&& DECL_THREAD_LOCAL_P (decl))
{
tree control = emutls_decl (decl);
if (decide_is_variable_needed (varpool_node (control), control))
return true;
}
/* When not reordering top level variables, we have to assume that
we are going to keep everything. */
if (flag_toplevel_reorder)
return false;
/* We want to emit COMDAT variables only when absolutely necessary. */
if (DECL_COMDAT (decl))
return false;
return true;
}
示例9: decide_is_function_needed
static bool
decide_is_function_needed (struct cgraph_node *node, tree decl)
{
if (MAIN_NAME_P (DECL_NAME (decl))
&& TREE_PUBLIC (decl))
{
node->local.externally_visible = true;
return true;
}
/* If the user told us it is used, then it must be so. */
if (node->local.externally_visible)
return true;
/* ??? If the assembler name is set by hand, it is possible to assemble
the name later after finalizing the function and the fact is noticed
in assemble_name then. This is arguably a bug. */
if (DECL_ASSEMBLER_NAME_SET_P (decl)
&& TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
return true;
/* With -fkeep-inline-functions we are keeping all inline functions except
for extern inline ones. */
if (flag_keep_inline_functions
&& DECL_DECLARED_INLINE_P (decl)
&& !DECL_EXTERNAL (decl)
&& !lookup_attribute ("always_inline", DECL_ATTRIBUTES (decl)))
return true;
/* If we decided it was needed before, but at the time we didn't have
the body of the function available, then it's still needed. We have
to go back and re-check its dependencies now. */
if (node->needed)
return true;
/* Externally visible functions must be output. The exception is
COMDAT functions that must be output only when they are needed.
When not optimizing, also output the static functions. (see
PR24561), but don't do so for always_inline functions, functions
declared inline and nested functions. These was optimized out
in the original implementation and it is unclear whether we want
to change the behavior here. */
if (((TREE_PUBLIC (decl)
|| (!optimize && !node->local.disregard_inline_limits
&& !DECL_DECLARED_INLINE_P (decl)
&& !node->origin))
&& !flag_whole_program)
&& !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
return true;
/* Constructors and destructors are reachable from the runtime by
some mechanism. */
if (DECL_STATIC_CONSTRUCTOR (decl) || DECL_STATIC_DESTRUCTOR (decl))
return true;
return false;
}
示例10: symtab_make_decl_local
void
symtab_make_decl_local (tree decl)
{
rtx rtl, symbol;
/* Avoid clearing DECL_COMDAT_GROUP on comdat-local decls. */
if (TREE_PUBLIC (decl) == 0)
return;
if (TREE_CODE (decl) == VAR_DECL)
DECL_COMMON (decl) = 0;
else gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
if (DECL_ONE_ONLY (decl) || DECL_COMDAT (decl))
{
DECL_SECTION_NAME (decl) = 0;
DECL_COMDAT (decl) = 0;
}
DECL_COMDAT_GROUP (decl) = 0;
DECL_WEAK (decl) = 0;
DECL_EXTERNAL (decl) = 0;
DECL_VISIBILITY_SPECIFIED (decl) = 0;
DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
TREE_PUBLIC (decl) = 0;
DECL_DLLIMPORT_P (decl) = 0;
if (!DECL_RTL_SET_P (decl))
return;
/* Update rtl flags. */
make_decl_rtl (decl);
rtl = DECL_RTL (decl);
if (!MEM_P (rtl))
return;
symbol = XEXP (rtl, 0);
if (GET_CODE (symbol) != SYMBOL_REF)
return;
SYMBOL_REF_WEAK (symbol) = DECL_WEAK (decl);
}
示例11: symtab_nonoverwritable_alias
symtab_node *
symtab_nonoverwritable_alias (symtab_node *node)
{
tree new_decl;
symtab_node *new_node = NULL;
/* First try to look up existing alias or base object
(if that is already non-overwritable). */
node = symtab_alias_ultimate_target (node, NULL);
gcc_assert (!node->alias && !node->weakref);
symtab_for_node_and_aliases (node, symtab_nonoverwritable_alias_1,
(void *)&new_node, true);
if (new_node)
return new_node;
#ifndef ASM_OUTPUT_DEF
/* If aliases aren't supported by the assembler, fail. */
return NULL;
#endif
/* Otherwise create a new one. */
new_decl = copy_node (node->decl);
DECL_DLLIMPORT_P (new_decl) = 0;
DECL_NAME (new_decl) = clone_function_name (node->decl, "localalias");
if (TREE_CODE (new_decl) == FUNCTION_DECL)
DECL_STRUCT_FUNCTION (new_decl) = NULL;
DECL_INITIAL (new_decl) = NULL;
SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl));
SET_DECL_RTL (new_decl, NULL);
/* Update the properties. */
DECL_EXTERNAL (new_decl) = 0;
if (DECL_ONE_ONLY (node->decl))
DECL_SECTION_NAME (new_decl) = NULL;
DECL_COMDAT_GROUP (new_decl) = 0;
TREE_PUBLIC (new_decl) = 0;
DECL_COMDAT (new_decl) = 0;
DECL_WEAK (new_decl) = 0;
DECL_VIRTUAL_P (new_decl) = 0;
if (TREE_CODE (new_decl) == FUNCTION_DECL)
{
DECL_STATIC_CONSTRUCTOR (new_decl) = 0;
DECL_STATIC_DESTRUCTOR (new_decl) = 0;
new_node = cgraph_create_function_alias
(new_decl, node->decl);
}
else
new_node = varpool_create_variable_alias (new_decl,
node->decl);
symtab_resolve_alias (new_node, node);
gcc_assert (decl_binds_to_current_def_p (new_decl));
return new_node;
}
示例12: lto_symtab_resolve_replaceable_p
static bool
lto_symtab_resolve_replaceable_p (symtab_node e)
{
if (DECL_EXTERNAL (e->symbol.decl)
|| DECL_COMDAT (e->symbol.decl)
|| DECL_ONE_ONLY (e->symbol.decl)
|| DECL_WEAK (e->symbol.decl))
return true;
if (TREE_CODE (e->symbol.decl) == VAR_DECL)
return (DECL_COMMON (e->symbol.decl)
|| (!flag_no_common && !DECL_INITIAL (e->symbol.decl)));
return false;
}
示例13: cgraph_variable_initializer_availability
/* Return variable availability. See cgraph.h for description of individual
return values. */
enum availability
cgraph_variable_initializer_availability (struct varpool_node *node)
{
gcc_assert (cgraph_function_flags_ready);
if (!node->finalized)
return AVAIL_NOT_AVAILABLE;
if (!TREE_PUBLIC (node->decl))
return AVAIL_AVAILABLE;
/* If the variable can be overwritten, return OVERWRITABLE. Takes
care of at least two notable extensions - the COMDAT variables
used to share template instantiations in C++. */
if (!(*targetm.binds_local_p) (node->decl) && !DECL_COMDAT (node->decl))
return AVAIL_OVERWRITABLE;
return AVAIL_AVAILABLE;
}
示例14: get_symbol_class
enum symbol_class
get_symbol_class (symtab_node *node)
{
/* Inline clones are always duplicated.
This include external delcarations. */
cgraph_node *cnode = dyn_cast <cgraph_node> (node);
if (DECL_ABSTRACT (node->decl))
return SYMBOL_EXTERNAL;
if (cnode && cnode->global.inlined_to)
return SYMBOL_DUPLICATE;
/* Weakref aliases are always duplicated. */
if (node->weakref)
return SYMBOL_DUPLICATE;
/* External declarations are external. */
if (DECL_EXTERNAL (node->decl))
return SYMBOL_EXTERNAL;
if (varpool_node *vnode = dyn_cast <varpool_node> (node))
{
/* Constant pool references use local symbol names that can not
be promoted global. We should never put into a constant pool
objects that can not be duplicated across partitions. */
if (DECL_IN_CONSTANT_POOL (node->decl))
return SYMBOL_DUPLICATE;
gcc_checking_assert (vnode->definition);
}
/* Functions that are cloned may stay in callgraph even if they are unused.
Handle them as external; compute_ltrans_boundary take care to make
proper things to happen (i.e. to make them appear in the boundary but
with body streamed, so clone can me materialized). */
else if (!cgraph (node)->definition)
return SYMBOL_EXTERNAL;
/* Comdats are duplicated to every use unless they are keyed.
Those do not need duplication. */
if (DECL_COMDAT (node->decl)
&& !node->force_output
&& !symtab_used_from_object_file_p (node))
return SYMBOL_DUPLICATE;
return SYMBOL_PARTITION;
}
示例15: varpool_finalize_decl
/* Mark DECL as finalized. By finalizing the declaration, frontend instruct the
middle end to output the variable to asm file, if needed or externally
visible. */
void
varpool_finalize_decl (tree decl)
{
struct varpool_node *node = varpool_node (decl);
/* FIXME: We don't really stream varpool datastructure and instead rebuild it
by varpool_finalize_decl. This is not quite correct since this way we can't
attach any info to varpool. Eventually we will want to stream varpool nodes
and the flags.
For the moment just prevent analysis of varpool nodes to happen again, so
we will re-try to compute "address_taken" flag of varpool that breaks
in presence of clones. */
if (in_lto_p)
node->analyzed = true;
/* The first declaration of a variable that comes through this function
decides whether it is global (in C, has external linkage)
or local (in C, has internal linkage). So do nothing more
if this function has already run. */
if (node->finalized)
{
if (cgraph_global_info_ready)
varpool_assemble_pending_decls ();
return;
}
if (node->needed)
varpool_enqueue_needed_node (node);
node->finalized = true;
if (decide_is_variable_needed (node, decl))
varpool_mark_needed_node (node);
/* Since we reclaim unreachable nodes at the end of every language
level unit, we need to be conservative about possible entry points
there. */
else if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
varpool_mark_needed_node (node);
if (cgraph_global_info_ready)
varpool_assemble_pending_decls ();
}