public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/66790] New: Invalid uninitialized register handling in REE
@ 2015-07-07 16:05 derodat at adacore dot com
  2015-07-07 16:06 ` [Bug rtl-optimization/66790] " derodat at adacore dot com
                   ` (37 more replies)
  0 siblings, 38 replies; 39+ messages in thread
From: derodat at adacore dot com @ 2015-07-07 16:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66790
           Summary: Invalid uninitialized register handling in REE
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: derodat at adacore dot com
  Target Milestone: ---

The reproducer I'm about to attach[1] seems to trigger a code generation issue
at least on x86_64-linux:

    $ gnatmake -q p -O3 -gnatn
    $ ./p

    raised PROGRAM_ERROR : p.adb:9 explicit raise

The bottom line is that when Success is False in Q.Get (q.adb, around line 40)
its value is clobbered during return. If we build with -fno-ree, we can see in
the assembly code (near the return point for q__get) the following sequence:

    movzwl    (%rax), %epb
    ...
somelabel:
    ...
    movzwl    %bp, %ebp
    ...
    salq    $16, %rax
    orq    %rbp, %rax

However, without the -fno-ree switch the instruction:

    movzwl    %bp, %ebp

is merged with its definition (the first movzwl instruction) by the REE pass.
This is wrong since the definition does _not_ dominate this zero-extension: the
first movzwl instruction can be by-passed through "somelabel".

I started to investigate this issue: the REE pass is currently not aware of
this by-pass code path because it is reached by no proper definition (it brings
an uninitialized %rbp register to the zero-extension). This happens in
ree.c:get_defs; in our case (insn=second movzwl, reg=BP) DF_REF_CHAIN contains
only one definition: the movzwl instruction.

Given the "somelabel" code path, I would rather expect DF_REF_CHAIN to hold a
NULL reference to materialize the lack of initialization in one path. I found
the DF_LR_IN/DF_LR_OUT macros from df.h: they provide information about
uninitialized variables but the associated comment says they should not be used
("This intolerance should eventually be fixed."). Besides, they provide a
basic-block-level information whereas we are rather interested in
instruction-level information in REE.

I was thinking that REE may not be the only optimization pass needing this kind
of information but I found no other one, so I'm not sure how this ought to be
handled. Can anybody confirm my intuition about the NULL reference in
DF_REF_CHAIN? I'm willing to implement it but I prefer first to be sure this is
the right approach.

Thanks in advance!


[1] It's in Ada. I tried to translate it into C but any change in register
allocation makes the issue disappear...


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

end of thread, other threads:[~2015-10-19 23:48 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-07 16:05 [Bug rtl-optimization/66790] New: Invalid uninitialized register handling in REE derodat at adacore dot com
2015-07-07 16:06 ` [Bug rtl-optimization/66790] " derodat at adacore dot com
2015-07-07 16:06 ` derodat at adacore dot com
2015-07-07 16:06 ` derodat at adacore dot com
2015-07-29 13:06 ` rguenth at gcc dot gnu.org
2015-07-30  9:54 ` derodat at adacore dot com
2015-07-31  8:17 ` derodat at adacore dot com
2015-07-31  8:18 ` derodat at adacore dot com
2015-09-10 14:16 ` ebotcazou at gcc dot gnu.org
2015-09-10 14:26 ` derodat at adacore dot com
2015-09-10 14:40 ` ebotcazou at gcc dot gnu.org
2015-09-10 14:44 ` derodat at adacore dot com
2015-09-16 11:45 ` bernds at gcc dot gnu.org
2015-09-16 17:52 ` ebotcazou at gcc dot gnu.org
2015-09-16 22:54 ` bernds at gcc dot gnu.org
2015-09-17 10:21 ` ebotcazou at gcc dot gnu.org
2015-09-17 10:39 ` bernds at gcc dot gnu.org
2015-09-17 11:27 ` bonzini at gnu dot org
2015-09-17 12:52 ` zadeck at naturalbridge dot com
2015-09-17 12:53 ` ebotcazou at gcc dot gnu.org
2015-09-17 14:41 ` zadeck at naturalbridge dot com
2015-09-17 15:36 ` ebotcazou at gcc dot gnu.org
2015-09-17 15:36 ` ebotcazou at gcc dot gnu.org
2015-09-17 15:36 ` ebotcazou at gcc dot gnu.org
2015-09-21 16:32 ` derodat at adacore dot com
2015-09-21 17:04 ` bernds at gcc dot gnu.org
2015-09-22  8:40 ` bonzini at gnu dot org
2015-09-22  9:03 ` ebotcazou at gcc dot gnu.org
2015-09-22  9:14 ` bonzini at gnu dot org
2015-09-23 10:04 ` derodat at adacore dot com
2015-09-23 10:05 ` derodat at adacore dot com
2015-09-23 10:23 ` bonzini at gnu dot org
2015-09-23 10:25 ` bernds at gcc dot gnu.org
2015-09-23 10:26 ` bonzini at gnu dot org
2015-09-24  7:42 ` derodat at adacore dot com
2015-10-01  5:44 ` derodat at adacore dot com
2015-10-03 10:45 ` bernds at gcc dot gnu.org
2015-10-12 14:47 ` derodat at adacore dot com
2015-10-19 23:48 ` pmderodat at gcc dot gnu.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).