This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [pr 41246] Fix incorrect values of DECL_NO_STATIC_CHAIN
- From: Duncan Sands <baldrick at free dot fr>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 17 Sep 2009 10:57:34 +0200
- Subject: Re: [pr 41246] Fix incorrect values of DECL_NO_STATIC_CHAIN
- References: <4AB113B0.6030706@redhat.com> <200909161950.57394.ebotcazou@adacore.com>
Hi,
I have absolutely no idea how the Ada compiler managed to function up
until now. By rights it should have fallen flat on its face due to
these incorrect settings.
the reason everything worked is that the static chain is not considered
a real parameter but is passed "out of band" in a special register. The
bug resulted in callers thinking that the callee took a static chain,
while the callees knew they didn't. As a result, callers would put the
chain in the register before performing the call. The callee would then
ignore the register and all was well. If it had been the other way
round, with callees expecting a chain but callers not providing it, then
that would have been fatal.
That said, this did kill the Ada compiler in llvm-gcc, because in
llvm-gcc the static chain is added as an additional parameter for
the nested function, so getting this wrong had an impact on how
all other parameters were passed (wrong registers etc). That's how
I first discovered this bug. It was fixed long ago in llvm-gcc, and
I apologise for not pushing my fix harder to gcc. That said, Richard's
fix looks much slicker than mine (I haven't tested it yet though), so
perhaps it was a good thing after all :)
Ciao,
Duncan.