This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/21111] IA-64 NaT consumption faults due to uninitialized register reads


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

--- Comment #7 from Jim Wilson <wilson at gcc dot gnu.org> ---
I must have failed to realize that this was a bug I had created when I got the
earlier message.

Looking now, I see that I can still reproduce with mainline, though the problem
is not as obvious with this testcase.  Compiling with -O -S -fdump-rtl-all, I
see for the bitfield insert of i into foo.i

(insn 8 5 9 2 (set (reg:DI 348)
        (zero_extend:DI (reg/v:SI 345 [ i ]))) "tmp.c":10 -1
     (nil))
(insn 9 8 10 2 (set (reg:DI 350)
        (const_int 2147483647 [0x7fffffff])) "tmp.c":10 -1
     (nil))
(insn 10 9 11 2 (set (reg:DI 349)
        (and:DI (reg:DI 348)
            (reg:DI 350))) "tmp.c":10 -1
     (nil))
(insn 11 10 12 2 (set (reg:DI 352)
        (const_int -2147483648 [0xffffffff80000000])) "tmp.c":10 -1
     (nil))
(insn 12 11 13 2 (set (reg:DI 351)
        (and:DI (reg:DI 343 [ D.1463 ])
            (reg:DI 352))) "tmp.c":10 -1
     (nil))
(insn 13 12 14 2 (set (reg:DI 353)
        (ior:DI (reg:DI 351)
            (reg:DI 349))) "tmp.c":10 -1
     (nil))
(insn 14 13 15 2 (set (reg:DI 343 [ D.1463 ])
        (reg:DI 353)) "tmp.c":10 -1
     (nil))

And note that in the fifth insn (reg:DI 343) is used uninitialized.  This is
not safe on IA-64, as an uninit register may accidentally have the NaT bit set,
which would then cause a trap.

For this testcase, later optimization passes clean up the mess, and we get
correct code at the end.  However, it is not safe to have a read of an uninit
pseudo on IA-64, as there is no guarantee that a later optimization pass will
accidentally fix it.

Mostly the compiler works because we rarely speculate, and hence we rarely have
registers with the NaT bit set, and hence it is very rare that anyone will ever
trigger this problem.

Andrew Pinski suggests that it is an NRV problem, but I see the same issue with
NRV disabled.

An possible fix might be to force all locals to zero, to ensure that we never
read from an uninit register.

I no longer have access to IA-64 hardware at home or at work.  There is no
IA-64 hardware in the compile farm either.  I also no longer care whether this
issue gets addressed.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]