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

Bernd Edlinger <bernd.edlinger at hotmail dot de> changed:

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

--- Comment #89 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 41103
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41103&action=edit
updated patch

should work in principle with LTO,
but there is still another bug
somewhere which makes __attribute__((may_alias))
and the std::byte handling fail in the end.

consider this test example:

cat t.cc
#include <cstddef>
//namespace std { enum class byte: unsigned char {}; };
struct t  {
  int x;
  //std::byte kk[1];
  unsigned char k;
} __attribute__((may_alias));

t t1;
t t2;
t *t3;
t *t4;

void __attribute__((noinline, noclone))
test()
{
  t1 = t2;
  *t4 = *t3;
}

int main()
{
  test();
}

g++ -std=c++17 -O2 -fdump-rtl-final t.cc

t.cc.309r.final:
(insn:TI 6 2 7 2 (set (reg:DI 0 ax [orig:90 MEM[(const struct t &
{ref-all})&t2] ] [90])
        (mem/c:DI (symbol_ref:DI ("t2") [flags 0x2]  <var_decl 0x7f973b7302d0
t2>) [0 MEM[(const struct t & {ref-all})&t2]+0 S8 A64])) "t.cc":17 81
{*movdi_internal}
     (expr_list:REG_EQUIV (mem/c:DI (symbol_ref:DI ("t2") [flags 0x2] 
<var_decl 0x7f973b7302d0 t2>) [0 MEM[(const struct t & {ref-all})&t2]+0 S8
A64])
        (nil)))
(insn:TI 7 6 14 2 (set (mem/c:DI (symbol_ref:DI ("t1") [flags 0x2]  <var_decl
0x7f973b730240 t1>) [2 t1+0 S8 A64])
        (reg:DI 0 ax [orig:90 MEM[(const struct t & {ref-all})&t2] ] [90]))
"t.cc":17 81 {*movdi_internal}
     (expr_list:REG_DEAD (reg:DI 0 ax [orig:90 MEM[(const struct t &
{ref-all})&t2] ] [90])
        (nil)))
(insn 14 7 10 2 (set (reg/f:DI 0 ax [orig:87 t3.1_1 ] [87])
        (mem/f/c:DI (symbol_ref:DI ("t3") [flags 0x2]  <var_decl 0x7f973b730360
t3>) [1 t3+0 S8 A64])) "t.cc":18 81 {*movdi_internal}
     (expr_list:REG_EQUIV (mem/f/c:DI (symbol_ref:DI ("t3") [flags 0x2] 
<var_decl 0x7f973b730360 t3>) [1 t3+0 S8 A64])
        (nil)))
(insn:TI 10 14 15 2 (set (reg:DI 1 dx [orig:91 MEM[(const struct t &
{ref-all})t3.1_1] ] [91])
        (mem:DI (reg/f:DI 0 ax [orig:87 t3.1_1 ] [87]) [0 MEM[(const struct t &
{ref-all})t3.1_1]+0 S8 A32])) "t.cc":18 81 {*movdi_internal}
     (expr_list:REG_DEAD (reg/f:DI 0 ax [orig:87 t3.1_1 ] [87])
        (nil)))
(insn 15 10 11 2 (set (reg/f:DI 0 ax [orig:88 t4.2_2 ] [88])
        (mem/f/c:DI (symbol_ref:DI ("t4") [flags 0x2]  <var_decl 0x7f973b7303f0
t4>) [1 t4+0 S8 A64])) "t.cc":18 81 {*movdi_internal}
     (expr_list:REG_EQUIV (mem/f/c:DI (symbol_ref:DI ("t4") [flags 0x2] 
<var_decl 0x7f973b7303f0 t4>) [1 t4+0 S8 A64])
        (nil)))
(insn:TI 11 15 23 2 (set (mem:DI (reg/f:DI 0 ax [orig:88 t4.2_2 ] [88]) [0
*t4.2_2+0 S8 A32])
        (reg:DI 1 dx [orig:91 MEM[(const struct t & {ref-all})t3.1_1] ] [91]))
"t.cc":18 81 {*movdi_internal}
     (expr_list:REG_DEAD (reg:DI 1 dx [orig:91 MEM[(const struct t &
{ref-all})t3.1_1] ] [91])
        (expr_list:REG_DEAD (reg/f:DI 0 ax [orig:88 t4.2_2 ] [88])
            (nil))))



I think the access to t1 uses alias set 2, and that is wrong.
The other accesses are ok.

Reply via email to