This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA:] PR37170, extern weak broken, like for gcc.dg/weak/weak-1.c


Weak support for extern weak symbols in some use cases,
depending on the declaration, now rely on the code path
modified in the patch below, added around July 22, meant to
catch symbol references in output_operand.  Unfortunately, the
current code is incomplete, and only catches references of type
(mem (symbol_ref)), which relies on a specific addressing mode
being supported in the target as well as that particular operand
being generated, instead of e.g. a bare symbol_ref and one or
more (mem reg).  The former happens for ix86 but not for ia64,
powerpc64 and cris.  Here's a fix to make it more general.

<rant
I must say, this bug and several other current regressions would
likely not have happened had it not been for the policy of
testing patches affecting middle-end having been softened up.
At one time testing such patches on more that one target was
required.  Please consider again requiring testing on more than
one target, and I don't mean x86_64 and ix86.  It can't be
helped that it takes more time.  The bottle-neck for a commit is
review, not testing.
>

Tested manually that the missing .weak directive for the extern
gcc.dg/weak/weak-1.c case is now emitted for ia64-elf and
i386-elf.  Regtested on cris-elf and native
x86_64-unknown-linux-gnu.  Testing revealed that this patch also
fixes gcc.dg/visibility-16.c which never passed for cris-elf.

Ok to commit?

	PR middle-end/37170
	* final.c (output_operand): Generalize extraction of
	symbol_ref for assemble_external.

Index: final.c
===================================================================
--- final.c	(revision 139233)
+++ final.c	(working copy)
@@ -3359,6 +3359,8 @@
 static void
 output_operand (rtx x, int code ATTRIBUTE_UNUSED)
 {
+  rtx tem;
+
   if (x && GET_CODE (x) == SUBREG)
     x = alter_subreg (&x);
 
@@ -3366,10 +3368,23 @@
   gcc_assert (!x || !REG_P (x) || REGNO (x) < FIRST_PSEUDO_REGISTER);
 
   PRINT_OPERAND (asm_out_file, x, code);
-  if (x && MEM_P (x) && GET_CODE (XEXP (x, 0)) == SYMBOL_REF)
+
+  if (x == NULL_RTX)
+    return;
+
+  /* Dig out the innermost non-memory entity.  */
+  while (MEM_P (x))
+    x = XEXP (x, 0);
+
+  /* Strip any integer offset.  */
+  tem = get_related_value (x);
+  if (tem != NULL_RTX)
+    x = tem;
+
+  /* If we have a symbol, handle external and weak assembly annotations.  */
+  if (x != NULL_RTX && GET_CODE (x) == SYMBOL_REF)
     {
       tree t;
-      x = XEXP (x, 0);
       t = SYMBOL_REF_DECL (x);
       if (t)
 	assemble_external (t);

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]