[llvm] r270147 - Record a TargetMachine instead of a Reloc::Model.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu May 19 15:07:58 PDT 2016
Author: rafael
Date: Thu May 19 17:07:57 2016
New Revision: 270147
URL: http://llvm.org/viewvc/llvm-project?rev=270147&view=rev
Log:
Record a TargetMachine instead of a Reloc::Model.
Addresses r270095's code review.
Modified:
llvm/trunk/lib/Target/X86/X86FastISel.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
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=270147&r1=270146&r2=270147&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Thu May 19 17:07:57 2016
@@ -607,7 +607,7 @@ bool X86FastISel::handleConstantAddresse
AM.GV = GV;
// Allow the subtarget to classify the global.
- unsigned char GVFlags = Subtarget->classifyGlobalReference(GV, TM);
+ unsigned char GVFlags = Subtarget->classifyGlobalReference(GV);
// If this reference is relative to the pic base, set it now.
if (isGlobalRelativeToPICBase(GVFlags)) {
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=270147&r1=270146&r2=270147&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu May 19 17:07:57 2016
@@ -12679,8 +12679,7 @@ X86TargetLowering::LowerGlobalAddress(co
int64_t Offset, SelectionDAG &DAG) const {
// Create the TargetGlobalAddress node, folding in the constant
// offset if it is legal.
- unsigned char OpFlags =
- Subtarget.classifyGlobalReference(GV, DAG.getTarget());
+ unsigned char OpFlags = Subtarget.classifyGlobalReference(GV);
CodeModel::Model M = DAG.getTarget().getCodeModel();
auto PtrVT = getPointerTy(DAG.getDataLayout());
SDValue Result;
@@ -21983,8 +21982,7 @@ bool X86TargetLowering::isLegalAddressin
return false;
if (AM.BaseGV) {
- unsigned GVFlags =
- Subtarget.classifyGlobalReference(AM.BaseGV, getTargetMachine());
+ unsigned GVFlags = Subtarget.classifyGlobalReference(AM.BaseGV);
// If a reference to this global requires an extra load, we can't fold it.
if (isGlobalStubReference(GVFlags))
@@ -30186,8 +30184,7 @@ void X86TargetLowering::LowerAsmOperandF
const GlobalValue *GV = GA->getGlobal();
// If we require an extra load to get this address, as in PIC mode, we
// can't accept it.
- if (isGlobalStubReference(
- Subtarget.classifyGlobalReference(GV, DAG.getTarget())))
+ if (isGlobalStubReference(Subtarget.classifyGlobalReference(GV)))
return;
Result = DAG.getTargetGlobalAddress(GV, SDLoc(Op),
Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=270147&r1=270146&r2=270147&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Thu May 19 17:07:57 2016
@@ -59,8 +59,8 @@ unsigned char X86Subtarget::classifyBloc
/// Classify a global variable reference for the current subtarget according to
/// how we should reference it in a non-pcrel context.
-unsigned char X86Subtarget::
-classifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const {
+unsigned char
+X86Subtarget::classifyGlobalReference(const GlobalValue *GV) const {
// DLLImport only exists on windows, it is implemented as a load from a
// DLLIMPORT stub.
if (GV->hasDLLImportStorageClass())
@@ -158,8 +158,9 @@ X86Subtarget::classifyGlobalFunctionRefe
// 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() && RM == Reloc::PIC_ && !isGlobalDefinedInPIE(GV) &&
- GV->hasDefaultVisibility() && !GV->hasLocalLinkage()) {
+ if (isTargetELF() && TM.getRelocationModel() == Reloc::PIC_ &&
+ !isGlobalDefinedInPIE(GV) && GV->hasDefaultVisibility() &&
+ !GV->hasLocalLinkage()) {
return X86II::MO_PLT;
} else if (isPICStyleStubAny() && !GV->isStrongDefinitionForLinker() &&
(!getTargetTriple().isMacOSX() ||
@@ -205,7 +206,7 @@ bool X86Subtarget::isLegalToCallImmediat
// the following check for Win32 should be removed.
if (In64BitMode || isTargetWin32())
return false;
- return isTargetELF() || RM == Reloc::Static;
+ return isTargetELF() || TM.getRelocationModel() == Reloc::Static;
}
void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
@@ -346,7 +347,7 @@ X86Subtarget::X86Subtarget(const Triple
const std::string &FS, const X86TargetMachine &TM,
unsigned StackAlignOverride)
: X86GenSubtargetInfo(TT, CPU, FS), X86ProcFamily(Others),
- PICStyle(PICStyles::None), RM(TM.getRelocationModel()), TargetTriple(TT),
+ PICStyle(PICStyles::None), TM(TM), 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=270147&r1=270146&r2=270147&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86Subtarget.h (original)
+++ llvm/trunk/lib/Target/X86/X86Subtarget.h Thu May 19 17:07:57 2016
@@ -64,7 +64,7 @@ protected:
/// Which PIC style to use
PICStyles::Style PICStyle;
- Reloc::Model RM;
+ const TargetMachine &TM;
/// SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, or none supported.
X86SSEEnum X86SSELevel;
@@ -565,8 +565,7 @@ public:
/// Classify a global variable reference for the current subtarget according
/// to how we should reference it in a non-pcrel context.
- unsigned char classifyGlobalReference(const GlobalValue *GV,
- const TargetMachine &TM)const;
+ unsigned char classifyGlobalReference(const GlobalValue *GV) const;
/// Classify a global function reference for the current subtarget.
unsigned char classifyGlobalFunctionReference(const GlobalValue *GV) const;
More information about the llvm-commits
mailing list