public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/96347] New: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location
@ 2020-07-27 22:19 ibuclaw at gdcproject dot org
  2020-07-27 22:22 ` [Bug target/96347] " ibuclaw at gdcproject dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-07-27 22:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96347
           Summary: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in
                    variable location
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ibuclaw at gdcproject dot org
  Target Milestone: ---

Created attachment 48938
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48938&action=edit
test case

Attached test that was translated to C++ from D after being minimised.

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

* [Bug target/96347] note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location
  2020-07-27 22:19 [Bug target/96347] New: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location ibuclaw at gdcproject dot org
@ 2020-07-27 22:22 ` ibuclaw at gdcproject dot org
  2020-07-28 13:06 ` ibuclaw at gdcproject dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-07-27 22:22 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Buclaw <ibuclaw at gdcproject dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_86-linux-gnu
              Build|                            |x86_86-linux-gnu
      Known to work|                            |8.4.0
      Known to fail|                            |10.1.0, 11.0, 9.3.0
               Host|                            |x86_86-linux-gnu

--- Comment #1 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
(In reply to Iain Buclaw from comment #0)
> Created attachment 48938 [details]
> test case
> 
> Attached test that was translated to C++ from D after being minimised.

Forgot to mention, needs to be compiled with: -O2 -g -fchecking

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

* [Bug target/96347] note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location
  2020-07-27 22:19 [Bug target/96347] New: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location ibuclaw at gdcproject dot org
  2020-07-27 22:22 ` [Bug target/96347] " ibuclaw at gdcproject dot org
@ 2020-07-28 13:06 ` ibuclaw at gdcproject dot org
  2020-07-28 14:55 ` ibuclaw at gdcproject dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-07-28 13:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Possibly some useful information for context.

At expand_expr_real_1 (expr.c:10567) there is the following expression.
---
MEM <int *> [(struct Darray *)&testYearsBC + 8B]
---

Lowered to RTL as
---
(plus:DI (unspec:DI [
            (const_int 0 [0])
        ] UNSPEC_TP)
    (const:DI (plus:DI (unspec:DI [
                    (symbol_ref:DI ("testYearsBC") [flags 0x2a] <var_decl
0x7ffff7fa2bd0 testYearsBC>)
                ] UNSPEC_NTPOFF)
            (const_int 8 [0x8]))))
---

At break_out_memory_refs (explow.c:277) the rhs of the plus expression is
forced into a register.
---
(insn 18 17 0 (set (reg:DI 89)
        (const:DI (plus:DI (unspec:DI [
                        (symbol_ref:DI ("testYearsBC") [flags 0x2a] <var_decl
0x7ffff7fa2bd0 testYearsBC>)
                    ] UNSPEC_NTPOFF)
                (const_int 8 [0x8])))) -1
     (nil))

(mem/f/c:DI (plus:DI (unspec:DI [
                (const_int 0 [0])
            ] UNSPEC_TP)
        (reg:DI 89)) [1 MEM <int *> [(struct Darray *)&testYearsBC + 8B]+0 S8
A64])
---

And it is the second insn that reaches const_ok_for_output_1() at
mem_loc_descriptor (dwarf2out.c:15748)
---
(note 133 132 163 3 (var_location year (mem:SI (mem/f/c:DI (plus:DI (unspec:DI
[
                    (const_int 0 [0])
                ] UNSPEC_TP)
            (reg/f:DI 6 bp [90])) [1 MEM <int *> [(struct Darray *)&testYearsBC
+ 8B]+0 S8 A64]) [6 *rs$pt
r_5+0 S4 A32])) NOTE_INSN_VAR_LOCATION)
---

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

* [Bug target/96347] note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location
  2020-07-27 22:19 [Bug target/96347] New: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location ibuclaw at gdcproject dot org
  2020-07-27 22:22 ` [Bug target/96347] " ibuclaw at gdcproject dot org
  2020-07-28 13:06 ` ibuclaw at gdcproject dot org
@ 2020-07-28 14:55 ` ibuclaw at gdcproject dot org
  2020-07-29 18:12 ` ibuclaw at gdcproject dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-07-28 14:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Created attachment 48946
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48946&action=edit
disallow tpoff+offset from being stored in a temp

Patch prevents the forced temp from being used to replace the rhs of the
original PLUS expr at memory_address_addr_space (explow.c:434), so the excess
errors are gone.

Alters the resultant assembly in the following way:
---
@@ -35,15 +35,11 @@ _Z5chain6Darray:
 main:
 .LFB4:
        .cfi_startproc
-       pushq   %rbp
-       .cfi_def_cfa_offset 16
-       .cfi_offset 6, -16
-       leaq    8+testYearsBC@tpoff, %rbp
        pushq   %rbx
-       .cfi_def_cfa_offset 24
-       .cfi_offset 3, -24
-       subq    $40, %rsp
-       .cfi_def_cfa_offset 64
+       .cfi_def_cfa_offset 16
+       .cfi_offset 3, -16
+       subq    $32, %rsp
+       .cfi_def_cfa_offset 48
        leaq    17(%rsp), %rbx
        jmp     .L6
        .p2align 4,,10
@@ -56,11 +52,11 @@ main:
        movl    $0, (%rbx)
        movw    %ax, 4(%rbx)
        movb    $0, 6(%rbx)
-       movq    %fs:0(%rbp), %rdx
        movq    %fs:testYearsBC@tpoff, %rax
+       movq    %fs:8+testYearsBC@tpoff, %rdx
        movb    $0, 16(%rsp)
-       movq    %rdx, 8(%rsp)
        movq    %rax, (%rsp)
+       movq    %rdx, 8(%rsp)
        testq   %rax, %rax
        je      .L7
        jmp     .L9
@@ -71,9 +67,8 @@ main:
 main.cold:
 .LFSB4:
 .L7:
-       .cfi_def_cfa_offset 64
-       .cfi_offset 3, -24
-       .cfi_offset 6, -16
+       .cfi_def_cfa_offset 48
+       .cfi_offset 3, -16
        call    abort@PLT
        .cfi_endproc
 .LFE4:

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

* [Bug target/96347] note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location
  2020-07-27 22:19 [Bug target/96347] New: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location ibuclaw at gdcproject dot org
                   ` (2 preceding siblings ...)
  2020-07-28 14:55 ` ibuclaw at gdcproject dot org
@ 2020-07-29 18:12 ` ibuclaw at gdcproject dot org
  2020-08-06 12:02 ` ibuclaw at gdcproject dot org
  2023-10-18 18:59 ` ibuclaw at gdcproject dot org
  5 siblings, 0 replies; 7+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-07-29 18:12 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Buclaw <ibuclaw at gdcproject dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #48946|0                           |1
        is obsolete|                            |

--- Comment #4 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Created attachment 48953
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48953&action=edit
delegitimize mem(plus (unspec reg) tls)

Second patch, this time dealing with the following insn
---
(mem/f/c:DI (plus:DI (unspec:DI [
                (const_int 0 [0])
            ] UNSPEC_TP)
        (reg:DI 89)) [1 MEM <int *> [(struct Darray *)&testYearsBC + 8B]+0 S8
A64])
---

After ix86_delegitimize_tls_address, it becomes
---
(mem/f/c:DI (reg/f:DI 6 bp [90]) [1 MEM <int *> [(struct Darray *)&testYearsBC
+ 8B]+0 S8 A64])
---

Doesn't change assembly produced for given test, but alters debug output:
---
@@ -1105,12 +1105,9 @@ testYearsBC:
 .LLST4:
        .quad   .LVL7
        .quad   .LVL8-1
-       .value  0xd
-       .byte   0xe
-       .long   testYearsBC@dtpoff, 0
-       .byte   0xe0
-       .byte   0x23
-       .uleb128 0x8
+       .value  0x3
+       .byte   0x76
+       .sleb128 0
        .byte   0x6
        .quad   0
        .quad   0
@@ -1148,15 +1145,12 @@ testYearsBC:
 .LLST6:
        .quad   .LVL9
        .quad   .LVL9
-       .value  0x11
+       .value  0x7
        .byte   0x50
        .byte   0x93
        .uleb128 0x8
-       .byte   0xe
-       .long   testYearsBC@dtpoff, 0
-       .byte   0xe0
-       .byte   0x23
-       .uleb128 0x8
+       .byte   0x76
+       .sleb128 0
        .byte   0x93
        .uleb128 0x8
        .quad   0
@@ -1167,15 +1161,12 @@ testYearsBC:
 .LLST7:
        .quad   .LVL9
        .quad   .LVL9
-       .value  0x11
+       .value  0x7
        .byte   0x50
        .byte   0x93
        .uleb128 0x8
-       .byte   0xe
-       .long   testYearsBC@dtpoff, 0
-       .byte   0xe0
-       .byte   0x23
-       .uleb128 0x8
+       .byte   0x76
+       .sleb128 0
        .byte   0x93
        .uleb128 0x8
        .quad   0
---

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

* [Bug target/96347] note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location
  2020-07-27 22:19 [Bug target/96347] New: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location ibuclaw at gdcproject dot org
                   ` (3 preceding siblings ...)
  2020-07-29 18:12 ` ibuclaw at gdcproject dot org
@ 2020-08-06 12:02 ` ibuclaw at gdcproject dot org
  2023-10-18 18:59 ` ibuclaw at gdcproject dot org
  5 siblings, 0 replies; 7+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-08-06 12:02 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Buclaw <ibuclaw at gdcproject dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #48953|0                           |1
        is obsolete|                            |

--- Comment #5 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Created attachment 49009
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49009&action=edit
favour tls_mem_loc_descriptor

Patch leaves delegitimize alone and instead plugs the warning in dwarf2out.c. 
If MEM is a TLS reference, then try tls_mem_loc_descriptor() first.

No observed changes in either assembly or debug as a result of the patch.

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

* [Bug target/96347] note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location
  2020-07-27 22:19 [Bug target/96347] New: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location ibuclaw at gdcproject dot org
                   ` (4 preceding siblings ...)
  2020-08-06 12:02 ` ibuclaw at gdcproject dot org
@ 2023-10-18 18:59 ` ibuclaw at gdcproject dot org
  5 siblings, 0 replies; 7+ messages in thread
From: ibuclaw at gdcproject dot org @ 2023-10-18 18:59 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Buclaw <ibuclaw at gdcproject dot org> changed:

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

--- Comment #6 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
(releases/gcc-9) $ ./gcc/xg++ -B ./gcc/ pr.cc -O2 -g -fchecking
pr.cc: In function ‘int main()’:
pr.cc:45:5: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable
location
   45 | int main (void)
      |     ^~~~
pr.cc:45:5: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable
location

(releases/gcc-10) $ ./gcc/xg++ -B ./gcc/ pr.cc -O2 -g -fchecking
pr.cc: In function ‘int main()’:
pr.cc:45:5: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable
location
   45 | int main (void)
      |     ^~~~
pr.cc:45:5: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable
location
pr.cc:45:5: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable
location

(releases/gcc-11) $ ./gcc/xg++ -B ./gcc/ pr.cc -O2 -g -fchecking

(releases/gcc-12) $ ./gcc/xg++ -B ./gcc/ pr.cc -O2 -g -fchecking

(releases/gcc-13) $ ./gcc/xg++ -B ./gcc/ pr.cc -O2 -g -fchecking

(trunk) $ ./gcc/xg++ -B ./gcc/ pr.cc -O2 -g -fchecking

Minimal test is only reproducible on the 9.x and 10.x compilers, and I've not
seen it crop up again in any D testsuite runs. I'll just close this then.

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

end of thread, other threads:[~2023-10-18 18:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27 22:19 [Bug target/96347] New: note: non-delegitimized UNSPEC UNSPEC_TP (19) found in variable location ibuclaw at gdcproject dot org
2020-07-27 22:22 ` [Bug target/96347] " ibuclaw at gdcproject dot org
2020-07-28 13:06 ` ibuclaw at gdcproject dot org
2020-07-28 14:55 ` ibuclaw at gdcproject dot org
2020-07-29 18:12 ` ibuclaw at gdcproject dot org
2020-08-06 12:02 ` ibuclaw at gdcproject dot org
2023-10-18 18:59 ` ibuclaw at gdcproject dot 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).