Will the "tail" pseudo instruction always get transformed to the "jalr" instruction?
SaiVK opened this issue · 9 comments
Hello Everyone
I compiled a C program with -O2 flag enabled. On inspecting the assembly file generated by the compiler (-S flag) I noticed a couple of tail pseudo instruction. But in the object dump file generated, I noticed that the tail pseudo instruction gets converted to j instruction.
My doubt is, in the explanation given in the manual, it is specified that tail pseudo instruction gets transformed to jalr. Is this not followed always?
Thank you so much
Sai
Hello @aswaterman
Oh ok, so only when a far-away subroutine is being invoked, the tail pseudo instruction transforms to an auipc + jalr instruction. Else, it can transform to j or c.j instruction.
Did I understand it properly?
Thank you so much
Sai
Yes. Note the linker performs that transformation, so the object code will always show auipc/jalr.
@aswaterman
Got it.
Is it possible to modify the linker such that all tail pseudo instructions transform only to jalr instruction and not to j or c.j instruction?
Thank you so much
Sai
I think you can pass the --no-relax
flag to the linker.
@aswaterman
Oh ok. I will try using that flag.
Are there any downsides in using that?
Thank you so much
Sai
Yes - increased code size and lower performance
Oh ok. Got it.
Thank you so much @aswaterman for taking your time and explaining it to me.
Sai
You're welcome!