From 1d5053d6b407b6fc493151a3581df7c628ffa72b Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 3 Mar 2010 14:02:08 -0500 Subject: [PATCH] re PR c++/12909 (ambiguity in mangling vector types) PR c++/12909 * lto-streamer.h (LTO_tags): Add LTO_var_decl_alias. * lto-streamer-in.c (lto_input_tree): Read it. * lto-streamer-out.c (output_unreferenced_globals): Write it. From-SVN: r157204 --- gcc/ChangeLog | 3 +++ gcc/lto-streamer-in.c | 11 +++++++++++ gcc/lto-streamer-out.c | 13 +++++++++++++ gcc/lto-streamer.h | 3 +++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/lto/20100302.h | 9 +++++++++ gcc/testsuite/g++.dg/lto/20100302_0.C | 9 +++++++++ gcc/testsuite/g++.dg/lto/20100302_1.C | 8 ++++++++ 8 files changed, 59 insertions(+) create mode 100644 gcc/testsuite/g++.dg/lto/20100302.h create mode 100644 gcc/testsuite/g++.dg/lto/20100302_0.C create mode 100644 gcc/testsuite/g++.dg/lto/20100302_1.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1ae9f671051..1b749f4da42 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -5,6 +5,9 @@ * varpool.c (varpool_extra_name_alias): New. (varpool_assemble_decl): Emit extra name aliases. (varpool_mark_needed_node): Look past an extra name alias. + * lto-streamer.h (LTO_tags): Add LTO_var_decl_alias. + * lto-streamer-in.c (lto_input_tree): Read it. + * lto-streamer-out.c (output_unreferenced_globals): Write it. 2010-03-03 Eric Botcazou diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index 095591484db..b098be2b4c0 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -2696,6 +2696,17 @@ lto_input_tree (struct lto_input_block *ib, struct data_in *data_in) the code and class. */ result = lto_get_builtin_tree (ib, data_in); } + else if (tag == LTO_var_decl_alias) + { + /* An extra_name alias for a variable. */ + unsigned HOST_WIDE_INT ix; + tree target; + ix = lto_input_uleb128 (ib); + result = lto_file_decl_data_get_var_decl (data_in->file_data, ix); + ix = lto_input_uleb128 (ib); + target = lto_file_decl_data_get_var_decl (data_in->file_data, ix); + varpool_extra_name_alias (result, target); + } else if (tag == lto_tree_code_to_tag (INTEGER_CST)) { /* For integer constants we only need the type and its hi/low diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index b5fc3e26c20..f375282beac 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -1978,6 +1978,8 @@ output_unreferenced_globals (cgraph_node_set set) if (TREE_CODE (var) == VAR_DECL) { + struct varpool_node *alias; + /* Output the object in order to output references used in the initialization. */ lto_output_tree (ob, var, true); @@ -1985,6 +1987,17 @@ output_unreferenced_globals (cgraph_node_set set) /* If it is public we also need a reference to the object itself. */ if (TREE_PUBLIC (var)) lto_output_tree_ref (ob, var); + + /* Also output any extra_name aliases for this variable. */ + for (alias = vnode->extra_name; alias; alias = alias->next) + { + lto_output_tree (ob, alias->decl, true); + output_record_start (ob, LTO_var_decl_alias); + lto_output_var_decl_index (ob->decl_state, ob->main_stream, + alias->decl); + lto_output_var_decl_index (ob->decl_state, ob->main_stream, + var); + } } } diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index 703d6fabbff..e67b669387f 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -217,6 +217,9 @@ enum LTO_tags /* Special for global streamer. Reference to previously-streamed node. */ LTO_tree_pickle_reference, + /* A decl which exists only to provide an extra symbol for another var. */ + LTO_var_decl_alias, + /* References to indexable tree nodes. These objects are stored in tables that are written separately from the function bodies that reference them. This way they can be instantiated even when the diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 77aaf9c6833..637680f1634 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -3,6 +3,9 @@ PR c++/12909 * g++.dg/abi/mangle40.C: New. * g++.dg/abi/mangle41.C: New. + * g++.dg/lto/20100302_0.C: New. + * g++.dg/lto/20100302_1.C: New. + * g++.dg/lto/20100302.h: New. 2010-03-03 Paul Thomas diff --git a/gcc/testsuite/g++.dg/lto/20100302.h b/gcc/testsuite/g++.dg/lto/20100302.h new file mode 100644 index 00000000000..7260be10c91 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/20100302.h @@ -0,0 +1,9 @@ +typedef float mm128 __attribute ((vector_size (16))); + +template +struct A +{ + static T t; +}; + +void f (mm128 *); diff --git a/gcc/testsuite/g++.dg/lto/20100302_0.C b/gcc/testsuite/g++.dg/lto/20100302_0.C new file mode 100644 index 00000000000..13d4373aea3 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/20100302_0.C @@ -0,0 +1,9 @@ +// Test for ABI forward-compatibility aliases with LTO. +// { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } { "*" } { "" } } +// { dg-lto-options {"-flto -fabi-version=2"} } + +#include "20100302.h" + +void f(mm128 *) { } + +template <> mm128 A::t = { }; diff --git a/gcc/testsuite/g++.dg/lto/20100302_1.C b/gcc/testsuite/g++.dg/lto/20100302_1.C new file mode 100644 index 00000000000..48548b63ae9 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/20100302_1.C @@ -0,0 +1,8 @@ +// { dg-options "-fabi-version=0" } + +#include "20100302.h" + +int main() +{ + f(& A::t); +}