From d18817ded94cc9586a3817f12013282ef16ddf83 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sat, 12 May 2018 13:46:20 +0300 Subject: [PATCH] X86: Fix/workaround Small Code Model for JIT Force RIP-relative jump tables and global values These things were causing crashes due to use of absolute addressing --- lib/Target/X86/X86ISelLowering.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 032db2a80a7..e3106438df1 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -2451,7 +2451,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. @@ -19206,7 +19206,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;