------- Comment #3 from pinskia at gcc dot gnu dot org 2006-01-31 16:24 ------- Reduced testcase: int f(void); static typeof(f) g __attribute__((weakref("f"))); int h(void) { return g(); }
----- Actually is obviously why x86 goes wrong: in ix86_function_ok_for_sibcall: /* If we are generating position-independent code, we cannot sibcall optimize any indirect call, or a direct call to a global function, as the PLT requires %ebx be live. */ if (!TARGET_64BIT && flag_pic && (!decl || TREE_PUBLIC (decl))) return false; TREE_PUBLIC Is the wrong check here. s390 fixed it a different correct way: http://gcc.gnu.org/ml/gcc-patches/2005-12/msg00646.html See the thread: http://gcc.gnu.org/ml/gcc/2005-12/msg00718.html Again checking TREE_PUBLIC is not the correct check really. In fact reading tree.h, it seems so too as it is just commenting about the name: nonzero means name is to be accessible from outside this module. Which has nothing to do with the function being external. -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Component|middle-end |target GCC build triplet|i686-pc-linux-gnu | GCC host triplet|i686-pc-linux-gnu | Summary|[4.2 Regression] weak_ref |[4.2 Regression] weakref |sibcalled with -fPIC |sibcalled with -fPIC http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25377