On Sat, 29 Feb 2020, Jeff Law wrote: > > Wow, I think I wrote the v850 port back in circa 1997 and this bug has been > latent all this time. Vlad's IRA changes twiddled register allocation in just > the right way to expose this bug. > > I'm not sure what I was thinking, but apparently I made a spectacularly bad > choice for the STATIC_CHAIN_REGNUM in choosing a call-saved register (r20). > > It's simply wrong to use a call-saved register for the static chain.
Heh. I did that mistake too, for CRIS. :/ A comment from RTH below my (incorrect) comment in cris.c above cris_asm_trampoline_template alludes to there being an ABI-neutral solution: "??? See the i386 regparm=3 implementation that pushes the static chain value to the stack in the trampoline, and uses a call-saved register when called directly." ... but IIRC it either didn't apply for CRIS or I didn't look into it thoroughly enough. Or that's also buggy. brgds, H-P PS. Perhaps a doc update with a warning is a suitable penance? :)