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

            Bug ID: 102733
           Summary: missing fs:0 store when followed by one to gs:0
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

While testing r12-4376 I noticed that when a fs:0 store is followed by one to
gs:0 the former is not emitted, otherwise when each is done on its own each is
also emitted on its own.  My very basic understanding is that the FS and GS
namespaces are distinct with null being a valid address of a distinct location
in each (and so I would expect both stores to be emitted) but I leave it
experts to confirm or resolve this as invalid.

$ cat z.c && gcc -O -S -Wall -o/dev/stdout z.c
void test_null_store_fs (void)
{
  int __seg_fs *fs = (int __seg_fs *)0;
  *fs = 1;   // fs:0 store emitted
}

void test_null_store_gs (void)
{
  int __seg_gs *gs = (int __seg_gs *)0;
  *gs = 2;   // gs:0 store emitted
}

void test_null_store_fs_gs (void)
{
  int __seg_fs *fs = (int __seg_fs *)0;
  *fs = 1;   // store missing

  int __seg_gs *gs = (int __seg_gs *)0;
  *gs = 2;   // gs:0 store emitted
}
        .file   "z.c"
        .text
        .globl  test_null_store_fs
        .type   test_null_store_fs, @function
test_null_store_fs:
.LFB0:
        .cfi_startproc
        movl    $1, %fs:0
        ret
        .cfi_endproc
.LFE0:
        .size   test_null_store_fs, .-test_null_store_fs
        .globl  test_null_store_gs
        .type   test_null_store_gs, @function
test_null_store_gs:
.LFB1:
        .cfi_startproc
        movl    $2, %gs:0
        ret
        .cfi_endproc
.LFE1:
        .size   test_null_store_gs, .-test_null_store_gs
        .globl  test_null_store_fs_gs
        .type   test_null_store_fs_gs, @function
test_null_store_fs_gs:
.LFB2:
        .cfi_startproc
        movl    $2, %gs:0
        ret
        .cfi_endproc
.LFE2:
        .size   test_null_store_fs_gs, .-test_null_store_fs_gs
        .ident  "GCC: (GNU) 12.0.0 20211013 (experimental)"
        .section        .note.GNU-stack,"",@progbits

Reply via email to