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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |9.5
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-01-26

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
(gdb) p debug_rtx (insn)
(insn 5 2 6 2 (parallel [
            (set (reg:DI 94)
                (plus:DI (reg:DI 244)
                    (const_int -112 [0xffffffffffffff90])))
            (clobber (reg:CC 17 flags))
        ]) "t.f90":1:9 230 {*adddi_1}
     (nil))

and we reference reg 244 but reg_info for this reg is NULL.  The insn is the
first in the BB and reg:DI 244 doesn't seem to be initialized.

The instruction is expanded from

;; _10 = &FRAME.16.FRAME_BASE.PARENT;

(insn 5 4 6 (parallel [
            (set (reg:DI 94)
                (plus:DI (reg:DI 244)
                    (const_int -112 [0xffffffffffffff90])))
            (clobber (reg:CC 17 flags))
        ]) "t.f90":1:9 -1
     (nil)) 

(insn 6 5 0 (parallel [
            (set (reg/f:DI 88 [ _10 ])
                (plus:DI (reg:DI 94)
                    (const_int 64 [0x40])))
            (clobber (reg:CC 17 flags))
        ]) "t.f90":1:9 -1
     (nil))

and the underlying issue is a shared FRAME.16 local used in two functions
I think:

__attribute__((fn spec (". ")))
voidD.27 sD.4214 ()
{
..
  struct FRAME.p FRAME.16D.4307;


...
__attribute__((fn spec (". ")))
voidD.27 pD.4212 ()
{
  struct FRAME.p FRAME.16D.4307;
...
  struct array01_character(kind=1) yD.4238 [value-expr:
FRAME.16D.4307.yD.4308];

where the frame is unused in 's' but likely expanded there and then
the expansion is used in the wrong function.

Without asan the references are likely optimized away.


Note in .original from the FE we see the shared variable is 'y':

void s ()
{
  {
    static integer(kind=8)D.9 .yD.4216;
    struct array01_character(kind=1) yD.4238;
...

void p ()
{
  static voidD.27 sD.4214 (void);
  struct array01_character(kind=1) yD.4238;
...

where that 'y' is unused in 'p'.

Reply via email to