summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2019-11-09 09:29:42 +0300
committerSimon Atanasyan <simon@atanasyan.com>2019-11-15 23:38:14 +0300
commit0287efb891c1da33d8eb01889f18ef71cd689ebc (patch)
treecd5ddd4adef43ffb39814af621e2cba54f2f0f69 /llvm/lib/Target
parent09c7e51283dafbfd122cc0d7ab251476c451c9f5 (diff)
downloadbcm5719-llvm-0287efb891c1da33d8eb01889f18ef71cd689ebc.tar.gz
bcm5719-llvm-0287efb891c1da33d8eb01889f18ef71cd689ebc.zip
[mips] Do not emit R_MIPS_JALR for sym+offset in case of O32 ABI
O32 ABI uses relocations in REL format. Relocation's addend is written in place. R_MIPS_JALR relocation points to the `jalr` instruction which does not have a place to store the relocation addend. So it's impossible to save non-zero "offset". This patch blocks emission of `R_MIPS_JALR` relocations in such cases. Differential Revision: https://reviews.llvm.org/D70201
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index 11c9cddb28c..65c373b10f5 100644
--- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -562,6 +562,19 @@ public:
return getSTI().getFeatureBits()[Mips::FeatureFP64Bit];
}
+ bool isJalrRelocAvailable(const MCExpr *JalExpr) {
+ if (!EmitJalrReloc)
+ return false;
+ MCValue Res;
+ if (!JalExpr->evaluateAsRelocatable(Res, nullptr, nullptr))
+ return false;
+ if (Res.getSymB() != nullptr)
+ return false;
+ if (Res.getConstant() != 0)
+ return ABI.IsN32() || ABI.IsN64();
+ return true;
+ }
+
const MipsABIInfo &getABI() const { return ABI; }
bool isABI_N32() const { return ABI.IsN32(); }
bool isABI_N64() const { return ABI.IsN64(); }
@@ -2048,7 +2061,7 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
JalrInst.addOperand(MCOperand::createReg(Mips::RA));
JalrInst.addOperand(MCOperand::createReg(Mips::T9));
- if (EmitJalrReloc) {
+ if (isJalrRelocAvailable(JalExpr)) {
// As an optimization hint for the linker, before the JALR we add:
// .reloc tmplabel, R_{MICRO}MIPS_JALR, symbol
// tmplabel:
OpenPOWER on IntegriCloud