public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/23478] New: Miscompilation due to reloading of a var that is also used in EH pad
@ 2005-08-19 11:09 jakub at redhat dot com
  2005-08-19 11:28 ` [Bug rtl-optimization/23478] " jakub at redhat dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: jakub at redhat dot com @ 2005-08-19 11:09 UTC (permalink / raw)
  To: gcc-bugs

The following testcase is miscompiled on x86_64-linux at -O2.
Before global alloc/reload, the interesting part of code is:
(reg:DI %rax) = (call _Znwm (1))
(reg:DI 81) = (reg:DI %rax)
...
(reg:DI %rdi) = (reg:DI 81)
(call _ZN2C1C1ERK2C3S2_S2_RPS1_ (%rdi, ...)) - may throw, EH pad .Leh
...
(reg:DI %rdi) = (reg:DI 81)
...
(barrier)
.Leh:
(reg:DI %rdi) = (reg:DI 81)
(call _ZdlPv (%rdi))

Now, as the register preassure is pretty high, there don't appear to be any
free usable call saved registers for pseudo 81, so global alloc assigns pseudo
81 into (reg:DI %r10), which is call clobbered.  Then reload saves it into stack
before the _ZN2C1C1ERK2C3S2_S2_RPS1_ call and restores it from the stack slot
after the call.  But doesn't restore it on the EH path as well.
So we end up with:
(reg:DI %rax) = (call _Znwm (1))
(reg:DI %r10 (81)) = (reg:DI %rax)
...
(reg:DI %rdi) = (reg:DI %r10 (81))
(mem:DI %rsp+24) = (reg:DI %r10 (81))
(call _ZN2C1C1ERK2C3S2_S2_RPS1_ (%rdi, ...)) - may throw, EH pad .Leh
(reg:DI %r10 (81)) = (mem:DI %rsp+24)
...
(reg:DI %rdi) = (reg:DI %r10 (81))
...
(barrier)
.Leh:
(reg:DI %rdi) = (reg:DI %r10 (81))
(call _ZdlPv (%rdi))

As this is a reload bug, it is not reproduceable on != 3.4.x compilers I have
tried, which doesn't mean the bug is present on 3.4.x only though.

-- 
           Summary: Miscompilation due to reloading of a var that is also
                    used in EH pad
           Product: gcc
           Version: 3.4.5
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at redhat dot com
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: x86_64-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23478


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

end of thread, other threads:[~2005-09-01 20:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-19 11:09 [Bug rtl-optimization/23478] New: Miscompilation due to reloading of a var that is also used in EH pad jakub at redhat dot com
2005-08-19 11:28 ` [Bug rtl-optimization/23478] " jakub at redhat dot com
2005-08-19 12:11 ` [Bug rtl-optimization/23478] [3.4 regression] " belyshev at depni dot sinp dot msu dot ru
2005-08-19 13:57 ` jakub at redhat dot com
2005-08-19 18:33 ` rth at gcc dot gnu dot org
2005-08-19 18:37 ` rth at gcc dot gnu dot org
2005-08-19 18:54 ` jakub at redhat dot com
2005-08-19 19:16 ` rth at gcc dot gnu dot org
2005-08-22 17:33 ` cvs-commit at gcc dot gnu dot org
2005-08-26 16:58 ` schwab at suse dot de
2005-08-29 23:00 ` sje at cup dot hp dot com
2005-09-01  5:29 ` cvs-commit at gcc dot gnu dot org
2005-09-01  6:05 ` cvs-commit at gcc dot gnu dot org
2005-09-01 20:51 ` cvs-commit at gcc dot gnu dot org
2005-09-01 20:53 ` jakub at gcc dot gnu dot 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).