This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH for c++/41997 (missed optimization with C++0x initializer list0

On Sun, 14 Feb 2010, Jason Merrill wrote:

> We were neglecting to set TREE_READONLY on a static temporary for a
> compound literal with const type, and we use the compound literal code
> for building up a std::initializer_list.
> Tested x86_64-pc-linux-gnu, applied to trunk.

The optimization in this new testcase only triggers if global functions
bind locally.  This isn't the case when running the testsuite with -fpic
or -fPIC (which I do regularly).  The patch below fixes it.

Tested by running the testsuite with -fpic and -fPIC, installed as

Note: if you backport this to 4.4, the bind_pic_locally stuff isn't there
so you have to do it manually like so:
+ // { dg-options "-std=c++0x -O2 -fdump-tree-optimized -fpie" { target { ! nonpic } } }


2010-02-15  Kaveh R. Ghazi  <>

	* g++.dg/cpp0x/initlist-opt.C: Bind pic locally.

diff -rup orig/egcc-SVN20100215/gcc/testsuite/g++.dg/cpp0x/initlist-opt.C egcc-SVN20100215/gcc/testsuite/g++.dg/cpp0x/initlist-opt.C
--- orig/egcc-SVN20100215/gcc/testsuite/g++.dg/cpp0x/initlist-opt.C	2010-02-15 02:01:29.000000000 +0100
+++ egcc-SVN20100215/gcc/testsuite/g++.dg/cpp0x/initlist-opt.C	2010-02-15 18:41:53.000000000 +0100
@@ -1,5 +1,6 @@
 // PR c++/41997
 // { dg-options "-std=c++0x -O2 -fdump-tree-optimized" }
+// { dg-add-options bind_pic_locally }
 // { dg-final { scan-tree-dump-not "_0" "optimized" } }
 // { dg-final { cleanup-tree-dump "optimized" } }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]