This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix PR middle-end/46674
- From: Jie Zhang <jie at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 01 Dec 2010 07:57:58 +0800
- Subject: Fix PR middle-end/46674
PR 46674 is same as PR 46221 indeed. It happens when one alias has a
user set name.
extern void jelly (void) __asm__ ("jelly2") __attribute__ ((alias
("dessert"), weak));
extern void wobbly (void) __attribute__ ((alias ("jelly2"), weak));
When jelly was added to the visible point set, the identifier was
"*jelly2". But later GCC looked for identifier "jelly2" when deciding if
alias wobbly could be removed or not. Since "jelly2" was not in the
visible point set, alias wobbly would be removed.
With this patch, the identifier added to the visible point set has the
prefix '*' stripped if there is one.
Bootstrapped and regression tested on x86_64-linux-gnu with c,c++,lto.
OK?
Regards,
--
Jie Zhang
PR middle-end/46674
* varasm.c (compute_visible_aliases): Handle user set
assembler name.
testsuite/
PR middle-end/46674
* gcc.dg/pr46674.c: New test.
Index: testsuite/gcc.dg/pr46674.c
===================================================================
--- testsuite/gcc.dg/pr46674.c (revision 0)
+++ testsuite/gcc.dg/pr46674.c (revision 0)
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-require-alias "" } */
+/* { dg-options "-O2" } */
+
+int yum;
+void dessert (void) { ++yum; }
+extern void jelly (void) __asm__ ("jelly2") __attribute__ ((alias ("dessert"), weak));
+extern void wobbly (void) __attribute__ ((alias ("jelly2"), weak));
+
+/* { dg-final { scan-assembler "wobbly" } } */
+/* { dg-final { scan-assembler "jelly2" } } */
Index: varasm.c
===================================================================
--- varasm.c (revision 167217)
+++ varasm.c (working copy)
@@ -5526,12 +5526,21 @@ compute_visible_aliases (void)
{
struct cgraph_node *fnode = NULL;
struct varpool_node *vnode = NULL;
+ tree asmname = DECL_ASSEMBLER_NAME (p->decl);
+ const char *str = IDENTIFIER_POINTER (asmname);
+
+ if (str[0] == '*')
+ {
+ str ++;
+ asmname = get_identifier (str);
+ }
+
fnode = cgraph_node_for_asm (p->target);
vnode = (fnode == NULL) ? varpool_node_for_asm (p->target) : NULL;
if ((fnode
|| vnode
|| pointer_set_contains (visible, p->target))
- && !pointer_set_insert (visible, DECL_ASSEMBLER_NAME (p->decl)))
+ && !pointer_set_insert (visible, asmname))
changed = true;
}
}