diff --git a/lib/Target/X86/X86ISelDAGToDAG.cpp b/lib/Target/X86/X86ISelDAGToDAG.cpp index 53de9d86447..5822f946e2c 100644 --- a/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -679,21 +679,25 @@ bool X86DAGToDAGISel::MatchAddress(SDOperand N, X86ISelAddressMode &AM, GlobalValue *GV = G->getGlobal(); AM.GV = GV; AM.Disp += G->getOffset(); - AM.isRIPRel = is64Bit; + AM.isRIPRel = TM.getRelocationModel() != Reloc::Static && + Subtarget->isPICStyleRIPRel(); return false; } else if (ConstantPoolSDNode *CP = dyn_cast(N0)) { AM.CP = CP->getConstVal(); AM.Align = CP->getAlignment(); AM.Disp += CP->getOffset(); - AM.isRIPRel = is64Bit; + AM.isRIPRel = TM.getRelocationModel() != Reloc::Static && + Subtarget->isPICStyleRIPRel(); return false; } else if (ExternalSymbolSDNode *S =dyn_cast(N0)) { AM.ES = S->getSymbol(); - AM.isRIPRel = is64Bit; + AM.isRIPRel = TM.getRelocationModel() != Reloc::Static && + Subtarget->isPICStyleRIPRel(); return false; } else if (JumpTableSDNode *J = dyn_cast(N0)) { AM.JT = J->getIndex(); - AM.isRIPRel = is64Bit; + AM.isRIPRel = TM.getRelocationModel() != Reloc::Static && + Subtarget->isPICStyleRIPRel(); return false; } }