From 85bb54f96421461aaafcde83b6302530179337e9 Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Thu, 4 Feb 2010 19:56:59 +0000 Subject: [PATCH] Disable external stubs for X86-32 and X86-64 Instruction selection for X86 now can choose an instruction sequence that will fit any address of any symbol, no matter the pointer width. X86-64 uses a mov+call-via-reg sequence for this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95323 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineRelocation.h | 5 +++-- lib/Target/X86/X86CodeEmitter.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/llvm/CodeGen/MachineRelocation.h b/include/llvm/CodeGen/MachineRelocation.h index 1c15fab532d..c316785dd11 100644 --- a/include/llvm/CodeGen/MachineRelocation.h +++ b/include/llvm/CodeGen/MachineRelocation.h @@ -138,14 +138,15 @@ public: /// static MachineRelocation getExtSym(uintptr_t offset, unsigned RelocationType, const char *ES, intptr_t cst = 0, - bool GOTrelative = 0) { + bool GOTrelative = 0, + bool NeedStub = true) { assert((RelocationType & ~63) == 0 && "Relocation type too large!"); MachineRelocation Result; Result.Offset = offset; Result.ConstantVal = cst; Result.TargetReloType = RelocationType; Result.AddrType = isExtSym; - Result.MayNeedFarStub = true; + Result.MayNeedFarStub = NeedStub; Result.GOTRelative = GOTrelative; Result.TargetResolve = false; Result.Target.ExtSym = ES; diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp index b65d23e9651..a026392d4cd 100644 --- a/lib/Target/X86/X86CodeEmitter.cpp +++ b/lib/Target/X86/X86CodeEmitter.cpp @@ -191,8 +191,15 @@ template void Emitter::emitExternalSymbolAddress(const char *ES, unsigned Reloc) { intptr_t RelocCST = (Reloc == X86::reloc_picrel_word) ? PICBaseOffset : 0; + + // X86 never needs stubs because instruction selection will always pick + // an instruction sequence that is large enough to hold any address + // to a symbol. + // (see X86ISelLowering.cpp, near 2039: X86TargetLowering::LowerCall) + bool NeedStub = false; MCE.addRelocation(MachineRelocation::getExtSym(MCE.getCurrentPCOffset(), - Reloc, ES, RelocCST)); + Reloc, ES, RelocCST, + 0, NeedStub)); if (Reloc == X86::reloc_absolute_dword) MCE.emitDWordLE(0); else