[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-09-23 Thread vincenzo.innocente at cern dot ch
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

--- Comment #11 from Vincenzo Innocente vincenzo.innocente at cern dot ch 
2011-09-23 11:15:33 UTC ---
Indeed there is a long chain of function calls.
So I removed the visibility from the namespace in stl_algo.h

namespace std /* _GLIBCXX_VISIBILITY(default) */

and

c++ -O2 -Wl,--icf=all,--print-icf-sections -shared -fPIC
-fvisibility-inlines-hidden -ffunction-sections ICFproblem.cpp -o libbha.so
-fno-inline -fvisibility=hidden
no folding of the sorting stuff (even if now its all LOCAL  HIDDEN)

readelf -sW libbha.so | grep -v UND | c++filt | grep move_median 
 80: 43b0   149 FUNCLOCAL  HIDDEN11 void
std::__move_median_first__gnu_cxx::__normal_iteratorA**, std::vectorA*,
std::allocatorA*   (__gnu_cxx::__normal_iteratorA**, std::vectorA*,
std::allocatorA*  , __gnu_cxx::__normal_iteratorA**, std::vectorA*,
std::allocatorA*  , __gnu_cxx::__normal_iteratorA**, std::vectorA*,
std::allocatorA*  )
89: 4d60   149 FUNCLOCAL  HIDDEN11 void
std::__move_median_first__gnu_cxx::__normal_iteratorB**, std::vectorB*,
std::allocatorB*   (__gnu_cxx::__normal_iteratorB**, std::vectorB*,
std::allocatorB*  , __gnu_cxx::__normal_iteratorB**, std::vectorB*,
std::allocatorB*  , __gnu_cxx::__normal_iteratorB**, std::vectorB*,
std::allocatorB*  )
98: 56e0   149 FUNCLOCAL  HIDDEN11 void
std::__move_median_first__gnu_cxx::__normal_iteratorC**, std::vectorC*,
std::allocatorC*   (__gnu_cxx::__normal_iteratorC**, std::vectorC*,
std::allocatorC*  , __gnu_cxx::__normal_iteratorC**, std::vectorC*,
std::allocatorC*  , __gnu_cxx::__normal_iteratorC**, std::vectorC*,
std::allocatorC*  )
[vinavx0] ~/public/ctest $ readelf -sW libbha.so | grep -v UND | c++filt | grep
introsort
83: 4560   120 FUNCLOCAL  HIDDEN11 void
std::__introsort_loop__gnu_cxx::__normal_iteratorA**, std::vectorA*,
std::allocatorA*  , long(__gnu_cxx::__normal_iteratorA**, std::vectorA*,
std::allocatorA*  , __gnu_cxx::__normal_iteratorA**, std::vectorA*,
std::allocatorA*  , long)
92: 4f10   120 FUNCLOCAL  HIDDEN11 void
std::__introsort_loop__gnu_cxx::__normal_iteratorB**, std::vectorB*,
std::allocatorB*  , long(__gnu_cxx::__normal_iteratorB**, std::vectorB*,
std::allocatorB*  , __gnu_cxx::__normal_iteratorB**, std::vectorB*,
std::allocatorB*  , long)
  101: 5890   120 FUNCLOCAL  HIDDEN11 void
std::__introsort_loop__gnu_cxx::__normal_iteratorC**, std::vectorC*,
std::allocatorC*  , long(__gnu_cxx::__normal_iteratorC**, std::vectorC*,
std::allocatorC*  , __gnu_cxx::__normal_iteratorC**, std::vectorC*,
std::allocatorC*  , long)


p.s. made
void  __attribute__ ((visibility (default))) go() 
in ICFproblem.cpp

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-09-22 Thread vincenzo.innocente at cern dot ch
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

--- Comment #8 from Vincenzo Innocente vincenzo.innocente at cern dot ch 
2011-09-22 08:13:26 UTC ---
I made few more tests:
adding inline keyword to __introsort in stl_algo.h makes no difference even if
-fvisibility-inlines-hidden is used.

nm -C libbha.so | sort | grep introsort
2190 W void std::__introsort_loop__gnu_cxx::__normal_iteratorA**,
std::vectorA*, std::allocatorA*  , long(__gnu_cxx::__normal_iteratorA**,
std::vectorA*, std::allocatorA*  , __gnu_cxx::__normal_iteratorA**,
std::vectorA*, std::allocatorA*  , long)
2a10 W void std::__introsort_loop__gnu_cxx::__normal_iteratorB**,
std::vectorB*, std::allocatorB*  , long(__gnu_cxx::__normal_iteratorB**,
std::vectorB*, std::allocatorB*  , __gnu_cxx::__normal_iteratorB**,
std::vectorB*, std::allocatorB*  , long)
3290 W void std::__introsort_loop__gnu_cxx::__normal_iteratorC**,
std::vectorC*, std::allocatorC*  , long(__gnu_cxx::__normal_iteratorC**,
std::vectorC*, std::allocatorC*  , __gnu_cxx::__normal_iteratorC**,
std::vectorC*, std::allocatorC*  , long)


what (with gcc 4.7, I think should be the same with 4.6.1) seems to work is
-flto 
with inline added  the three introsort are now folded
 c++ -flto -O2 -Wl,--icf=all,--print-icf-sections -shared -fPIC
-fvisibility-inlines-hidden -ffunction-sections ICFproblem.cpp -o libbha.so
nm -C libbha.so | sort | grep introsort
2210 t
_ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPP1ASt6vectorIS3_SaIS3_lEvT_S9_T0_.local.43
2210 t
_ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPP1BSt6vectorIS3_SaIS3_lEvT_S9_T0_.local.29
2210 t
_ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPP1CSt6vectorIS3_SaIS3_lEvT_S9_T0_.local.15

funny enough w/o inline (original std_algo.h) there is just one symbol
explicitly generated
 nm -C libbha.so | sort | grep introsort
09f0 t
_ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPP1CSt6vectorIS3_SaIS3_lEvT_S9_T0_.local.15.2431
btw we need to make c++filt understanding local symbols :-( 
 echo 
_ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPP1CSt6vectorIS3_SaIS3_lEvT_S9_T0_
| c++filt
void std::__introsort_loop__gnu_cxx::__normal_iteratorC**, std::vectorC*,
std::allocatorC*  , long(__gnu_cxx::__normal_iteratorC**, std::vectorC*,
std::allocatorC*  , __gnu_cxx::__normal_iteratorC**, std::vectorC*,
std::allocatorC*  , long)

I will iterate with GCC folks on this.
In any case, I support Ian's proposal to have, for .so libraries, just
independent PLT entries and fold the internal ones.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-09-22 Thread vincenzo.innocente at cern dot ch
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

--- Comment #9 from Vincenzo Innocente vincenzo.innocente at cern dot ch 
2011-09-22 10:29:29 UTC ---
I tried to add __attribute__ ((visibility (hidden))) to __introsort_loop
no folding either even if now the symbol is t not W.


c++ -O2 -Wl,--icf=all,--print-icf-sections -shared -fPIC
-fvisibility-inlines-hidden -ffunction-sections ICFproblem.cpp -o libbha.so

nm -C libbha.so | grep intro
1fa0 t void std::__introsort_loop__gnu_cxx::__normal_iteratorA**,
std::vectorA*, std::allocatorA*  , long(__gnu_cxx::__normal_iteratorA**,
std::vectorA*, std::allocatorA*  , __gnu_cxx::__normal_iteratorA**,
std::vectorA*, std::allocatorA*  , long)
2230 t void std::__introsort_loop__gnu_cxx::__normal_iteratorB**,
std::vectorB*, std::allocatorB*  , long(__gnu_cxx::__normal_iteratorB**,
std::vectorB*, std::allocatorB*  , __gnu_cxx::__normal_iteratorB**,
std::vectorB*, std::allocatorB*  , long)
24c0 t void std::__introsort_loop__gnu_cxx::__normal_iteratorC**,
std::vectorC*, std::allocatorC*  , long(__gnu_cxx::__normal_iteratorC**,
std::vectorC*, std::allocatorC*  , __gnu_cxx::__normal_iteratorC**,
std::vectorC*, std::allocatorC*  , long)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-09-22 Thread tmsriram at google dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

--- Comment #10 from Sriraman Tallam tmsriram at google dot com 2011-09-22 
17:48:57 UTC ---
On Thu, Sep 22, 2011 at 3:29 AM, vincenzo.innocente at cern dot ch
sourceware-bugzi...@sourceware.org wrote:
 http://sourceware.org/bugzilla/show_bug.cgi?id=12919

 --- Comment #9 from Vincenzo Innocente vincenzo.innocente at cern dot ch 
 2011-09-22 10:29:29 UTC ---
 I tried to add __attribute__ ((visibility (hidden))) to __introsort_loop
 no folding either even if now the symbol is t not W.

Isn't it the case that __introsort_loop has references to pre-emptible
functions like move_median*. So, it is important to make  the
referenced functions hidden than making introsort_loop itself hidden.
It does not matter that introsort_loop is hidden or not.

Now, it is the case that a hidden function in a shared object calls a
pre-emptible function, right? Which means, the behaviour of the hidden
function can still be changed by providing new definitions for the
pre-emptible functions.



 c++ -O2 -Wl,--icf=all,--print-icf-sections -shared -fPIC
 -fvisibility-inlines-hidden -ffunction-sections ICFproblem.cpp -o libbha.so

 nm -C libbha.so | grep intro
 1fa0 t void 
 std::__introsort_loop__gnu_cxx::__normal_iteratorA**,
 std::vectorA*, std::allocatorA*  , 
 long(__gnu_cxx::__normal_iteratorA**,
 std::vectorA*, std::allocatorA*  , __gnu_cxx::__normal_iteratorA**,
 std::vectorA*, std::allocatorA*  , long)
 2230 t void 
 std::__introsort_loop__gnu_cxx::__normal_iteratorB**,
 std::vectorB*, std::allocatorB*  , 
 long(__gnu_cxx::__normal_iteratorB**,
 std::vectorB*, std::allocatorB*  , __gnu_cxx::__normal_iteratorB**,
 std::vectorB*, std::allocatorB*  , long)
 24c0 t void 
 std::__introsort_loop__gnu_cxx::__normal_iteratorC**,
 std::vectorC*, std::allocatorC*  , 
 long(__gnu_cxx::__normal_iteratorC**,
 std::vectorC*, std::allocatorC*  , __gnu_cxx::__normal_iteratorC**,
 std::vectorC*, std::allocatorC*  , long)

 --
 Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
 --- You are receiving this mail because: ---
 You are on the CC list for the bug.
 You are the assignee for the bug.


-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-09-21 Thread vincenzo.innocente at cern dot ch
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

--- Comment #1 from Vincenzo Innocente vincenzo.innocente at cern dot ch 
2011-09-21 16:50:18 UTC ---
any news on a solution of this kind of problem?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-09-21 Thread tmsriram at google dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

--- Comment #2 from Sriraman Tallam tmsriram at google dot com 2011-09-21 
16:52:53 UTC ---
Sorry, I did not get a chance to look at this yet. I will take a look
at it this week.

Thanks,
-Sri.

On Wed, Sep 21, 2011 at 9:50 AM, vincenzo.innocente at cern dot ch
sourceware-bugzi...@sourceware.org wrote:
 http://sourceware.org/bugzilla/show_bug.cgi?id=12919

 --- Comment #1 from Vincenzo Innocente vincenzo.innocente at cern dot ch 
 2011-09-21 16:50:18 UTC ---
 any news on a solution of this kind of problem?

 --
 Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
 --- You are receiving this mail because: ---
 You are on the CC list for the bug.
 You are the assignee for the bug.


-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-09-21 Thread tmsriram at google dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

Sriraman Tallam tmsriram at google dot com changed:

   What|Removed |Added

 CC||iant at google dot com

--- Comment #3 from Sriraman Tallam tmsriram at google dot com 2011-09-21 
18:57:08 UTC ---
It is about pre-emptible symbols and libstdcxx makes namespace std as visiblity
default.

It is working as intended. Let me explain with an example first.

If you have two functions foo and bar, calling zip and zap. If foo and bar are
in a shared object and exported in the dynamic symbol table, it is not correct
to fold foo and bar even though zip and zap get folded. Simple reason, zip and
zap can be pre-empted by another definition in the executable. So, the ICF
algorithm would only fold foo and bar if they both called functions with the
same name. 

Here, the 3 introsort_loop functions essentially point to different
move_median* functions (the functions differ in their names), for A, B and C.
The move_median functions themselves get folded, but since they are exported, 
icf thinks they can be pre-empted and in theory they can. So, it will not fold
the introsort_loop functions.

However, if you were to link this into an executable, the introsort_loop
functions would be folded.

However, pre-emption of these functions maybe never happens in practice. So, I
could add a flag to icf that disables preemption and the introsort_loop
functions would be folded. I am not sure if this is the right thing to do.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-09-21 Thread tmsriram at google dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

--- Comment #4 from Sriraman Tallam tmsriram at google dot com 2011-09-21 
18:58:03 UTC ---
It is about pre-emptible symbols and libstdcxx makes namespace std as visiblity
default.

It is working as intended. Let me explain with an example first.

If you have two functions foo and bar, calling zip and zap. If foo and bar are
in a shared object and exported in the dynamic symbol table, it is not correct
to fold foo and bar even though zip and zap get folded. Simple reason, zip and
zap can be pre-empted by another definition in the executable. So, the ICF
algorithm would only fold foo and bar if they both called functions with the
same name. 

Here, the 3 introsort_loop functions essentially point to different
move_median* functions (the functions differ in their names), for A, B and C.
The move_median functions themselves get folded, but since they are exported, 
icf thinks they can be pre-empted and in theory they can. So, it will not fold
the introsort_loop functions.

However, if you were to link this into an executable, the introsort_loop
functions would be folded.

However, pre-emption of these functions maybe never happens in practice. So, I
could add a flag to icf that disables preemption and the introsort_loop
functions would be folded. I am not sure if this is the right thing to do.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-09-21 Thread ian at airs dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

Ian Lance Taylor ian at airs dot com changed:

   What|Removed |Added

 CC||ian at airs dot com

--- Comment #5 from Ian Lance Taylor ian at airs dot com 2011-09-21 19:55:58 
UTC ---
I think you actually could combine functions within a .so.  Although the
symbols are preemptible, if one of them is actually preempted, it will be done
by redirecting the PLT entry.  So as long as you provide separate PLT entries
for each symbol, you could arrange for all the PLT entries to point, by
default, to the same code.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-09-21 Thread vincenzo.innocente at cern dot ch
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

--- Comment #6 from Vincenzo Innocente vincenzo.innocente at cern dot ch 
2011-09-21 19:58:07 UTC ---
Thanks for the detailed analysis that indeed makes sense in the general case.
In this specific example introsort_loop is not inlined just for choice of a gcc
heuristics.
My understanding was that with -fvisibility-inlines-hidden I made the 3
move_median_first and the 3 introsort_loop functions internals to the library
and therefore neither visible nor preempt-able.
maybe they need to be declared inline in gcc or even hidden?
In any case I do not think that they are ment to be preempt-able!

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-09-21 Thread tmsriram at google dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

--- Comment #7 from Sriraman Tallam tmsriram at google dot com 2011-09-21 
21:25:45 UTC ---
The std namespace is marked explicity with default visibility. So, these
symbols are exported no matter what. If you do hide those symbols the folding
will work.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-09-21 Thread pcarlini at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

Paolo Carlini pcarlini at gmail dot com changed:

   What|Removed |Added

 CC||pcarlini at gmail dot com

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-06-22 Thread ian at airs dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

Ian Lance Taylor ian at airs dot com changed:

   What|Removed |Added

Summary|icf falis to fold one of|icf fails to fold one of
   |the component of std::sort  |the component of std::sort

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12919] icf fails to fold one of the component of std::sort

2011-06-22 Thread tmsriram at google dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12919

Sriraman Tallam tmsriram at google dot com changed:

   What|Removed |Added

 AssignedTo|ian at airs dot com |tmsriram at google dot com

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils