This is an archive of the discontinued LLVM Phabricator instance.

[mips] Relax jalr/jr instructions using R_MIPS_JALR relocation
ClosedPublic

Authored by atanasyan on Sep 25 2019, 3:19 PM.

Details

Summary

The R_MIPS_JALR relocation denotes jalr/jr instructions in position independent code. Both these instructions take a target's address from the $25 register. If offset to the target symbol fits into the 18-bits, it's more efficient to replace jalr/jr by bal/b instructions.

Diff Detail

Repository
rL LLVM

Event Timeline

atanasyan created this revision.Sep 25 2019, 3:19 PM
jrtc27 added inline comments.Sep 25 2019, 3:29 PM
lld/ELF/Arch/Mips.cpp
645 ↗(On Diff #221844)

isInt<18>(val)?

atanasyan marked an inline comment as done.Sep 25 2019, 10:25 PM
atanasyan added inline comments.
lld/ELF/Arch/Mips.cpp
645 ↗(On Diff #221844)

Sure. Thanks.

Simplify code - replace SignExtend64 by the isInt.

ruiu accepted this revision.Sep 25 2019, 10:43 PM

LGTM

This revision is now accepted and ready to land.Sep 25 2019, 10:43 PM
MaskRay added inline comments.Sep 25 2019, 11:00 PM
lld/test/ELF/mips-jalr.s
3 ↗(On Diff #221886)

## for comments.

atanasyan marked an inline comment as done.Sep 26 2019, 2:12 AM
This revision was automatically updated to reflect the committed changes.