diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-05-19 18:49:29 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-05-19 18:49:29 +0000 |
| commit | 46107b9e62f35c3a0f6b6e94467967f018010953 (patch) | |
| tree | 4b16904477f1fca1ca05210bc9ff3eae20bead7f /llvm/lib | |
| parent | 31c3bad4999dbe8757ec55dc658a427f9985947a (diff) | |
| download | bcm5719-llvm-46107b9e62f35c3a0f6b6e94467967f018010953.tar.gz bcm5719-llvm-46107b9e62f35c3a0f6b6e94467967f018010953.zip | |
Remember the relocation model. NFC.
This avoids passing a TargetMachine in a few places.
llvm-svn: 270095
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/X86FastISel.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86InstrInfo.td | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86Subtarget.cpp | 17 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86Subtarget.h | 10 |
5 files changed, 16 insertions, 18 deletions
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp index 00942578b58..cc7a1024608 100644 --- a/llvm/lib/Target/X86/X86FastISel.cpp +++ b/llvm/lib/Target/X86/X86FastISel.cpp @@ -3183,7 +3183,7 @@ bool X86FastISel::fastLowerCall(CallLoweringInfo &CLI) { 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; diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 0d27503d481..0fd7b173015 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -3262,8 +3262,7 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, // 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); diff --git a/llvm/lib/Target/X86/X86InstrInfo.td b/llvm/lib/Target/X86/X86InstrInfo.td index a9c53ab3943..10a8d0efa7f 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.td +++ b/llvm/lib/Target/X86/X86InstrInfo.td @@ -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()">; diff --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp index 3368ad0451b..f512cce8343 100644 --- a/llvm/lib/Target/X86/X86Subtarget.cpp +++ b/llvm/lib/Target/X86/X86Subtarget.cpp @@ -88,7 +88,7 @@ classifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const { // overridden. if (!GV->hasLocalLinkage() && GV->hasDefaultVisibility() && - !isGlobalDefinedInPIE(GV, TM)) + !isGlobalDefinedInPIE(GV)) return X86II::MO_GOTPCREL; } @@ -100,7 +100,7 @@ classifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const { // 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 GlobalValue *GV, const TargetMachine &TM) const { 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 &TT, const std::string &CPU, 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 && diff --git a/llvm/lib/Target/X86/X86Subtarget.h b/llvm/lib/Target/X86/X86Subtarget.h index dd409d1457b..a1fc79ec173 100644 --- a/llvm/lib/Target/X86/X86Subtarget.h +++ b/llvm/lib/Target/X86/X86Subtarget.h @@ -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 |

