diff options
Diffstat (limited to 'llvm/lib/Target/X86/X86TargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86TargetMachine.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp index f6184a3c1f1..8f3d1870761 100644 --- a/llvm/lib/Target/X86/X86TargetMachine.cpp +++ b/llvm/lib/Target/X86/X86TargetMachine.cpp @@ -106,7 +106,8 @@ static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) { llvm_unreachable("unknown subtarget type"); } -static std::string computeDataLayout(const Triple &TT) { +static std::string computeDataLayout(const Triple &TT, + bool AddressSpaces = true) { // X86 is little endian std::string Ret = "e"; @@ -117,6 +118,10 @@ static std::string computeDataLayout(const Triple &TT) { !TT.isArch64Bit()) Ret += "-p:32:32"; + // Address spaces for 32 bit signed, 32 bit unsigned, and 64 bit pointers. + if (AddressSpaces) + Ret += "-p270:32:32-p271:32:32-p272:64:64"; + // Some ABIs align 64 bit integers and doubles to 64 bits, others to 32. if (TT.isArch64Bit() || TT.isOSWindows() || TT.isOSNaCl()) Ret += "-i64:64"; @@ -218,7 +223,8 @@ X86TargetMachine::X86TargetMachine(const Target &T, const Triple &TT, getEffectiveRelocModel(TT, JIT, RM), getEffectiveX86CodeModel(CM, JIT, TT.getArch() == Triple::x86_64), OL), - TLOF(createTLOF(getTargetTriple())) { + TLOF(createTLOF(getTargetTriple())), + DLNoAddrSpaces(computeDataLayout(TT, /*AddressSpaces=*/false)) { // On PS4, the "return address" of a 'noreturn' call must still be within // the calling function, and TrapUnreachable is an easy way to get that. if (TT.isPS4() || TT.isOSBinFormatMachO()) { @@ -312,6 +318,13 @@ X86TargetMachine::getSubtargetImpl(const Function &F) const { return I.get(); } +bool X86TargetMachine::isCompatibleDataLayout( + const DataLayout &Candidate) const { + // Maintain compatibility with datalayouts that don't have address space + // pointer sizes. + return DL == Candidate || DLNoAddrSpaces == Candidate; +} + //===----------------------------------------------------------------------===// // Command line options for x86 //===----------------------------------------------------------------------===// |