This is an archive of the discontinued LLVM Phabricator instance.

Add segmented stack support for DragonFlyBSD
ClosedPublic

Authored by mneumann on Jul 29 2014, 6:20 AM.

Details

Reviewers
rafael
Group Reviewers
deleted
Summary

This patch adds support for segmented stacks for DragonFlyBSD. It is required to port the Rust programming language to DragonFly. With this patch rustc can generate code targeted at DragonFly.

Diff Detail

Event Timeline

mneumann updated this revision to Diff 11978.Jul 29 2014, 6:20 AM
mneumann retitled this revision from to Add segmented stack support for DragonFlyBSD.
mneumann updated this object.
mneumann edited the test plan for this revision. (Show Details)
mneumann added a subscriber: Unknown Object (MLST).

Ping!

Am 29.07.2014 um 15:20 schrieb Michael Neumann:

This patch adds support for segmented stacks for DragonFlyBSD. It is required to port the Rust programming language to DragonFly. With this patch rustc can generate code targeted at DragonFly.

http://reviews.llvm.org/D4705

Files:

lib/Target/X86/X86FrameLowering.cpp
lib/Target/X86/X86Subtarget.h

Index: lib/Target/X86/X86FrameLowering.cpp

  • lib/Target/X86/X86FrameLowering.cpp

+++ lib/Target/X86/X86FrameLowering.cpp
@@ -1328,7 +1328,8 @@

if (MF.getFunction()->isVarArg())
  report_fatal_error("Segmented stacks do not support vararg functions.");
if (!STI.isTargetLinux() && !STI.isTargetDarwin() &&
  • !STI.isTargetWin32() && !STI.isTargetWin64() && !STI.isTargetFreeBSD())

+ !STI.isTargetWin32() && !STI.isTargetWin64() &&
+ !STI.isTargetFreeBSD() && !STI.isTargetDragonFly())

  report_fatal_error("Segmented stacks not supported on this platform.");

// Eventually StackSize will be calculated by a link-time pass; which will

@@ -1382,6 +1383,9 @@

} else if (STI.isTargetFreeBSD()) {
  TlsReg = X86::FS;
  TlsOffset = 0x18;

+ } else if (STI.isTargetDragonFly()) {
+ TlsReg = X86::FS;
+ TlsOffset = 0x20; // use tls_tcb.tcb_segstack

} else {
  report_fatal_error("Segmented stacks not supported on this platform.");
}

@@ -1404,6 +1408,9 @@

} else if (STI.isTargetWin32()) {
  TlsReg = X86::FS;
  TlsOffset = 0x14; // pvArbitrary, reserved for application use

+ } else if (STI.isTargetDragonFly()) {
+ TlsReg = X86::FS;
+ TlsOffset = 0x10; // use tls_tcb.tcb_segstack

} else if (STI.isTargetFreeBSD()) {
  report_fatal_error("Segmented stacks not supported on FreeBSD i386.");
} else {

Index: lib/Target/X86/X86Subtarget.h

  • lib/Target/X86/X86Subtarget.h

+++ lib/Target/X86/X86Subtarget.h
@@ -371,6 +371,9 @@

bool isTargetFreeBSD() const {
  return TargetTriple.getOS() == Triple::FreeBSD;
}

+ bool isTargetDragonFly() const {
+ return TargetTriple.getOS() == Triple::DragonFly;
+ }

bool isTargetSolaris() const {
  return TargetTriple.getOS() == Triple::Solaris;
}

You should add a testcase showing what code llc produces for both 32 and 64 bits.

mneumann updated this revision to Diff 17257.Dec 13 2014, 8:38 AM

Add codegen test cases and fix a bug in the X32 generation.

rafael accepted this revision.Dec 15 2014, 1:45 PM
rafael added a reviewer: rafael.

LGTM with it clang-formated.

include/llvm/ADT/Triple.h
380

This fits in one line, no? Can you git-clang-format the patch?

This revision is now accepted and ready to land.Dec 15 2014, 1:45 PM
mneumann updated this revision to Diff 17645.Dec 27 2014, 1:50 AM
mneumann edited edge metadata.

clang-formatted version