Index: llvm/lib/Target/X86/X86FastISel.cpp =================================================================== --- llvm/lib/Target/X86/X86FastISel.cpp +++ llvm/lib/Target/X86/X86FastISel.cpp @@ -745,6 +745,12 @@ AM.Base.Reg = getInstrInfo()->getGlobalBaseReg(FuncInfo.MF); } + bool NeedLoad = GVFlags == X86II::MO_GOTPCREL; + if(NeedLoad) { + assert(AM.Base.Reg == 0 && AM.IndexReg == 0); + AM.Base.Reg = X86::RIP; + } + // Unless the ABI requires an extra load, return a direct reference to // the global. if (!isGlobalStubReference(GVFlags)) {