aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2015-02-28 21:32:15 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2015-02-28 20:32:15 +0000
commitb7aa4a3ab319b307daf896c274557443593acbd5 (patch)
treeb1b16f1a1567b6bacad4d0f21597b2a83c80b5cf
parentf083b434c27face3cdf13c0f5b089d3f651956f3 (diff)
downloadgcc-b7aa4a3ab319b307daf896c274557443593acbd5.zip
gcc-b7aa4a3ab319b307daf896c274557443593acbd5.tar.gz
gcc-b7aa4a3ab319b307daf896c274557443593acbd5.tar.bz2
re PR ipa/65236 (IPA ICF causes miscompilation in Chromium built with -Os)
PR ipa/65236 * g++.dg/ipa/ipa-icf-6.C: New testcase. * cgraphunit.c (cgraph_node::expand_thunk): Enable return slot opt. From-SVN: r221077
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cgraphunit.c8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/ipa/ipa-icf-6.C37
4 files changed, 56 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5540fb6..2c8c9a5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-02-28 Jan Hubicka <hubicka@ucw.cz>
+
+ PR ipa/65236
+ * cgraphunit.c (cgraph_node::expand_thunk): Enable return slot
+ opt.
+
2015-02-28 Xingxing Pan <xxingpan@marvell.com>
* config/aarch64/aarch64.md: (mov<mode>_aarch64): Change type
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 9f6878a..e640907 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1680,6 +1680,14 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
callees->call_stmt = call;
gimple_call_set_from_thunk (call, true);
gimple_call_set_with_bounds (call, instrumentation_clone);
+
+ /* Return slot optimization is always possible and in fact requred to
+ return values with DECL_BY_REFERENCE. */
+ if (aggregate_value_p (resdecl, TREE_TYPE (thunk_fndecl))
+ && (!is_gimple_reg_type (TREE_TYPE (resdecl))
+ || DECL_BY_REFERENCE (resdecl)))
+ gimple_call_set_return_slot_opt (call, true);
+
if (restmp && !alias_is_noreturn)
{
gimple_call_set_lhs (call, restmp);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 27b6a4a..bf0978e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-28 Jan Hubicka <hubicka@ucw.cz>
+
+ PR ipa/65236
+ * g++.dg/ipa/ipa-icf-6.C: New testcase.
+
2015-02-27 Pat Haugen <pthaugen@us.ibm.com>
* gcc.dg/vect/pr59354.c: Move vector producing code to separate function.
diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-6.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-6.C
new file mode 100644
index 0000000..933ab5d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-6.C
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fdump-ipa-icf" } */
+
+struct A {
+ A() {ptr=&b;}
+ A(const A &a) {ptr = &b;}
+ void test() { if (ptr != &b) __builtin_abort ();}
+ int b;
+ int *ptr;
+};
+
+A test1(A a)
+{
+ a.test();
+ return a;
+}
+A test2(A a)
+{
+ a.test();
+ return a;
+}
+__attribute__ ((noinline))
+static void
+test_me (A (*t)(A))
+{
+ struct A a, b=t(a);
+ b.test ();
+}
+int
+main()
+{
+ test_me (test1);
+ test_me (test2);
+ return 0;
+}
+/* { dg-final { scan-ipa-dump-times "Unified; Wrapper has been created" 1 "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */