On Thu, May 09, 2013 at 05:52:26PM +0800, Chung-Lin Tang wrote: >2013-05-09 Chung-Lin Tang <clt...@codesourcery.com> > > PR target/32219 > * rtlanal.c (nonzero_address_p): Robustify checking by look > recursively into PIC constant offsets and (CONST (UNSPEC ...)) > expressions.
>Index: rtlanal.c >=================================================================== >--- rtlanal.c (revision 198735) >+++ rtlanal.c (working copy) >@@ -387,13 +387,22 @@ nonzero_address_p (const_rtx x) > return false; > > case CONST: >- return nonzero_address_p (XEXP (x, 0)); >+ { >+ rtx base, offset; >+ /* Peel away any constant offsets from the base symbol. */ >+ split_const (CONST_CAST_RTX (x), &base, &offset); >+ return nonzero_address_p (base); >+ } > >+ case UNSPEC: >+ /* Reach for a contained symbol. */ >+ return nonzero_address_p (XVECEXP (x, 0, 0)); >+ > case PLUS: > /* Handle PIC references. */ > if (XEXP (x, 0) == pic_offset_table_rtx > && CONSTANT_P (XEXP (x, 1))) >- return true; >+ return nonzero_address_p (XEXP (x, 1)); > return false; > > case PRE_MODIFY: >Index: testsuite/gcc.dg/visibility-21.c >=================================================================== >--- testsuite/gcc.dg/visibility-21.c (revision 0) >+++ testsuite/gcc.dg/visibility-21.c (revision 0) Please put this into gcc.dg/torture/ instead to make sure it works on all optimization levels. >@@ -0,0 +1,12 @@ >+/* PR target/32219 */ >+/* { dg-do run } */ >+/* { dg-require-visibility "" } */ >+/* { dg-options "-O1 -fPIC" { target fpic } } */ I do not remember offhand if the whole test should dg-require-effective-target fpic >+ >+extern void f() __attribute__((weak,visibility("hidden"))); >+int main() >+{ >+ if (f) >+ f(); >+ return 0; >+} Thanks for taking care of this PR! Bernhard