[PATCH] pdp11: Fix handling of common (local and global) vars [PR94134]
Paul Koning
paulkoning@comcast.net
Wed Mar 11 17:19:26 GMT 2020
Ok, thanks.
paul
> On Mar 11, 2020, at 1:12 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> As mentioned in the PR, the generic code decides to put the a variable into
> lcomm_section, which is a NOSWITCH section and thus the generic code doesn't
> switch into a particular section before using
> ASM_OUTPUT{_ALIGNED{,_DECL}_}_LOCAL, on many targets that results just in
> .lcomm (or for non-local .comm) directives which don't need a switch to some
> section, other targets put switch_to_section (bss_section) at the start of
> that macro.
> pdp11 doesn't do that (and doesn't have bss_section), and so emits the
> lcomm/comm variables in whatever section is current (it has only .text/.data
> and for DEC assembler rodata).
>
> The following patch fixes that by putting it always into data section, and
> additionally avoids emitting an empty line in the assembly for the lcomm
> vars.
>
> Tested on the testcase, I'm afraid I have no other way to test this target.
> Ok for trunk?
>
> 2020-03-11 Jakub Jelinek <jakub@redhat.com>
>
> PR target/94134
> * config/pdp11/pdp11.c (pdp11_asm_output_var): Call switch_to_section
> at the start to switch to data section. Don't print extra newline if
> .globl directive has not been emitted.
>
> * gcc.c-torture/execute/pr94134.c: New test.
>
> --- gcc/config/pdp11/pdp11.c.jj 2020-01-12 11:54:36.382413876 +0100
> +++ gcc/config/pdp11/pdp11.c 2020-03-11 15:44:43.373970000 +0100
> @@ -743,6 +743,7 @@ void
> pdp11_asm_output_var (FILE *file, const char *name, int size,
> int align, bool global)
> {
> + switch_to_section (data_section);
> if (align > 8)
> fprintf (file, "\t.even\n");
> if (TARGET_DEC_ASM)
> @@ -763,8 +764,8 @@ pdp11_asm_output_var (FILE *file, const
> {
> fprintf (file, ".globl ");
> assemble_name (file, name);
> + fprintf (file, "\n");
> }
> - fprintf (file, "\n");
> assemble_name (file, name);
> fputs (":", file);
> ASM_OUTPUT_SKIP (file, size);
> --- gcc/testsuite/gcc.c-torture/execute/pr94134.c.jj 2020-03-11 15:46:09.540710642 +0100
> +++ gcc/testsuite/gcc.c-torture/execute/pr94134.c 2020-03-11 15:40:18.538840663 +0100
> @@ -0,0 +1,14 @@
> +/* PR target/94134 */
> +
> +static volatile int a = 0;
> +static volatile int b = 1;
> +
> +int
> +main ()
> +{
> + a++;
> + b++;
> + if (a != 1 || b != 2)
> + __builtin_abort ();
> + return 0;
> +}
>
> Jakub
>
More information about the Gcc-patches
mailing list