1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 10:32:48 +02:00

X86: Fix/workaround Small Code Model for JIT

Force RIP-relative jump tables and global values
Force RIP-relative all zeros / all ones constants
These things were causing crashes due to use of absolute addressing
This commit is contained in:
Nekotekina 2018-05-12 13:46:20 +03:00
parent 1739071165
commit 391548e226
2 changed files with 10 additions and 12 deletions

View File

@ -2395,7 +2395,7 @@ const MCExpr *X86TargetLowering::
getPICJumpTableRelocBaseExpr(const MachineFunction *MF, unsigned JTI,
MCContext &Ctx) const {
// X86-64 uses RIP relative addressing based on the jump table label.
if (Subtarget.isPICStyleRIPRel())
if (Subtarget.isPICStyleRIPRel() || Subtarget.is64Bit())
return TargetLowering::getPICJumpTableRelocBaseExpr(MF, JTI, Ctx);
// Otherwise, the reference is relative to the PIC base.
@ -18586,7 +18586,7 @@ unsigned X86TargetLowering::getGlobalWrapperKind(
return X86ISD::Wrapper;
CodeModel::Model M = getTargetMachine().getCodeModel();
if (Subtarget.isPICStyleRIPRel() &&
if ((Subtarget.isPICStyleRIPRel() || Subtarget.is64Bit()) &&
(M == CodeModel::Small || M == CodeModel::Kernel))
return X86ISD::WrapperRIP;

View File

@ -5983,16 +5983,14 @@ MachineInstr *X86InstrInfo::foldMemoryOperandImpl(
// x86-32 PIC requires a PIC base register for constant pools.
unsigned PICBase = 0;
if (MF.getTarget().isPositionIndependent()) {
if (Subtarget.is64Bit())
PICBase = X86::RIP;
else
// FIXME: PICBase = getGlobalBaseReg(&MF);
// This doesn't work for several reasons.
// 1. GlobalBaseReg may have been spilled.
// 2. It may not be live at MI.
return nullptr;
}
if (Subtarget.is64Bit())
PICBase = X86::RIP;
else if (MF.getTarget().isPositionIndependent())
// FIXME: PICBase = getGlobalBaseReg(&MF);
// This doesn't work for several reasons.
// 1. GlobalBaseReg may have been spilled.
// 2. It may not be live at MI.
return nullptr;
// Create a constant-pool entry.
MachineConstantPool &MCP = *MF.getConstantPool();