llvm.org GIT mirror llvm / d11ea2f
[X86] Extend some Linux special cases to cover kFreeBSD. Both Linux and kFreeBSD use glibc, so follow similiar code paths. Add isTargetGlibc to check for this, and use it instead of isTargetLinux in a few places. Fixes PR22248 for kFreeBSD. Differential Revision: http://reviews.llvm.org/D19104 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268624 91177308-0d34-0410-b5e6-96231b3b80d8 Marcin Koscielnicki 3 years ago
7 changed file(s) with 26 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
522522 return getOS() == Triple::Linux;
523523 }
524524
525 /// Tests whether the OS is kFreeBSD.
526 bool isOSKFreeBSD() const {
527 return getOS() == Triple::KFreeBSD;
528 }
529
530 /// Tests whether the OS uses glibc.
531 bool isOSGlibc() const {
532 return getOS() == Triple::Linux || getOS() == Triple::KFreeBSD;
533 }
534
525535 /// Tests whether the OS uses the ELF binary format.
526536 bool isOSBinFormatELF() const {
527537 return getObjectFormat() == Triple::ELF;
718718 // For more information see http://people.redhat.com/drepper/tls.pdf
719719 if (ConstantSDNode *C = dyn_cast(Address))
720720 if (C->getSExtValue() == 0 && AM.Segment.getNode() == nullptr &&
721 Subtarget->isTargetLinux())
721 Subtarget->isTargetGlibc())
722722 switch (N->getPointerInfo().getAddrSpace()) {
723723 case 256:
724724 AM.Segment = CurDAG->getRegister(X86::GS, MVT::i16);
19181918 }
19191919
19201920 Value *X86TargetLowering::getIRStackGuard(IRBuilder<> &IRB) const {
1921 if (!Subtarget.isTargetLinux())
1921 // glibc has a special slot for the stack guard in tcbhead_t, use it instead
1922 // of the usual global variable (see sysdeps/{i386,x86_64}/nptl/tls.h)
1923 if (!Subtarget.isTargetGlibc())
19221924 return TargetLowering::getIRStackGuard(IRB);
19231925
19241926 // %fs:0x28, unless we're using a Kernel code model, in which case it's %gs:
19311933 }
19321934
19331935 void X86TargetLowering::insertSSPDeclarations(Module &M) const {
1934 if (!Subtarget.isTargetLinux())
1936 if (!Subtarget.isTargetGlibc())
19351937 TargetLowering::insertSSPDeclarations(M);
19361938 }
19371939
261261 assert((!In64BitMode || HasX86_64) &&
262262 "64-bit code requested on a subtarget that doesn't support it!");
263263
264 // Stack alignment is 16 bytes on Darwin, Linux and Solaris (both
264 // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD and Solaris (both
265265 // 32 and 64 bit) and for all 64-bit targets.
266266 if (StackAlignOverride)
267267 stackAlignment = StackAlignOverride;
268268 else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() ||
269 In64BitMode)
269 isTargetKFreeBSD() || In64BitMode)
270270 stackAlignment = 16;
271271 }
272272
466466 bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
467467
468468 bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
469 bool isTargetKFreeBSD() const { return TargetTriple.isOSKFreeBSD(); }
470 bool isTargetGlibc() const { return TargetTriple.isOSGlibc(); }
469471 bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
470472 bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
471473 bool isTargetNaCl32() const { return isTargetNaCl() && !is64Bit(); }
0 ; RUN: llc < %s -mcpu=generic -mtriple=i386-linux | FileCheck %s -check-prefix=LINUX-I386
1 ; RUN: llc < %s -mcpu=generic -mtriple=i386-kfreebsd | FileCheck %s -check-prefix=KFREEBSD-I386
12 ; RUN: llc < %s -mcpu=generic -mtriple=i386-netbsd | FileCheck %s -check-prefix=NETBSD-I386
23 ; RUN: llc < %s -mcpu=generic -mtriple=i686-apple-darwin8 | FileCheck %s -check-prefix=DARWIN-I386
34 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux | FileCheck %s -check-prefix=LINUX-X86_64
5 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-kfreebsd | FileCheck %s -check-prefix=KFREEBSD-X86_64
46 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-netbsd | FileCheck %s -check-prefix=NETBSD-X86_64
57 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-apple-darwin8 | FileCheck %s -check-prefix=DARWIN-X86_64
68
1012 ret i32 0
1113
1214 ; LINUX-I386: subl $12, %esp
15 ; KFREEBSD-I386: subl $12, %esp
1316 ; DARWIN-I386: subl $12, %esp
1417 ; NETBSD-I386-NOT: subl {{.*}}, %esp
1518
1922 ; DARWIN-X86_64-NOT: subq {{.*}}, %rsp
2023 ; NETBSD-X86_64: pushq %{{.*}}
2124 ; NETBSD-X86_64-NOT: subq {{.*}}, %rsp
25 ; KFREEBSD-X86_64: pushq %{{.*}}
26 ; KFREEBSD-X86_64-NOT: subq {{.*}}, %rsp
2227 }
2328
2429 declare void @test2()
22 ; RUN: llc -mtriple=x86_64-linux < %s -o - | FileCheck --check-prefix=LINUX-X64 %s
33 ; RUN: llc -mtriple=i386-linux-android < %s -o - | FileCheck --check-prefix=LINUX-I386 %s
44 ; RUN: llc -mtriple=x86_64-linux-android < %s -o - | FileCheck --check-prefix=LINUX-X64 %s
5 ; RUN: llc -mtriple=i386-kfreebsd < %s -o - | FileCheck --check-prefix=LINUX-I386 %s
6 ; RUN: llc -mtriple=x86_64-kfreebsd < %s -o - | FileCheck --check-prefix=LINUX-X64 %s
57
68 define void @_Z1fv() sspreq {
79 entry: