+2010-03-03 Jason Merrill <jason@redhat.com>
+
+ PR c++/12909
+ * cgraph.h (varpool_node): Add extra_name field.
+ * varpool.c (varpool_extra_name_alias): New.
+ (varpool_assemble_decl): Emit extra name aliases.
+ (varpool_mark_needed_node): Look past an extra name alias.
+
2010-03-03 Eric Botcazou <ebotcazou@adacore.com>
* config.gcc (sparc64-*-solaris2*, sparc-*-solaris2*): Merge into...
struct varpool_node *next;
/* Pointer to the next function in varpool_nodes_queue. */
struct varpool_node *next_needed;
+ /* For normal nodes a pointer to the first extra name alias. For alias
+ nodes a pointer to the normal node. */
+ struct varpool_node *extra_name;
/* Ordering of all cgraph nodes. */
int order;
unsigned output : 1;
/* Set when function is visible by other units. */
unsigned externally_visible : 1;
- /* Set for aliases once they got through assemble_alias. */
+ /* Set for aliases once they got through assemble_alias. Also set for
+ extra name aliases in varpool_extra_name_alias. */
unsigned alias : 1;
};
bool varpool_analyze_pending_decls (void);
void varpool_remove_unreferenced_decls (void);
void varpool_empty_needed_queue (void);
+bool varpool_extra_name_alias (tree, tree);
const char * varpool_node_name (struct varpool_node *node);
/* Walk all reachable static variables. */
inform (DECL_SOURCE_LOCATION (decl), "-fabi-version=4 (or =0) "
"avoids this error with a change in vector mangling");
- if (TREE_CODE (decl) != FUNCTION_DECL)
- return;
-
save_ver = flag_abi_version;
flag_abi_version = 0;
id2 = mangle_decl_string (decl);
DECL_VISIBILITY (alias) = DECL_VISIBILITY (decl);
if (vague_linkage_p (decl))
DECL_WEAK (alias) = 1;
- cgraph_same_body_alias (alias, decl);
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ cgraph_same_body_alias (alias, decl);
+ else
+ varpool_extra_name_alias (alias, decl);
}
#endif
}
// { dg-options "-mavx -Wabi -fabi-version=2" }
// { dg-final { scan-assembler "weak\[^\n\]*_Z1fIDv4_fEvT_" } }
// { dg-final { scan-assembler "weak\[^\n\]*_Z1fIU8__vectorfEvT_" } }
+// { dg-final { scan-assembler "weak\[^\n\]*_ZN1AIDv4_fE1tE" } }
// { dg-final { scan-assembler "weak\[^\n\]*_ZN1AIU8__vectorfE1tE" } }
#include <x86intrin.h>
void
varpool_mark_needed_node (struct varpool_node *node)
{
+ if (node->alias && node->extra_name)
+ node = node->extra_name;
if (!node->needed && node->finalized
&& !TREE_ASM_WRITTEN (node->decl))
varpool_enqueue_needed_node (node);
assemble_variable (decl, 0, 1, 0);
if (TREE_ASM_WRITTEN (decl))
{
+ struct varpool_node *alias;
+
node->next_needed = varpool_assembled_nodes_queue;
varpool_assembled_nodes_queue = node;
node->finalized = 1;
+
+ /* Also emit any extra name aliases. */
+ for (alias = node->extra_name; alias; alias = alias->next)
+ {
+ /* Update linkage fields in case they've changed. */
+ DECL_WEAK (alias->decl) = DECL_WEAK (decl);
+ TREE_PUBLIC (alias->decl) = TREE_PUBLIC (decl);
+ DECL_VISIBILITY (alias->decl) = DECL_VISIBILITY (decl);
+ assemble_alias (alias->decl, DECL_ASSEMBLER_NAME (decl));
+ }
+
return true;
}
}
return new_node->decl;
}
+/* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
+ Extra name aliases are output whenever DECL is output. */
+
+bool
+varpool_extra_name_alias (tree alias, tree decl)
+{
+ struct varpool_node key, *alias_node, *decl_node, **slot;
+
+#ifndef ASM_OUTPUT_DEF
+ /* If aliases aren't supported by the assembler, fail. */
+ return false;
+#endif
+
+ gcc_assert (TREE_CODE (decl) == VAR_DECL);
+ gcc_assert (TREE_CODE (alias) == VAR_DECL);
+ /* Make sure the hash table has been created. */
+ decl_node = varpool_node (decl);
+
+ key.decl = alias;
+
+ slot = (struct varpool_node **) htab_find_slot (varpool_hash, &key, INSERT);
+
+ /* If the varpool_node has been already created, fail. */
+ if (*slot)
+ return false;
+
+ alias_node = GGC_CNEW (struct varpool_node);
+ alias_node->decl = alias;
+ alias_node->alias = 1;
+ alias_node->extra_name = decl_node;
+ alias_node->next = decl_node->extra_name;
+ decl_node->extra_name = alias_node;
+ *slot = alias_node;
+ return true;
+}
+
#include "gt-varpool.h"