public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements
@ 2023-06-05 12:45 admin@tho-otto.de
  2023-06-06 14:26 ` [Bug modula2/110126] " gaius at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: admin@tho-otto.de @ 2023-06-05 12:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

            Bug ID: 110126
           Summary: Variables are reported as unused when only referenced
                    by ASM statements
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: admin@tho-otto.de
  Target Milestone: ---

In the following fragment:

MODULE foo;

VAR x: INTEGER;

PROCEDURE test;
BEGIN
  ASM("" : : "m"(x));
END test;

END foo.

x is reported as unused (same happens when specifying it as output parameter)

Even worse, when used as input operand only, the whole asm statement seems to
be optimized away.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
@ 2023-06-06 14:26 ` gaius at gcc dot gnu.org
  2023-06-07  5:06 ` admin@tho-otto.de
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-06-06 14:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

--- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> ---
The procedure test is unreachable, if the module is re-written as:

MODULE fooasm ;

VAR x: INTEGER;

PROCEDURE test;
BEGIN
  ASM("" : : "m"(x));
END test;

BEGIN
   test
END fooasm.


then the assembly output for procedure test in gm2 -S fooasm.mod looks similar
to:

static int x;

void test (void)
{
  asm ("" : : "m"(x));
}

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
  2023-06-06 14:26 ` [Bug modula2/110126] " gaius at gcc dot gnu.org
@ 2023-06-07  5:06 ` admin@tho-otto.de
  2023-06-07 12:50 ` gaius at gcc dot gnu.org
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: admin@tho-otto.de @ 2023-06-07  5:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

--- Comment #2 from Thorsten Otto <admin@tho-otto.de> ---
But even if i rewrite it like that, i still get the warning.

I avoided doing anything machine specific in the first example, but if i
actually do, and use something like:

PROCEDURE test;
BEGIN
  ASM("movl %1,%%eax; addl $1,%%eax; movl %%eax,%0" : "=r"(x) : "0"(x) :
"eax");
END test;

i still get the warning.

BTW, is there a reason why the string in the asm statement can't be
concatenated?

eg. especially if the statement becomes longer, you would usually want to write
it something like

  ASM("movl %1,%%eax;" +
      "addl $1,%%eax;" +
      "movl %%eax,%0"
     : "=r"(x) : "0"(x) : "eax");

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
  2023-06-06 14:26 ` [Bug modula2/110126] " gaius at gcc dot gnu.org
  2023-06-07  5:06 ` admin@tho-otto.de
@ 2023-06-07 12:50 ` gaius at gcc dot gnu.org
  2023-06-08 20:33 ` gaius at gcc dot gnu.org
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-06-07 12:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2023-06-07
     Ever confirmed|0                           |1

--- Comment #3 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Ah yes indeed, so there are two issues:

   (1)  gm2 -Wall -c foo.mod generates an incorrect warning.
   (2)  gm2 cannot concatenate strings before an ASM statement.

will fix - thanks for the report(s)

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (2 preceding siblings ...)
  2023-06-07 12:50 ` gaius at gcc dot gnu.org
@ 2023-06-08 20:33 ` gaius at gcc dot gnu.org
  2023-06-08 23:56 ` cvs-commit at gcc dot gnu.org
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-06-08 20:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gaius at gcc dot gnu.org

--- Comment #4 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 55285
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55285&action=edit
Proposed fix

Here is a proposed fix.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (3 preceding siblings ...)
  2023-06-08 20:33 ` gaius at gcc dot gnu.org
@ 2023-06-08 23:56 ` cvs-commit at gcc dot gnu.org
  2023-06-08 23:56 ` gaius at gcc dot gnu.org
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-06-08 23:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>:

https://gcc.gnu.org/g:990d10ab23360fef8b5eb6937ac10b4f67f46e2d

commit r14-1638-g990d10ab23360fef8b5eb6937ac10b4f67f46e2d
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Fri Jun 9 00:55:50 2023 +0100

    PR modula2/110126 variables are reported as unused when referenced by ASM

    This patches fixes two problems with the asm statement.
    gm2 -Wall -c fooasm3.mod generates an incorrect warning and
    gm2 cannot concatenate strings before an ASM statement.
    The asm statement now accepts a constant expression (rather than
    a string) and it updates the variable read/write use lists as
    appropriate.

    gcc/m2/ChangeLog:

            PR modula2/110126
            * gm2-compiler/M2GenGCC.mod (BuildTreeFromInterface): Remove
            tokenno parameter.  Use object tok instead of tokenno.
            (BuildTrashTreeFromInterface): Use object tok instead of
            GetDeclaredMod.
            (CodeInline): Remove tokenno from parameter list to
BuildTreeFromInterface.
            * gm2-compiler/M2Quads.def (BuildAsmElement): Exported and
            defined.
            * gm2-compiler/M2Quads.mod (BuildOptimizeOff): Reformatted.
            (BuildInline): Reformatted.
            (BuildLineNo): Reformatted.
            (UseLineNote): Reformatted.
            (BuildAsmElement): New procedure.
            * gm2-compiler/P0SyntaxCheck.bnf (AsmOperands): Use
            ConstExpression instead of string.
            (AsmElement): Use ConstExpression instead of string.
            (TrashList): Use ConstExpression instead of string.
            * gm2-compiler/P1Build.bnf (AsmOperands): Use
            ConstExpression instead of string.
            (AsmElement): Use ConstExpression instead of string.
            (TrashList): Use ConstExpression instead of string.
            * gm2-compiler/P2Build.bnf (AsmOperands): Use
            ConstExpression instead of string.
            (AsmElement): Use ConstExpression instead of string.
            (TrashList): Use ConstExpression instead of string.
            * gm2-compiler/P3Build.bnf (AsmOperands): Rewrite.
            (AsmOperandSpec): Rewrite.
            (AsmOutputList): New rule.
            (AsmInputList): New rule.
            (TrashList): Rewrite.
            * gm2-compiler/PCBuild.bnf (AsmOperands): Use
            ConstExpression instead of string.
            (AsmElement): Use ConstExpression instead of string.
            (TrashList): Use ConstExpression instead of string.
            * gm2-compiler/PHBuild.bnf (AsmOperands): Use
            ConstExpression instead of string.
            (AsmElement): Use ConstExpression instead of string.
            (TrashList): Use ConstExpression instead of string.
            * gm2-compiler/SymbolTable.def (PutRegInterface):
            Rewrite interface.
            (GetRegInterface): Rewrite interface.
            * gm2-compiler/SymbolTable.mod (SetFirstUsed): New procedure.
            (PutFirstUsed): New procedure.
            (PutRegInterface): Rewrite.
            (GetRegInterface): Rewrite.

    gcc/testsuite/ChangeLog:

            PR modula2/110126
            * gm2/pim/pass/fooasm3.mod: New test.

    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (4 preceding siblings ...)
  2023-06-08 23:56 ` cvs-commit at gcc dot gnu.org
@ 2023-06-08 23:56 ` gaius at gcc dot gnu.org
  2023-06-09  6:21 ` admin@tho-otto.de
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-06-08 23:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Closing now patch has been applied - thanks for the report!

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (5 preceding siblings ...)
  2023-06-08 23:56 ` gaius at gcc dot gnu.org
@ 2023-06-09  6:21 ` admin@tho-otto.de
  2023-06-09  7:19 ` admin@tho-otto.de
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: admin@tho-otto.de @ 2023-06-09  6:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

Thorsten Otto <admin@tho-otto.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |ASSIGNED
         Resolution|FIXED                       |---

--- Comment #7 from Thorsten Otto <admin@tho-otto.de> ---
Thanks for looking into this.

Unfortunately, with the new patch applied, i now get

cc1gm2: internal compiler error: symbol out of bounds
0x7f4dfde2cbaf __libc_start_call_main
        ???:0
0x7f4dfde2cc78 __libc_start_main_alias_1
        ???:0

Have yet to try to create a simple testcase that triggers this bug.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (6 preceding siblings ...)
  2023-06-09  6:21 ` admin@tho-otto.de
@ 2023-06-09  7:19 ` admin@tho-otto.de
  2023-06-12 12:26 ` gaius at gcc dot gnu.org
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: admin@tho-otto.de @ 2023-06-09  7:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

--- Comment #8 from Thorsten Otto <admin@tho-otto.de> ---
And here are examples that trigger the bug:

DEFINITION MODULE BIOS;

FROM SYSTEM IMPORT ADDRESS, CARDINAL32, INTEGER16, INTEGER32;

END BIOS.

IMPLEMENTATION MODULE BIOS;

PROCEDURE trap_13_w(n: INTEGER16): [ INTEGER32 ];
VAR
    retvalue: INTEGER32;
BEGIN
    ASM VOLATILE(""
       : "=r"(retvalue)
       : "g"(n)
       : "cc", "memory"
    );
    RETURN retvalue
END trap_13_w;


BEGIN
END BIOS.

The crash disappears when i remove the clobber list from the asm.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (7 preceding siblings ...)
  2023-06-09  7:19 ` admin@tho-otto.de
@ 2023-06-12 12:26 ` gaius at gcc dot gnu.org
  2023-06-12 13:35 ` admin@tho-otto.de
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-06-12 12:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

--- Comment #9 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 55309
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55309&action=edit
Proposed fix v2

Here is a proposed fix, please can you test on your code?   It appears to work
with my short examples.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (8 preceding siblings ...)
  2023-06-12 12:26 ` gaius at gcc dot gnu.org
@ 2023-06-12 13:35 ` admin@tho-otto.de
  2023-06-12 14:26 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: admin@tho-otto.de @ 2023-06-12 13:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

--- Comment #10 from Thorsten Otto <admin@tho-otto.de> ---
Yes, thank you, that seems to work.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (9 preceding siblings ...)
  2023-06-12 13:35 ` admin@tho-otto.de
@ 2023-06-12 14:26 ` cvs-commit at gcc dot gnu.org
  2023-06-12 14:28 ` gaius at gcc dot gnu.org
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-06-12 14:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>:

https://gcc.gnu.org/g:bf470895905e9152424076d1630a9d2c60de023b

commit r14-1718-gbf470895905e9152424076d1630a9d2c60de023b
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Mon Jun 12 15:25:39 2023 +0100

    PR modula2/110126 variables are reported as unused when referenced by ASM
fix

    This patch fixes the trash list of the asm statement.  It introduces a
    separate build procedure for trashed elements.

    gcc/m2/ChangeLog:

            PR modula2/110126
            * gm2-compiler/M2Quads.def (BuildAsmElement): Remove
            trash parameter.
            (BuildAsmTrash): New procedure.
            * gm2-compiler/M2Quads.mod (BuildAsmTrash): New procedure.
            (BuildAsmElement): Remove trash parameter.
            * gm2-compiler/P3Build.bnf (AsmTrashList): Rewrite.

    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (10 preceding siblings ...)
  2023-06-12 14:26 ` cvs-commit at gcc dot gnu.org
@ 2023-06-12 14:28 ` gaius at gcc dot gnu.org
  2023-06-13 11:36 ` admin@tho-otto.de
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-06-12 14:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #12 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Many thanks for the bug report and for testing the patches!
Closing now the patches have been applied.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (11 preceding siblings ...)
  2023-06-12 14:28 ` gaius at gcc dot gnu.org
@ 2023-06-13 11:36 ` admin@tho-otto.de
  2023-07-11 18:13 ` admin@tho-otto.de
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: admin@tho-otto.de @ 2023-06-13 11:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

--- Comment #13 from Thorsten Otto <admin@tho-otto.de> ---
Just found a small problem: asm statements without any lists,
like in

ASM("");

now are warned about with "syntax warning, ':' missing"

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (12 preceding siblings ...)
  2023-06-13 11:36 ` admin@tho-otto.de
@ 2023-07-11 18:13 ` admin@tho-otto.de
  2023-07-29 16:25 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: admin@tho-otto.de @ 2023-07-11 18:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

Thorsten Otto <admin@tho-otto.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #14 from Thorsten Otto <admin@tho-otto.de> ---
And another problem i just encountered. In the following example:

DEFINITION MODULE foo;

PROCEDURE ConWS(str: ARRAY OF CHAR);

END foo.


IMPLEMENTATION MODULE foo;

FROM SYSTEM     IMPORT ADR, CARDINAL16, CARDINAL32, INTEGER16, ADDRESS,
INTEGER32, WORD;

FROM StrIO IMPORT WriteString, WriteLn;

TYPE strtmp = ARRAY [0..255] OF CHAR;

PROCEDURE str0(VAR dst: strtmp; src: ARRAY OF CHAR);
VAR i, len: CARDINAL;
BEGIN
  len := HIGH(dst);
  FOR i := 0 TO len DO
    dst[i] := src[i];
  END;
END str0;


PROCEDURE trap_1_wl(n: INTEGER16; a: ADDRESS): [ INTEGER32 ];
VAR
    retvalue: INTEGER32;
BEGIN
    ASM VOLATILE("move.l %2,-(%%sp); move.w %1,-(%%sp); trap #1; addq.l
#6,%%sp; move.l %%d0,%0"
       : "=r"(retvalue)
       : "g"(n), "r"(a)
       : "memory"
    );
    RETURN retvalue
END trap_1_wl;


PROCEDURE ConWS(str: ARRAY OF CHAR);
VAR s: strtmp;
BEGIN
  str0(s, str);
  trap_1_wl(9, ADR(s));
END ConWS;


END foo.

The call to str0 (in reality supposed to ensure the string is 0-terminated;
just simplified for the example) is now completely eliminated. The assembler
statement is of course only for m68k, but it can even be triggered for other
targets when just producing assembler output.

It does not happen when replacing the call to trap_1_wl eg. by WriteString.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (13 preceding siblings ...)
  2023-07-11 18:13 ` admin@tho-otto.de
@ 2023-07-29 16:25 ` cvs-commit at gcc dot gnu.org
  2023-07-29 20:04 ` cvs-commit at gcc dot gnu.org
  2023-07-29 20:13 ` gaius at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-29 16:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

--- Comment #15 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Gaius Mulley
<gaius@gcc.gnu.org>:

https://gcc.gnu.org/g:3ad40f65a7c89af2f3cb71c06e327ee33a996bd4

commit r13-7644-g3ad40f65a7c89af2f3cb71c06e327ee33a996bd4
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Sat Jul 29 17:24:38 2023 +0100

    PR modula2/110126 variables are reported as unused when referenced by ASM

    This patches fixes two problems with the asm statement.
    gm2 -Wall -c fooasm3.mod generates an incorrect warning and
    gm2 cannot concatenate strings before an ASM statement.
    The asm statement now accepts a constant expression (rather than
    a string) and it updates the variable read/write use lists as
    appropriate.

    gcc/m2/ChangeLog:

            PR modula2/110126
            * gm2-compiler/M2GenGCC.mod (BuildTreeFromInterface): Remove
            tokenno parameter.  Use object tok instead of tokenno.
            (BuildTrashTreeFromInterface): Use object tok instead of
            GetDeclaredMod.
            (CodeInline): Remove tokenno from parameter list to
BuildTreeFromInterface.
            * gm2-compiler/M2Quads.def (BuildAsmElement): Exported and
            defined.
            * gm2-compiler/M2Quads.mod (BuildOptimizeOff): Reformatted.
            (BuildInline): Reformatted.
            (BuildLineNo): Reformatted.
            (UseLineNote): Reformatted.
            (BuildAsmElement): New procedure.
            * gm2-compiler/P0SyntaxCheck.bnf (AsmOperands): Use
            ConstExpression instead of string.
            (AsmElement): Use ConstExpression instead of string.
            (TrashList): Use ConstExpression instead of string.
            * gm2-compiler/P1Build.bnf (AsmOperands): Use
            ConstExpression instead of string.
            (AsmElement): Use ConstExpression instead of string.
            (TrashList): Use ConstExpression instead of string.
            * gm2-compiler/P2Build.bnf (AsmOperands): Use
            ConstExpression instead of string.
            (AsmElement): Use ConstExpression instead of string.
            (TrashList): Use ConstExpression instead of string.
            * gm2-compiler/P3Build.bnf (AsmOperands): Rewrite.
            (AsmOperandSpec): Rewrite.
            (AsmOutputList): New rule.
            (AsmInputList): New rule.
            (TrashList): Rewrite.
            * gm2-compiler/PCBuild.bnf (AsmOperands): Use
            ConstExpression instead of string.
            (AsmElement): Use ConstExpression instead of string.
            (TrashList): Use ConstExpression instead of string.
            * gm2-compiler/PHBuild.bnf (AsmOperands): Use
            ConstExpression instead of string.
            (AsmElement): Use ConstExpression instead of string.
            (TrashList): Use ConstExpression instead of string.
            * gm2-compiler/SymbolTable.def (PutRegInterface):
            Rewrite interface.
            (GetRegInterface): Rewrite interface.
            * gm2-compiler/SymbolTable.mod (SetFirstUsed): New procedure.
            (PutFirstUsed): New procedure.
            (PutRegInterface): Rewrite.
            (GetRegInterface): Rewrite.

    gcc/testsuite/ChangeLog:

            PR modula2/110126
            * gm2/pim/pass/fooasm3.mod: New test.

    (cherry picked from commit 990d10ab23360fef8b5eb6937ac10b4f67f46e2d)

    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (14 preceding siblings ...)
  2023-07-29 16:25 ` cvs-commit at gcc dot gnu.org
@ 2023-07-29 20:04 ` cvs-commit at gcc dot gnu.org
  2023-07-29 20:13 ` gaius at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-29 20:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

--- Comment #16 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Gaius Mulley
<gaius@gcc.gnu.org>:

https://gcc.gnu.org/g:4fa9afdc9b52cfa9ea16443418de29e0e31b293b

commit r13-7646-g4fa9afdc9b52cfa9ea16443418de29e0e31b293b
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Sat Jul 29 21:04:26 2023 +0100

    PR modula2/110126 variables are reported as unused when referenced by ASM
fix

    This patch fixes the trash list of the asm statement.  It introduces a
    separate build procedure for trashed elements.

    gcc/m2/ChangeLog:

            PR modula2/110126
            * gm2-compiler/M2Quads.def (BuildAsmElement): Remove
            trash parameter.
            (BuildAsmTrash): New procedure.
            * gm2-compiler/M2Quads.mod (BuildAsmTrash): New procedure.
            (BuildAsmElement): Remove trash parameter.
            * gm2-compiler/P3Build.bnf (AsmTrashList): Rewrite.

    (cherry picked from commit bf470895905e9152424076d1630a9d2c60de023b)

    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements
  2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
                   ` (15 preceding siblings ...)
  2023-07-29 20:04 ` cvs-commit at gcc dot gnu.org
@ 2023-07-29 20:13 ` gaius at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-07-29 20:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110126

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #17 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Many thanks for the bug report and test code!
Closing now as the patches have been applied to the gcc-13 branch.

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-07-29 20:13 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-05 12:45 [Bug modula2/110126] New: Variables are reported as unused when only referenced by ASM statements admin@tho-otto.de
2023-06-06 14:26 ` [Bug modula2/110126] " gaius at gcc dot gnu.org
2023-06-07  5:06 ` admin@tho-otto.de
2023-06-07 12:50 ` gaius at gcc dot gnu.org
2023-06-08 20:33 ` gaius at gcc dot gnu.org
2023-06-08 23:56 ` cvs-commit at gcc dot gnu.org
2023-06-08 23:56 ` gaius at gcc dot gnu.org
2023-06-09  6:21 ` admin@tho-otto.de
2023-06-09  7:19 ` admin@tho-otto.de
2023-06-12 12:26 ` gaius at gcc dot gnu.org
2023-06-12 13:35 ` admin@tho-otto.de
2023-06-12 14:26 ` cvs-commit at gcc dot gnu.org
2023-06-12 14:28 ` gaius at gcc dot gnu.org
2023-06-13 11:36 ` admin@tho-otto.de
2023-07-11 18:13 ` admin@tho-otto.de
2023-07-29 16:25 ` cvs-commit at gcc dot gnu.org
2023-07-29 20:04 ` cvs-commit at gcc dot gnu.org
2023-07-29 20:13 ` gaius at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).