From af8f40da2bf5af9946d3c7fc436b1b942f02222a Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Sat, 18 Jun 2016 00:03:20 +0000 Subject: [PATCH] [X86Subtarget] Use isPositionIndependent(). NFC. Differential Revision: http://reviews.llvm.org/D21480 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273071 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86Subtarget.cpp | 6 +++--- lib/Target/X86/X86Subtarget.h | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Target/X86/X86Subtarget.cpp b/lib/Target/X86/X86Subtarget.cpp index 99adf9c459a..a1550701de5 100644 --- a/lib/Target/X86/X86Subtarget.cpp +++ b/lib/Target/X86/X86Subtarget.cpp @@ -66,7 +66,7 @@ X86Subtarget::classifyLocalReference(const GlobalValue *GV) const { // If this is for a position dependent executable, the static linker can // figure it out. - if (TM.getRelocationModel() != Reloc::PIC_) + if (!isPositionIndependent()) return X86II::MO_NO_FLAG; // The COFF dynamic linker just patches the executable sections. @@ -104,7 +104,7 @@ unsigned char X86Subtarget::classifyGlobalReference(const GlobalValue *GV, return X86II::MO_GOTPCREL; if (isTargetDarwin()) { - if (RM != Reloc::PIC_) + if (!isPositionIndependent()) return X86II::MO_DARWIN_NONLAZY; return X86II::MO_DARWIN_NONLAZY_PIC_BASE; } @@ -334,7 +334,7 @@ X86Subtarget::X86Subtarget(const Triple &TT, StringRef CPU, StringRef FS, } else if (isTargetCOFF()) { setPICStyle(PICStyles::None); } else if (isTargetDarwin()) { - if (TM.getRelocationModel() == Reloc::PIC_) + if (isPositionIndependent()) setPICStyle(PICStyles::StubPIC); else { assert(TM.getRelocationModel() == Reloc::DynamicNoPIC); diff --git a/lib/Target/X86/X86Subtarget.h b/lib/Target/X86/X86Subtarget.h index 51b519c19e1..b0f3d2650e3 100644 --- a/lib/Target/X86/X86Subtarget.h +++ b/lib/Target/X86/X86Subtarget.h @@ -533,6 +533,10 @@ public: PICStyle == PICStyles::StubPIC; } + bool isPositionIndependent() const { + return TM.getRelocationModel() == Reloc::PIC_; + } + bool isCallingConvWin64(CallingConv::ID CC) const { switch (CC) { // On Win64, all these conventions just use the default convention. -- 2.11.0