mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[MinGW] Move code for indicating "potentially not DSO local" into shouldAssumeDSOLocal. NFC.
On Windows, if shouldAssumeDSOLocal returns false, it's either a dllimport reference, or a reference that we should treat as non-local and create a stub for. Clean up AArch64Subtarget::ClassifyGlobalReference a little while touching the flag handling relating to dllimport. Differential Revision: https://reviews.llvm.org/D51590 llvm-svn: 341402
This commit is contained in:
parent
3d5c7d84ef
commit
3bc21d8a2b
@ -196,25 +196,22 @@ AArch64Subtarget::ClassifyGlobalReference(const GlobalValue *GV,
|
||||
if (TM.getCodeModel() == CodeModel::Large && isTargetMachO())
|
||||
return AArch64II::MO_GOT;
|
||||
|
||||
unsigned Flags = AArch64II::MO_NO_FLAG;
|
||||
if (GV->hasDLLImportStorageClass())
|
||||
Flags = AArch64II::MO_DLLIMPORT;
|
||||
else if (getTargetTriple().isWindowsGNUEnvironment() &&
|
||||
!GV->isDSOLocal() && GV->isDeclarationForLinker() &&
|
||||
isa<GlobalVariable>(GV))
|
||||
Flags = AArch64II::MO_COFFSTUB | AArch64II::MO_GOT;
|
||||
|
||||
if (!TM.shouldAssumeDSOLocal(*GV->getParent(), GV))
|
||||
return AArch64II::MO_GOT | Flags;
|
||||
if (!TM.shouldAssumeDSOLocal(*GV->getParent(), GV)) {
|
||||
if (GV->hasDLLImportStorageClass())
|
||||
return AArch64II::MO_GOT | AArch64II::MO_DLLIMPORT;
|
||||
if (getTargetTriple().isOSWindows())
|
||||
return AArch64II::MO_GOT | AArch64II::MO_COFFSTUB;
|
||||
return AArch64II::MO_GOT;
|
||||
}
|
||||
|
||||
// The small code model's direct accesses use ADRP, which cannot
|
||||
// necessarily produce the value 0 (if the code is above 4GB).
|
||||
// Same for the tiny code model, where we have a pc relative LDR.
|
||||
if ((useSmallAddressing() || TM.getCodeModel() == CodeModel::Tiny) &&
|
||||
GV->hasExternalWeakLinkage())
|
||||
return AArch64II::MO_GOT | Flags;
|
||||
return AArch64II::MO_GOT;
|
||||
|
||||
return Flags;
|
||||
return AArch64II::MO_NO_FLAG;
|
||||
}
|
||||
|
||||
unsigned char AArch64Subtarget::classifyGlobalFunctionReference(
|
||||
|
@ -3317,13 +3317,12 @@ SDValue ARMTargetLowering::LowerGlobalAddressWindows(SDValue Op,
|
||||
assert(!Subtarget->isROPI() && !Subtarget->isRWPI() &&
|
||||
"ROPI/RWPI not currently supported for Windows");
|
||||
|
||||
const TargetMachine &TM = getTargetMachine();
|
||||
const GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
|
||||
ARMII::TOF TargetFlags = ARMII::MO_NO_FLAG;
|
||||
if (GV->hasDLLImportStorageClass())
|
||||
TargetFlags = ARMII::MO_DLLIMPORT;
|
||||
else if (Subtarget->getTargetTriple().isWindowsGNUEnvironment() &&
|
||||
!GV->isDSOLocal() && GV->isDeclarationForLinker() &&
|
||||
isa<GlobalVariable>(GV))
|
||||
else if (!TM.shouldAssumeDSOLocal(*GV->getParent(), GV))
|
||||
TargetFlags = ARMII::MO_COFFSTUB;
|
||||
EVT PtrVT = getPointerTy(DAG.getDataLayout());
|
||||
SDValue Result;
|
||||
|
@ -141,6 +141,15 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
|
||||
if (GV && GV->hasDLLImportStorageClass())
|
||||
return false;
|
||||
|
||||
// On MinGW, variables that haven't been declared with DLLImport may still
|
||||
// end up automatically imported by the linker. To make this feasible,
|
||||
// don't assume the variables to be DSO local unless we actually know
|
||||
// that for sure. This only has to be done for variables; for functions
|
||||
// the linker can insert thunks for calling functions from another DLL.
|
||||
if (TT.isWindowsGNUEnvironment() && GV && GV->isDeclarationForLinker() &&
|
||||
isa<GlobalVariable>(GV))
|
||||
return false;
|
||||
|
||||
// Every other GV is local on COFF.
|
||||
// Make an exception for windows OS in the triple: Some firmware builds use
|
||||
// *-win32-macho triples. This (accidentally?) produced windows relocations
|
||||
|
@ -138,19 +138,14 @@ unsigned char X86Subtarget::classifyGlobalReference(const GlobalValue *GV,
|
||||
}
|
||||
}
|
||||
|
||||
// For MinGW, if a data reference isn't marked as DSO local or DLLImport,
|
||||
// and it's a pure declaration without a definition, it might potentially
|
||||
// be automatically imported from another DLL, thus route accesses via a stub.
|
||||
if (isTargetWindowsGNU() && GV && !GV->isDSOLocal() &&
|
||||
!GV->hasDLLImportStorageClass() && GV->isDeclarationForLinker() &&
|
||||
isa<GlobalVariable>(GV))
|
||||
return X86II::MO_COFFSTUB;
|
||||
|
||||
if (TM.shouldAssumeDSOLocal(M, GV))
|
||||
return classifyLocalReference(GV);
|
||||
|
||||
if (isTargetCOFF())
|
||||
return X86II::MO_DLLIMPORT;
|
||||
if (isTargetCOFF()) {
|
||||
if (GV->hasDLLImportStorageClass())
|
||||
return X86II::MO_DLLIMPORT;
|
||||
return X86II::MO_COFFSTUB;
|
||||
}
|
||||
|
||||
if (is64Bit()) {
|
||||
// ELF supports a large, truly PIC code model with non-PC relative GOT
|
||||
|
Loading…
x
Reference in New Issue
Block a user