[llvm] r270095 - Remember the relocation model. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu May 19 11:49:29 PDT 2016
Author: rafael
Date: Thu May 19 13:49:29 2016
New Revision: 270095
URL: http://llvm.org/viewvc/llvm-project?rev=270095&view=rev
Log:
Remember the relocation model. NFC.
This avoids passing a TargetMachine in a few places.
Modified:
llvm/trunk/lib/Target/X86/X86FastISel.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/lib/Target/X86/X86InstrInfo.td
llvm/trunk/lib/Target/X86/X86Subtarget.cpp
llvm/trunk/lib/Target/X86/X86Subtarget.h
Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=270095&r1=270094&r2=270095&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Thu May 19 13:49:29 2016
@@ -3183,7 +3183,7 @@ bool X86FastISel::fastLowerCall(CallLowe
unsigned CallOpc = Is64Bit ? X86::CALL64pcrel32 : X86::CALLpcrel32;
// See if we need any target-specific flags on the GV operand.
- unsigned char OpFlags = Subtarget->classifyGlobalFunctionReference(GV, TM);
+ unsigned char OpFlags = Subtarget->classifyGlobalFunctionReference(GV);
// Ignore NonLazyBind attribute in FastISel
if (OpFlags == X86II::MO_GOTPCREL)
OpFlags = 0;
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=270095&r1=270094&r2=270095&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu May 19 13:49:29 2016
@@ -3262,8 +3262,7 @@ X86TargetLowering::LowerCall(TargetLower
// non-JIT mode.
const GlobalValue *GV = G->getGlobal();
if (!GV->hasDLLImportStorageClass()) {
- unsigned char OpFlags =
- Subtarget.classifyGlobalFunctionReference(GV, DAG.getTarget());
+ unsigned char OpFlags = Subtarget.classifyGlobalFunctionReference(GV);
Callee = DAG.getTargetGlobalAddress(
GV, dl, getPointerTy(DAG.getDataLayout()), G->getOffset(), OpFlags);
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=270095&r1=270094&r2=270095&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Thu May 19 13:49:29 2016
@@ -886,7 +886,7 @@ def OptForSize : Predicate<"OptForSize
def OptForMinSize : Predicate<"OptForMinSize">;
def OptForSpeed : Predicate<"!OptForSize">;
def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
-def CallImmAddr : Predicate<"Subtarget->isLegalToCallImmediateAddr(TM)">;
+def CallImmAddr : Predicate<"Subtarget->isLegalToCallImmediateAddr()">;
def FavorMemIndirectCall : Predicate<"!Subtarget->callRegIndirect()">;
def NotSlowIncDec : Predicate<"!Subtarget->slowIncDec()">;
def HasFastMem32 : Predicate<"!Subtarget->isUnalignedMem32Slow()">;
Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=270095&r1=270094&r2=270095&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Thu May 19 13:49:29 2016
@@ -88,7 +88,7 @@ classifyGlobalReference(const GlobalValu
// overridden.
if (!GV->hasLocalLinkage() && GV->hasDefaultVisibility() &&
- !isGlobalDefinedInPIE(GV, TM))
+ !isGlobalDefinedInPIE(GV))
return X86II::MO_GOTPCREL;
}
@@ -100,7 +100,7 @@ classifyGlobalReference(const GlobalValu
// PIE as the definition of the global in an executable is not overridden.
if (GV->hasLocalLinkage() || GV->hasHiddenVisibility() ||
- isGlobalDefinedInPIE(GV, TM))
+ isGlobalDefinedInPIE(GV))
return X86II::MO_GOTOFF;
return X86II::MO_GOT;
}
@@ -151,15 +151,14 @@ classifyGlobalReference(const GlobalValu
return X86II::MO_NO_FLAG;
}
-unsigned char X86Subtarget::classifyGlobalFunctionReference(
- const GlobalValue *GV, const TargetMachine &TM) const {
+unsigned char
+X86Subtarget::classifyGlobalFunctionReference(const GlobalValue *GV) const {
// On ELF targets, in both X86-64 and X86-32 mode, direct calls to
// external symbols most go through the PLT in PIC mode. If the symbol
// has hidden or protected visibility, or if it is static or local, then
// we don't need to use the PLT - we can directly call it.
// In PIE mode, calls to global functions don't need to go through PLT
- if (isTargetELF() && TM.getRelocationModel() == Reloc::PIC_ &&
- !isGlobalDefinedInPIE(GV, TM) &&
+ if (isTargetELF() && RM == Reloc::PIC_ && !isGlobalDefinedInPIE(GV) &&
GV->hasDefaultVisibility() && !GV->hasLocalLinkage()) {
return X86II::MO_PLT;
} else if (isPICStyleStubAny() && !GV->isStrongDefinitionForLinker() &&
@@ -200,13 +199,13 @@ bool X86Subtarget::hasSinCos() const {
}
/// Return true if the subtarget allows calls to immediate address.
-bool X86Subtarget::isLegalToCallImmediateAddr(const TargetMachine &TM) const {
+bool X86Subtarget::isLegalToCallImmediateAddr() const {
// 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;
+ return isTargetELF() || RM == Reloc::Static;
}
void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
@@ -347,7 +346,7 @@ X86Subtarget::X86Subtarget(const Triple
const std::string &FS, const X86TargetMachine &TM,
unsigned StackAlignOverride)
: X86GenSubtargetInfo(TT, CPU, FS), X86ProcFamily(Others),
- PICStyle(PICStyles::None), TargetTriple(TT),
+ PICStyle(PICStyles::None), RM(TM.getRelocationModel()), TargetTriple(TT),
StackAlignOverride(StackAlignOverride),
In64BitMode(TargetTriple.getArch() == Triple::x86_64),
In32BitMode(TargetTriple.getArch() == Triple::x86 &&
Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=270095&r1=270094&r2=270095&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86Subtarget.h (original)
+++ llvm/trunk/lib/Target/X86/X86Subtarget.h Thu May 19 13:49:29 2016
@@ -64,6 +64,8 @@ protected:
/// Which PIC style to use
PICStyles::Style PICStyle;
+ Reloc::Model RM;
+
/// SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, or none supported.
X86SSEEnum X86SSELevel;
@@ -556,8 +558,7 @@ public:
/// Determine if this global is defined in a Position Independent
/// Executable (PIE) where its definition cannot be interposed.
- bool isGlobalDefinedInPIE(const GlobalValue *GV,
- const TargetMachine &TM) const {
+ bool isGlobalDefinedInPIE(const GlobalValue *GV) const {
return GV->getParent()->getPIELevel() != PIELevel::Default &&
!GV->isDeclarationForLinker();
}
@@ -568,15 +569,14 @@ public:
const TargetMachine &TM)const;
/// Classify a global function reference for the current subtarget.
- unsigned char classifyGlobalFunctionReference(const GlobalValue *GV,
- const TargetMachine &TM) const;
+ unsigned char classifyGlobalFunctionReference(const GlobalValue *GV) const;
/// Classify a blockaddress reference for the current subtarget according to
/// how we should reference it in a non-pcrel context.
unsigned char classifyBlockAddressReference() const;
/// Return true if the subtarget allows calls to immediate address.
- bool isLegalToCallImmediateAddr(const TargetMachine &TM) const;
+ bool isLegalToCallImmediateAddr() const;
/// This function returns the name of a function which has an interface
/// like the non-standard bzero function, if such a function exists on
More information about the llvm-commits
mailing list