summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/X86ISelLowering.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/X86/X86ISelLowering.cpp')
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp38
1 files changed, 14 insertions, 24 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 071111384d2..a0a3cc5eb76 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -2124,23 +2124,21 @@ X86TargetLowering::findRepresentativeClass(const TargetRegisterInfo *TRI,
return std::make_pair(RRC, Cost);
}
+unsigned X86TargetLowering::getAddressSpace() const {
+ if (Subtarget.is64Bit())
+ return (getTargetMachine().getCodeModel() == CodeModel::Kernel) ? 256 : 257;
+ return 256;
+}
+
bool X86TargetLowering::getStackCookieLocation(unsigned &AddressSpace,
unsigned &Offset) const {
if (!Subtarget.isTargetLinux())
return false;
- if (Subtarget.is64Bit()) {
- // %fs:0x28, unless we're using a Kernel code model, in which case it's %gs:
- Offset = 0x28;
- if (getTargetMachine().getCodeModel() == CodeModel::Kernel)
- AddressSpace = 256;
- else
- AddressSpace = 257;
- } else {
- // %gs:0x14 on i386
- Offset = 0x14;
- AddressSpace = 256;
- }
+ // %fs:0x28, unless we're using a Kernel code model, in which case it's %gs:
+ // %gs:0x14 on i386
+ Offset = (Subtarget.is64Bit()) ? 0x28 : 0x14;
+ AddressSpace = getAddressSpace();
return true;
}
@@ -2152,19 +2150,11 @@ Value *X86TargetLowering::getSafeStackPointerLocation(IRBuilder<> &IRB) const {
// definition of TLS_SLOT_SAFESTACK in
// https://android.googlesource.com/platform/bionic/+/master/libc/private/bionic_tls.h
unsigned AddressSpace, Offset;
- if (Subtarget.is64Bit()) {
- // %fs:0x48, unless we're using a Kernel code model, in which case it's %gs:
- Offset = 0x48;
- if (getTargetMachine().getCodeModel() == CodeModel::Kernel)
- AddressSpace = 256;
- else
- AddressSpace = 257;
- } else {
- // %gs:0x24 on i386
- Offset = 0x24;
- AddressSpace = 256;
- }
+ // %fs:0x48, unless we're using a Kernel code model, in which case it's %gs:
+ // %gs:0x24 on i386
+ Offset = (Subtarget.is64Bit()) ? 0x48 : 0x24;
+ AddressSpace = getAddressSpace();
return ConstantExpr::getIntToPtr(
ConstantInt::get(Type::getInt32Ty(IRB.getContext()), Offset),
Type::getInt8PtrTy(IRB.getContext())->getPointerTo(AddressSpace));
OpenPOWER on IntegriCloud