]> gcc.gnu.org Git - gcc.git/commitdiff
re PR target/19041 (-fvisibility=hidden causes bad codegen for common symbols)
authorAndrew Pinski <pinskia@physics.uc.edu>
Fri, 17 Dec 2004 00:25:16 +0000 (00:25 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Fri, 17 Dec 2004 00:25:16 +0000 (16:25 -0800)
2004-12-16  Andrew Pinski  <pinskia@physics.uc.edu>

        PR target/19041
        * config/darwin.c (machopic_symbol_defined_p): Return false
        if the binds local and is a common symbol.

2004-12-16  Andrew Pinski  <pinskia@physics.uc.edu>

        PR target/19041
        * gcc.dg/visibility-c.c: New test.

From-SVN: r92292

gcc/ChangeLog
gcc/config/darwin.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/visibility-c.c [new file with mode: 0644]

index b288e70dd95ef9291efab435e4024dcb9b153345..c323cbf4626dcf0025372fdcdbf966d75b04b1aa 100644 (file)
@@ -1,3 +1,9 @@
+2004-12-16  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR target/19041
+       * config/darwin.c (machopic_symbol_defined_p): Return false
+       if the binds local and is a common symbol.
+
 2004-12-16  Richard Henderson  <rth@redhat.com>
 
        * config/i386/i386.md (extv, extzv, insv): Revalidate the
index e4a3997815917cdd294984ebd936f26b118a21ad..7b4943b5a159962a178fd3d8ae88d4d6db5c75d3 100644 (file)
@@ -90,16 +90,30 @@ name_needs_quotes (const char *name)
   return 0;
 }
 
-/*
- * flag_pic = 1 ... generate only indirections
- * flag_pic = 2 ... generate indirections and pure code
- */
-
+/* Return true if SYM_REF can be used without an indirection.  */
 static int
 machopic_symbol_defined_p (rtx sym_ref)
 {
-  return (SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_DEFINED)
-    || (SYMBOL_REF_LOCAL_P (sym_ref) && ! SYMBOL_REF_EXTERNAL_P (sym_ref));
+  if (SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_DEFINED)
+    return true;
+
+  /* If a symbol references local and is not an extern to this
+     file, then the symbol might be able to declared as defined.  */
+  if (SYMBOL_REF_LOCAL_P (sym_ref) && ! SYMBOL_REF_EXTERNAL_P (sym_ref))
+    {
+      /* If the symbol references a variable and the variable is a
+        common symbol, then this symbol is not defined.  */
+      if (SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_VARIABLE)
+       {
+         tree decl = SYMBOL_REF_DECL (sym_ref);
+         if (!decl)
+           return true;
+         if (DECL_COMMON (decl))
+           return false;
+       }
+      return true;
+    }
+  return false;
 }
 
 /* This module assumes that (const (symbol_ref "foo")) is a legal pic
index a92fedc4dc046c1dcbd7303b70b28bded0459a00..c5530fad3a4847792f64d313ddbb6266e865ed50 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-16  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR target/19041
+       * gcc.dg/visibility-c.c: New test.
+
 2004-12-16  Roger Sayle  <roger@eyesopen.com>
 
        PR middle-end/18493
diff --git a/gcc/testsuite/gcc.dg/visibility-c.c b/gcc/testsuite/gcc.dg/visibility-c.c
new file mode 100644 (file)
index 0000000..66b4d25
--- /dev/null
@@ -0,0 +1,11 @@
+/* Test that visibility works on common symbols also. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-final { scan-hidden "options" } } */
+
+int options  __attribute__((__visibility__("hidden")));
+
+void f(void)
+{
+  options = 0;
+}
This page took 0.115618 seconds and 5 git commands to generate.