This is the mail archive of the gcc-patches@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]

Re: [pr 41246] Fix incorrect values of DECL_NO_STATIC_CHAIN


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.


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