aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2010-06-16 14:21:56 +0200
committerMartin Jambor <jamborm@gcc.gnu.org>2010-06-16 14:21:56 +0200
commit29be38356740af75026c65c627f78d46fee2554d (patch)
tree8882f58ec40664507726bf4b62641267712f9828 /gcc
parent584bd1cfca25313643c5295908f248c2460022d5 (diff)
downloadgcc-29be38356740af75026c65c627f78d46fee2554d.zip
gcc-29be38356740af75026c65c627f78d46fee2554d.tar.gz
gcc-29be38356740af75026c65c627f78d46fee2554d.tar.bz2
re PR tree-optimization/43905 (duplicate __PRETTY_FUNCTION__ symbol for functions differing in const-ness)
2010-06-16 Martin Jambor <mjambor@suse.cz> PR tree-optimization/43905 * tree-sra.c: Include tree-inline.h. (create_abstract_origin): Removed. (modify_function): Version the call graph node instead of creating abstract origins and dealing with same_body aliases. * tree-sra.c (ipa_sra_preliminary_function_checks): Check whether the function is versionable. * Makefile.in (tree-sra.o): Add TREE_INLINE_H to dependencies. * testsuite/g++.dg/torture/pr43905.C: New test. From-SVN: r160832
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/Makefile.in3
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/torture/pr43905.C13
-rw-r--r--gcc/tree-sra.c59
5 files changed, 61 insertions, 29 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f25899e..449b824 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2010-06-16 Martin Jambor <mjambor@suse.cz>
+
+ PR tree-optimization/43905
+ * tree-sra.c: Include tree-inline.h.
+ (create_abstract_origin): Removed.
+ (modify_function): Version the call graph node instead of creating
+ abstract origins and dealing with same_body aliases.
+ * tree-sra.c (ipa_sra_preliminary_function_checks): Check whether the
+ function is versionable.
+ * Makefile.in (tree-sra.o): Add TREE_INLINE_H to dependencies.
+
2010-06-16 Maxim Kuvyrkov <maxim@codesourcery.com>
* config/mips/linux64.h (BIONIC_DYNAMIC_LINKERN32): Define.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 98ed23d..4c952c4 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -3118,7 +3118,8 @@ tree-ssa-ccp.o : tree-ssa-ccp.c $(TREE_FLOW_H) $(CONFIG_H) \
tree-sra.o : tree-sra.c $(CONFIG_H) $(SYSTEM_H) coretypes.h alloc-pool.h \
$(TM_H) $(TREE_H) $(GIMPLE_H) $(CGRAPH_H) $(TREE_FLOW_H) $(IPA_PROP_H) \
$(DIAGNOSTIC_H) statistics.h $(TREE_DUMP_H) $(TIMEVAR_H) $(PARAMS_H) \
- $(TARGET_H) $(FLAGS_H) $(EXPR_H) tree-pretty-print.h $(DBGCNT_H)
+ $(TARGET_H) $(FLAGS_H) $(EXPR_H) tree-pretty-print.h $(DBGCNT_H) \
+ $(TREE_INLINE_H)
tree-switch-conversion.o : tree-switch-conversion.c $(CONFIG_H) $(SYSTEM_H) \
$(TREE_H) $(TM_P_H) $(TREE_FLOW_H) $(DIAGNOSTIC_H) $(TREE_INLINE_H) \
$(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) $(GIMPLE_H) \
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 125d566..3c80394 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2010-06-16 Martin Jambor <mjambor@suse.cz>
+
+ * g++.dg/torture/pr43905.C: New test.
+
2010-06-16 Mikael Pettersson <mikpe@it.uu.se>
PR testsuite/44538
diff --git a/gcc/testsuite/g++.dg/torture/pr43905.C b/gcc/testsuite/g++.dg/torture/pr43905.C
new file mode 100644
index 0000000..0e49a32
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr43905.C
@@ -0,0 +1,13 @@
+extern void sf ( __const char *);
+struct Matrix{
+ int operator[](int n){
+ sf ( __PRETTY_FUNCTION__);
+ }
+ int operator[](int n)const{
+ sf ( __PRETTY_FUNCTION__);
+ }
+};
+void calcmy(Matrix const &b, Matrix &c, int k){
+ b[k];
+ c[k];
+}
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 18cef67..47d0e50 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -89,6 +89,7 @@ along with GCC; see the file COPYING3. If not see
#include "target.h"
#include "flags.h"
#include "dbgcnt.h"
+#include "tree-inline.h"
/* Enumeration of all aggregate reductions we can do. */
enum sra_mode { SRA_MODE_EARLY_IPA, /* early call regularization */
@@ -4225,43 +4226,38 @@ convert_callers (struct cgraph_node *node, ipa_parm_adjustment_vec adjustments)
return;
}
-/* Create an abstract origin declaration for OLD_DECL and make it an abstract
- origin of the provided decl so that there are preserved parameters for debug
- information. */
-
-static void
-create_abstract_origin (tree old_decl)
-{
- if (!DECL_ABSTRACT_ORIGIN (old_decl))
- {
- tree new_decl = copy_node (old_decl);
-
- DECL_ABSTRACT (new_decl) = 1;
- SET_DECL_ASSEMBLER_NAME (new_decl, NULL_TREE);
- SET_DECL_RTL (new_decl, NULL);
- DECL_STRUCT_FUNCTION (new_decl) = NULL;
- DECL_ARTIFICIAL (old_decl) = 1;
- DECL_ABSTRACT_ORIGIN (old_decl) = new_decl;
- }
-}
-
/* Perform all the modification required in IPA-SRA for NODE to have parameters
as given in ADJUSTMENTS. */
static void
modify_function (struct cgraph_node *node, ipa_parm_adjustment_vec adjustments)
{
- struct cgraph_node *alias;
- for (alias = node->same_body; alias; alias = alias->next)
- ipa_modify_formal_parameters (alias->decl, adjustments, "ISRA");
- /* current_function_decl must be handled last, after same_body aliases,
- as following functions will use what it computed. */
- create_abstract_origin (current_function_decl);
+ struct cgraph_node *new_node;
+ struct cgraph_edge *cs;
+ VEC (cgraph_edge_p, heap) * redirect_callers;
+ int node_callers;
+
+ node_callers = 0;
+ for (cs = node->callers; cs != NULL; cs = cs->next_caller)
+ node_callers++;
+ redirect_callers = VEC_alloc (cgraph_edge_p, heap, node_callers);
+ for (cs = node->callers; cs != NULL; cs = cs->next_caller)
+ VEC_quick_push (cgraph_edge_p, redirect_callers, cs);
+
+ rebuild_cgraph_edges ();
+ pop_cfun ();
+ current_function_decl = NULL_TREE;
+
+ new_node = cgraph_function_versioning (node, redirect_callers, NULL, NULL,
+ NULL, NULL, "isra");
+ current_function_decl = new_node->decl;
+ push_cfun (DECL_STRUCT_FUNCTION (new_node->decl));
+
ipa_modify_formal_parameters (current_function_decl, adjustments, "ISRA");
ipa_sra_modify_function_body (adjustments);
sra_ipa_reset_debug_stmts (adjustments);
- convert_callers (node, adjustments);
- cgraph_make_node_local (node);
+ convert_callers (new_node, adjustments);
+ cgraph_make_node_local (new_node);
return;
}
@@ -4279,6 +4275,13 @@ ipa_sra_preliminary_function_checks (struct cgraph_node *node)
return false;
}
+ if (!tree_versionable_function_p (node->decl))
+ {
+ if (dump_file)
+ fprintf (dump_file, "Function not local to this compilation unit.\n");
+ return false;
+ }
+
if (DECL_VIRTUAL_P (current_function_decl))
{
if (dump_file)