This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [mips] fix $gp restore bug
Adam Nemet <anemet@caviumnetworks.com> writes:
> Richard Sandiford writes:
>> FWIW, the idea I'm toying with at the moment is:
>>
>> - Make every branch use pic_offset_table_rtx.
>>
>> - Try to detect cases where a function only needs a global pointer
>> because of branches. In this case, emit easily-identifiable "ghost"
>> instructions (in the .md "type" attribute sense) to set, save and
>> restore the gp.
>>
>> These ghost instructions would replace the sequences we'd normally use.
>> They would have 0 length at this stage, and in theory shouldn't interfere
>> with things like scheduling.
>>
>> - At the end of md_reorg, run shorten_branches to see whether
>> all branches are in range. This should be safe because we run
>> dbr_schedule within mips_reorg. Nothing after mips_reorg should
>> change the insn stream besides shorten_branches itself.
>>
>> - If some branches are not in range, go through the insn stream and
>> replace all the ghost instructions with real implementations.
>> (This will of course invalidate the results of the shorten_branches
>> call, but the "real" shorten_branches pass will then calculate new
>> lengths.)
>
> This sounds like a good plan to me, FWIW.
Thanks. I tried it, and unfortunately it doesn't look like it's
going to work. Too much rtl infrastructure expects unconditional
jumps to be simple sets. I'm also not sure they really want a
situation where inserting a jump can suddenly change the liveness
of $gp.
Oh well. Back to the drawing board.
Richard