This is an archive of the discontinued LLVM Phabricator instance.

Modify MIPS long branch for NaCl
ClosedPublic

Authored by sstankovic on May 27 2014, 1:54 PM.

Details

Summary

[mips] Modify long branch for NaCl:

  • Move the instruction that changes sp outside of the branch delay slot.
  • Bundle-align the target of indirect branch.

Diff Detail

Event Timeline

sstankovic updated this revision to Diff 9846.May 27 2014, 1:54 PM
sstankovic retitled this revision from to Modify MIPS long branch for NaCl.
sstankovic updated this object.
sstankovic edited the test plan for this revision. (Show Details)
sstankovic added a reviewer: mseaborn.
sstankovic added subscribers: Unknown Object (MLST), petarj.
mseaborn edited edge metadata.May 27 2014, 3:33 PM

LGTM

BTW, if you're hitting this when targeting NaCl at the moment, you should probably turn off PIC code generation, since you don't need PIC for NaCl nexes.

lib/Target/Mips/MipsLongBranch.cpp
474

Could the code grow by more than a factor of 2? Some explanation of the max expansion factor here would be good.

e.g. "lw $sp, ($reg)" requires 2 sandboxing instructions to be added (before and after).

BTW, if you're hitting this when targeting NaCl at the moment, you should probably turn off PIC code generation, since you don't need PIC for NaCl nexes.

Should this be done in LLVM, or in pnacl/driver scripts?

lib/Target/Mips/MipsLongBranch.cpp
474

We measured code size on CSiBE, for pic relocation model (which on MIPS produces larger code than static), and sandboxing increased the size in the range 28% - 48%. I think it is very unlikely that the code will grow more than 100%.

MIPS traditionally used PIC relocation model, to be able to use shared libraries. PLT support (which enables non-PIC code to use shared libraries) was added to MIPS only recently, in 2008. I suppose at that time GCC switched to using non-PIC as default. I don't know why LLVM still uses PIC.

Regards,
Sasa

sstankovic accepted this revision.Jun 5 2014, 8:12 AM
sstankovic added a reviewer: sstankovic.
This revision is now accepted and ready to land.Jun 5 2014, 8:12 AM
sstankovic closed this revision.Jun 5 2014, 8:13 AM

Committed in r210262.