From c4cbe67fa87b2bab8deaeb9921c7315db8500e50 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 28 Jun 2016 20:13:36 +0000 Subject: [PATCH] Use isPositionIndependent in a few more places. I think this converts all the simple cases that really just care about the generated code being position independent or not. The remaining uses are a bit more complicated and are checking things like "is this a library or executable" or "can this symbol be preempted". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274055 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 +- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 2 +- lib/CodeGen/SelectionDAG/TargetLowering.cpp | 2 +- lib/Target/Hexagon/HexagonFrameLowering.cpp | 4 ++-- lib/Target/PowerPC/PPCRegisterInfo.cpp | 5 ++--- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 37099c468cb..a355e09824e 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -125,7 +125,7 @@ AsmPrinter::~AsmPrinter() { } bool AsmPrinter::isPositionIndependent() const { - return TM.getRelocationModel() == Reloc::PIC_; + return TM.isPositionIndependent(); } /// getFunctionNumber - Return a unique ID for the current function. diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index ac68bcdb426..cb3224bfb43 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -3510,7 +3510,7 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) { MachinePointerInfo::getJumpTable(DAG.getMachineFunction()), MemVT, false, false, false, 0); Addr = LD; - if (TM.getRelocationModel() == Reloc::PIC_) { + if (TM.isPositionIndependent()) { // For PIC, the sequence is: // BRIND(load(Jumptable + index) + RelocBase) // RelocBase can be JumpTable, GOT or some sort of global base. diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 10dcb0a266d..184f0805692 100644 --- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -45,7 +45,7 @@ const char *TargetLowering::getTargetNodeName(unsigned Opcode) const { } bool TargetLowering::isPositionIndependent() const { - return getTargetMachine().getRelocationModel() == Reloc::PIC_; + return getTargetMachine().isPositionIndependent(); } /// Check whether a given call node is in tail position within its function. If diff --git a/lib/Target/Hexagon/HexagonFrameLowering.cpp b/lib/Target/Hexagon/HexagonFrameLowering.cpp index 92ba475fdb2..ee4c7f55d6c 100644 --- a/lib/Target/Hexagon/HexagonFrameLowering.cpp +++ b/lib/Target/Hexagon/HexagonFrameLowering.cpp @@ -1058,7 +1058,7 @@ bool HexagonFrameLowering::insertCSRSpillsInBlock(MachineBasicBlock &MBB, const char *SpillFun = getSpillFunctionFor(MaxReg, SK_ToMem, StkOvrFlowEnabled); auto &HTM = static_cast(MF.getTarget()); - bool IsPIC = HTM.getRelocationModel() == Reloc::PIC_; + bool IsPIC = HTM.isPositionIndependent(); // Call spill function. DebugLoc DL = MI != MBB.end() ? MI->getDebugLoc() : DebugLoc(); @@ -1112,7 +1112,7 @@ bool HexagonFrameLowering::insertCSRRestoresInBlock(MachineBasicBlock &MBB, SpillKind Kind = HasTC ? SK_FromMemTailcall : SK_FromMem; const char *RestoreFn = getSpillFunctionFor(MaxR, Kind); auto &HTM = static_cast(MF.getTarget()); - bool IsPIC = HTM.getRelocationModel() == Reloc::PIC_; + bool IsPIC = HTM.isPositionIndependent(); // Call spill function. DebugLoc DL = MI != MBB.end() ? MI->getDebugLoc() diff --git a/lib/Target/PowerPC/PPCRegisterInfo.cpp b/lib/Target/PowerPC/PPCRegisterInfo.cpp index 5ea0eafff09..f0161a03d2d 100644 --- a/lib/Target/PowerPC/PPCRegisterInfo.cpp +++ b/lib/Target/PowerPC/PPCRegisterInfo.cpp @@ -260,7 +260,7 @@ BitVector PPCRegisterInfo::getReservedRegs(const MachineFunction &MF) const { if (TFI->needsFP(MF)) Reserved.set(PPC::R31); - bool IsPositionIndependent = TM.getRelocationModel() == Reloc::PIC_; + bool IsPositionIndependent = TM.isPositionIndependent(); if (hasBasePointer(MF)) { if (Subtarget.isSVR4ABI() && !TM.isPPC64() && IsPositionIndependent) Reserved.set(PPC::R29); @@ -934,8 +934,7 @@ unsigned PPCRegisterInfo::getBaseRegister(const MachineFunction &MF) const { if (TM.isPPC64()) return PPC::X30; - if (Subtarget.isSVR4ABI() && - TM.getRelocationModel() == Reloc::PIC_) + if (Subtarget.isSVR4ABI() && TM.isPositionIndependent()) return PPC::R29; return PPC::R30; -- 2.11.0