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 regression/20973] [4.0/4.1 Regression] kdelibs (khtml) miscompiled by reload


------- Additional Comments From wilson at gcc dot gnu dot org  2005-04-19 06:22 -------
The reload patch seems reasonable, though not very satisfying.  It is only
disabling some optimizations within reload, and hence should be somewhat safe. 
Though it is still a reload patch, and all reload patches are dangerous.

There is a hunk of code added twice, but only one of the two instances is
commented.  The other one should have a comment also.

Another way to look at this problem is to point out that we have an
uninitialized register, and claim that this is wrong.

This is actually dangerous on Itanium.  Suppose we call a hand-written glibc
routine which leaves a few NaT bits lying around.  Suppose we then assign the
uninitialized pseudo to one of these registers with a NaT bit set.  When we read
the register, we get an unhandled NaT consumption fault, and the program dies. 
This isn't hypothetical.  This actually happened once in the early days of the
Itanium port.  It is rather hard to reproduce, as gcc doesn't have speculation
support yet, so it is rare for a register to have the NaT bit set.  There are
only a few hand written library routines that can set NaT bits.  This will be a
more serious problem once we do have speculation support.

The old code for structures was careful to always initialize the structure
before doing any piecemeal initialization, if the structure was in a register. 
This way, we never had any uses of an unitialized register.  This is done in
store_constructor for instance.

Unfortunately, this isn't true now that we have tree-ssa, because structure
references are decomposed, and there is no longer any attempt to initialize the
whole structure if it is allocated to a register.

This will have to be fixed for Itanium.  All we need is an instruction to set
the uninitialized register to zero immediately before it is used.  It will then
be optimized away by combine, which will convert
  (set reg 0)
  (set reg (ior reg constant))
into
  (set reg constant)

Since we must eliminate the uninitialized register uses anyways, we perhaps
don't have to fix the reload issue.  It is probably harmless to make both fixes
though.  The reload patch should never trigger once the uninitialized register
problem is fixed.

-- 


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


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