X86: Disable IsLegalToCallImmediateAddr for Win32

WinCOFF cannot form PC relative relocations to support absolute
MCValues.  We should reenable this once WinCOFF supports emission of
IMAGE_REL_I386_REL32 relocations.

This fixes PR19272.

llvm-svn: 205058
This commit is contained in:
David Majnemer 2014-03-28 21:40:47 +00:00
parent bc69bce7de
commit 02f2188bb9
2 changed files with 6 additions and 1 deletions

View File

@ -165,7 +165,10 @@ bool X86Subtarget::hasSinCos() const {
/// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls
/// to immediate address.
bool X86Subtarget::IsLegalToCallImmediateAddr(const TargetMachine &TM) const {
if (In64BitMode)
// FIXME: I386 PE/COFF supports PC relative calls using IMAGE_REL_I386_REL32
// but WinCOFFObjectWriter::RecordRelocation cannot emit them. Once it does,
// the following check for Win32 should be removed.
if (In64BitMode || isTargetWin32())
return false;
return isTargetELF() || TM.getRelocationModel() == Reloc::Static;
}

View File

@ -1,6 +1,7 @@
; RUN: llc < %s -mtriple=i386-apple-darwin -relocation-model=static | FileCheck -check-prefix X86STA %s
; RUN: llc < %s -mtriple=i386-apple-darwin -relocation-model=pic | FileCheck -check-prefix X86PIC %s
; RUN: llc < %s -mtriple=i386-pc-linux -relocation-model=dynamic-no-pic | FileCheck -check-prefix X86DYN %s
; RUN: llc < %s -mtriple=i386-pc-win32 -relocation-model=static | FileCheck -check-prefix X86WINSTA %s
; Call to immediate is not safe on x86-64 unless we *know* that the
; call will be within 32-bits pcrel from the dest immediate.
@ -20,4 +21,5 @@ entry:
; X86STA: {{call.*12345678}}
; X86PIC-NOT: {{call.*12345678}}
; X86DYN: {{call.*12345678}}
; X86WINSTA: {{call.*[*]%eax}}
; X64: {{call.*[*]%rax}}