mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 04:09:45 +00:00
Darwin wants ctors/dtors to be ordered the other way round to linux.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139015 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
98f213cd60
commit
147272b8a7
@ -36,6 +36,10 @@ namespace llvm {
|
||||
enum LCOMMType { None, NoAlignment, ByteAlignment };
|
||||
}
|
||||
|
||||
namespace Structors {
|
||||
enum OutputOrder { None, PriorityOrder, ReversePriorityOrder };
|
||||
}
|
||||
|
||||
/// MCAsmInfo - This class is intended to be used as a base class for asm
|
||||
/// properties and features specific to the target.
|
||||
class MCAsmInfo {
|
||||
@ -68,6 +72,11 @@ namespace llvm {
|
||||
/// the macho-specific .tbss directive for emitting thread local BSS Symbols
|
||||
bool HasMachoTBSSDirective; // Default is false.
|
||||
|
||||
/// StructorOutputOrder - Whether the static ctor/dtor list should be output
|
||||
/// in no particular order, in order of increasing priority or the reverse:
|
||||
/// in order of decreasing priority (the default).
|
||||
Structors::OutputOrder StructorOutputOrder; // Default is reverse order.
|
||||
|
||||
/// HasStaticCtorDtorReferenceInStaticMode - True if the compiler should
|
||||
/// emit a ".reference .constructors_used" or ".reference .destructors_used"
|
||||
/// directive after the a static ctor/dtor list. This directive is only
|
||||
@ -395,6 +404,9 @@ namespace llvm {
|
||||
//
|
||||
bool hasMachoZeroFillDirective() const { return HasMachoZeroFillDirective; }
|
||||
bool hasMachoTBSSDirective() const { return HasMachoTBSSDirective; }
|
||||
Structors::OutputOrder getStructorOutputOrder() const {
|
||||
return StructorOutputOrder;
|
||||
}
|
||||
bool hasStaticCtorDtorReferenceInStaticMode() const {
|
||||
return HasStaticCtorDtorReferenceInStaticMode;
|
||||
}
|
||||
|
@ -1265,7 +1265,16 @@ void AsmPrinter::EmitXXStructorList(const Constant *List) {
|
||||
}
|
||||
|
||||
// Emit the function pointers in reverse priority order.
|
||||
std::sort(Structors.rbegin(), Structors.rend(), priority_order);
|
||||
switch (MAI->getStructorOutputOrder()) {
|
||||
case Structors::None:
|
||||
break;
|
||||
case Structors::PriorityOrder:
|
||||
std::sort(Structors.begin(), Structors.end(), priority_order);
|
||||
break;
|
||||
case Structors::ReversePriorityOrder:
|
||||
std::sort(Structors.rbegin(), Structors.rend(), priority_order);
|
||||
break;
|
||||
}
|
||||
for (unsigned i = 0, e = Structors.size(); i != e; ++i)
|
||||
EmitGlobalConstant(Structors[i].second);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ MCAsmInfo::MCAsmInfo() {
|
||||
HasSubsectionsViaSymbols = false;
|
||||
HasMachoZeroFillDirective = false;
|
||||
HasMachoTBSSDirective = false;
|
||||
StructorOutputOrder = Structors::ReversePriorityOrder;
|
||||
HasStaticCtorDtorReferenceInStaticMode = false;
|
||||
LinkerRequiresNonEmptyDwarfLines = false;
|
||||
MaxInstLength = 4;
|
||||
|
@ -39,6 +39,7 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() {
|
||||
ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
|
||||
HasMachoZeroFillDirective = true; // Uses .zerofill
|
||||
HasMachoTBSSDirective = true; // Uses .tbss
|
||||
StructorOutputOrder = Structors::PriorityOrder;
|
||||
HasStaticCtorDtorReferenceInStaticMode = true;
|
||||
|
||||
// FIXME: Darwin 10 and newer don't need this.
|
||||
|
@ -1,17 +1,24 @@
|
||||
; RUN: llc < %s -mtriple=i386-linux-gnu | FileCheck %s
|
||||
; RUN: llc < %s -mtriple=i386-linux-gnu | FileCheck %s --check-prefix=CHECK-DEFAULT
|
||||
; RUN: llc < %s -mtriple=i386-apple-darwin | FileCheck %s --check-prefix=CHECK-DARWIN
|
||||
; PR5329
|
||||
|
||||
@llvm.global_ctors = appending global [3 x { i32, void ()* }] [{ i32, void ()* } { i32 2000, void ()* @construct_2 }, { i32, void ()* } { i32 3000, void ()* @construct_3 }, { i32, void ()* } { i32 1000, void ()* @construct_1 }]
|
||||
; CHECK: ctors
|
||||
; CHECK: construct_3
|
||||
; CHECK: construct_2
|
||||
; CHECK: construct_1
|
||||
; CHECK-DEFAULT: construct_3
|
||||
; CHECK-DEFAULT: construct_2
|
||||
; CHECK-DEFAULT: construct_1
|
||||
|
||||
; CHECK-DARWIN: construct_1
|
||||
; CHECK-DARWIN: construct_2
|
||||
; CHECK-DARWIN: construct_3
|
||||
|
||||
@llvm.global_dtors = appending global [3 x { i32, void ()* }] [{ i32, void ()* } { i32 2000, void ()* @destruct_2 }, { i32, void ()* } { i32 1000, void ()* @destruct_1 }, { i32, void ()* } { i32 3000, void ()* @destruct_3 }]
|
||||
; CHECK: dtors
|
||||
; CHECK: destruct_3
|
||||
; CHECK: destruct_2
|
||||
; CHECK: destruct_1
|
||||
; CHECK-DEFAULT: destruct_3
|
||||
; CHECK-DEFAULT: destruct_2
|
||||
; CHECK-DEFAULT: destruct_1
|
||||
|
||||
; CHECK-DARWIN: destruct_1
|
||||
; CHECK-DARWIN: destruct_2
|
||||
; CHECK-DARWIN: destruct_3
|
||||
|
||||
declare void @construct_1()
|
||||
declare void @construct_2()
|
||||
|
Loading…
Reference in New Issue
Block a user