[llvm-commits] [llvm] r75099 - in /llvm/trunk/lib/Target/X86: X86ISelLowering.cpp X86TargetMachine.cpp
Chris Lattner
sabre at nondot.org
Wed Jul 8 21:24:46 PDT 2009
Author: lattner
Date: Wed Jul 8 23:24:46 2009
New Revision: 75099
URL: http://llvm.org/viewvc/llvm-project?rev=75099&view=rev
Log:
isPICStyleRIPRel() and friends are never true in -static mode.
Simplify code based on this.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=75099&r1=75098&r2=75099&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Jul 8 23:24:46 2009
@@ -1319,14 +1319,6 @@
}
-/// isUsingGOT - Return true if the target uses a GOT for PIC, and if we're in
-/// PIC mode.
-static bool isUsingGOT(const TargetMachine &TM) {
- const X86Subtarget &Subtarget = TM.getSubtarget<X86Subtarget>();
- return TM.getRelocationModel() == Reloc::PIC_ &&
- Subtarget.isPICStyleGOT();
-}
-
/// CreateCopyOfByValArgument - Make a copy of an aggregate at address specified
/// by "Src" to address "Dst" with size and alignment information specified by
/// the specific parameter attribute. The copy will be passed as a byval
@@ -1794,7 +1786,7 @@
}
- if (isUsingGOT(getTargetMachine())) {
+ if (Subtarget->isPICStyleGOT()) {
// ELF / PIC requires GOT in the EBX register before function calls via PLT
// GOT pointer.
if (!IsTailCall) {
@@ -1952,7 +1944,7 @@
RegsToPass[i].second.getValueType()));
// Add an implicit use GOT pointer in EBX.
- if (!IsTailCall && isUsingGOT(getTargetMachine()))
+ if (!IsTailCall && Subtarget->isPICStyleGOT())
Ops.push_back(DAG.getRegister(X86::EBX, getPointerTy()));
// Add an implicit use of AL for x86 vararg functions.
@@ -2069,12 +2061,12 @@
unsigned CallerCC = MF.getFunction()->getCallingConv();
unsigned CalleeCC= TheCall->getCallingConv();
if (CalleeCC == CallingConv::Fast && CallerCC == CalleeCC) {
- SDValue Callee = TheCall->getCallee();
// On x86/32Bit PIC/GOT tail calls are supported.
if (getTargetMachine().getRelocationModel() != Reloc::PIC_ ||
!Subtarget->isPICStyleGOT() || !Subtarget->is64Bit())
return true;
-
+
+ SDValue Callee = TheCall->getCallee();
// Can only do local tail calls (in same module, hidden or protected) on
// x86_64 PIC/GOT at the moment.
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
@@ -4438,11 +4430,11 @@
if (Subtarget->is64Bit() &&
getTargetMachine().getCodeModel() == CodeModel::Small) {
WrapperKind = X86ISD::WrapperRIP;
- } else if (getTargetMachine().getRelocationModel() == Reloc::PIC_) {
- if (Subtarget->isPICStyleStub())
- OpFlag = X86II::MO_PIC_BASE_OFFSET;
- else if (Subtarget->isPICStyleGOT())
- OpFlag = X86II::MO_GOTOFF;
+ } else if (Subtarget->isPICStyleGOT()) {
+ OpFlag = X86II::MO_GOTOFF;
+ } else if (Subtarget->isPICStyleStub() &&
+ getTargetMachine().getRelocationModel() == Reloc::PIC_) {
+ OpFlag = X86II::MO_PIC_BASE_OFFSET;
}
SDValue Result = DAG.getTargetConstantPool(CP->getConstVal(), getPointerTy(),
@@ -4471,11 +4463,11 @@
if (Subtarget->is64Bit()) {
WrapperKind = X86ISD::WrapperRIP;
- } else if (getTargetMachine().getRelocationModel() == Reloc::PIC_) {
- if (Subtarget->isPICStyleStub())
- OpFlag = X86II::MO_PIC_BASE_OFFSET;
- else if (Subtarget->isPICStyleGOT())
- OpFlag = X86II::MO_GOTOFF;
+ } else if (Subtarget->isPICStyleGOT()) {
+ OpFlag = X86II::MO_GOTOFF;
+ } else if (Subtarget->isPICStyleStub() &&
+ getTargetMachine().getRelocationModel() == Reloc::PIC_) {
+ OpFlag = X86II::MO_PIC_BASE_OFFSET;
}
SDValue Result = DAG.getTargetJumpTable(JT->getIndex(), getPointerTy(),
@@ -4504,11 +4496,11 @@
unsigned WrapperKind = X86ISD::Wrapper;
if (Subtarget->is64Bit()) {
WrapperKind = X86ISD::WrapperRIP;
- } else if (getTargetMachine().getRelocationModel() == Reloc::PIC_) {
- if (Subtarget->isPICStyleStub())
- OpFlag = X86II::MO_PIC_BASE_OFFSET;
- else if (Subtarget->isPICStyleGOT())
- OpFlag = X86II::MO_GOTOFF;
+ } else if (Subtarget->isPICStyleGOT()) {
+ OpFlag = X86II::MO_GOTOFF;
+ } else if (Subtarget->isPICStyleStub() &&
+ getTargetMachine().getRelocationModel() == Reloc::PIC_) {
+ OpFlag = X86II::MO_PIC_BASE_OFFSET;
}
SDValue Result = DAG.getTargetExternalSymbol(Sym, getPointerTy(), OpFlag);
@@ -4550,12 +4542,10 @@
if (GV->hasDLLImportLinkage())
OpFlags = X86II::MO_DLLIMPORT;
- else if (Subtarget->isPICStyleRIPRel() &&
- getTargetMachine().getRelocationModel() != Reloc::Static) {
+ else if (Subtarget->isPICStyleRIPRel()) {
if (ExtraLoadRequired)
OpFlags = X86II::MO_GOTPCREL;
- } else if (Subtarget->isPICStyleGOT() &&
- getTargetMachine().getRelocationModel() == Reloc::PIC_) {
+ } else if (Subtarget->isPICStyleGOT()) {
if (ExtraLoadRequired)
OpFlags = X86II::MO_GOT;
else
Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=75099&r1=75098&r2=75099&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Wed Jul 8 23:24:46 2009
@@ -158,11 +158,14 @@
// ELF and X86-64 don't have a distinct DynamicNoPIC model. DynamicNoPIC
// is defined as a model for code which may be used in static or dynamic
- // executables but not necessarily a shared library. On these systems we just
- // compile in -static mode.
- if (getRelocationModel() == Reloc::DynamicNoPIC &&
- !Subtarget.isTargetDarwin())
- setRelocationModel(Reloc::Static);
+ // executables but not necessarily a shared library. On X86-32 we just
+ // compile in -static mode, in x86-64 we use PIC.
+ if (getRelocationModel() == Reloc::DynamicNoPIC) {
+ if (is64Bit)
+ setRelocationModel(Reloc::PIC_);
+ else if (!Subtarget.isTargetDarwin())
+ setRelocationModel(Reloc::Static);
+ }
// If we are on Darwin, disallow static relocation model in X86-64 mode, since
// the Mach-O file format doesn't support it.
More information about the llvm-commits
mailing list