Move the GlobalBaseReg field out of X86ISelDAGToDAG.cpp
and X86FastISel.cpp into X86MachineFunction.h, so that it
can be shared, instead of having each selector keep track
of its own.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56825 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/X86ISelDAGToDAG.cpp b/lib/Target/X86/X86ISelDAGToDAG.cpp
index 6cc044c..692f4de 100644
--- a/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -123,10 +123,6 @@
/// make the right decision when generating code for different targets.
const X86Subtarget *Subtarget;
- /// GlobalBaseReg - keeps track of the virtual register mapped onto global
- /// base register.
- unsigned GlobalBaseReg;
-
/// CurBB - Current BB being isel'd.
///
MachineBasicBlock *CurBB;
@@ -143,12 +139,6 @@
Subtarget(&TM.getSubtarget<X86Subtarget>()),
OptForSize(OptimizeForSize) {}
- virtual bool runOnFunction(Function &Fn) {
- // Make sure we re-emit a set of the global base reg if necessary
- GlobalBaseReg = 0;
- return SelectionDAGISel::runOnFunction(Fn);
- }
-
virtual const char *getPassName() const {
return "X86 DAG->DAG Instruction Selection";
}
@@ -1174,9 +1164,8 @@
/// initialize the global base register, if necessary.
///
SDNode *X86DAGToDAGISel::getGlobalBaseReg() {
- assert(!Subtarget->is64Bit() && "X86-64 PIC uses RIP relative addressing");
- if (!GlobalBaseReg)
- GlobalBaseReg = TM.getInstrInfo()->initializeGlobalBaseReg(BB->getParent());
+ MachineFunction *MF = CurBB->getParent();
+ unsigned GlobalBaseReg = TM.getInstrInfo()->getGlobalBaseReg(MF);
return CurDAG->getRegister(GlobalBaseReg, TLI.getPointerTy()).getNode();
}