[PATCH] D37747: [MIPS] Fix PLT entries generation in case of linking regular and microMIPS code

Simon Atanasyan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 08:15:58 PDT 2017


atanasyan created this revision.
atanasyan added a project: lld.
Herald added subscribers: arichardson, sdardis, emaste.

Currently LLD calls the `isMicroMips` routine to determine type of PLT entries needs to be generated: regular or microMIPS. This routine checks ELF header flags in the `FirstObj` to retrieve type of linked object files. So if the first file does not contain microMIPS code, LLD will generate PLT entries with regular (non-microMIPS) code only.

Ideally, if a PLT entry is referenced by microMIPS code only this entry should contain microMIPS code, if a PLT entry is referenced by regular code this entry should contain regular code. In a "mixed" case the PLT entry can be either microMIPS or regular, but each "cross-mode-call" has additional cost.

It's rather difficult to implement this ideal solution. But we can assume that if there is an input object file with microMIPS code, the most part of the code is microMIPS too. So we need to deduce type of PLT entries based on finally calculated ELF header flags and do not check only the first input object file.

This change implements this.

- The `getMipsEFlags` function caches result of ELF flags calculation. Now it's cheap to call it multiple times.
- The `isMicroMips` and `isMipsR6` routines call `getMipsEFlags` to get and check calculated ELF flags.
- A side effect - these functions become non-template.


Repository:
  rL LLVM

https://reviews.llvm.org/D37747

Files:
  ELF/Arch/Mips.cpp
  ELF/Arch/MipsArchTree.cpp
  ELF/Writer.cpp
  ELF/Writer.h
  test/ELF/mips-elf-flags.s
  test/ELF/mips-micro-jal.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37747.114846.patch
Type: text/x-patch
Size: 9066 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170912/7fd73738/attachment.bin>


More information about the llvm-commits mailing list