[llvm-commits] [llvm] r145781 - in /llvm/trunk: include/llvm/MC/MCAsmInfo.h include/llvm/MC/MCObjectFileInfo.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/MC/MCAsmInfo.cpp lib/MC/MCAsmInfoDarwin.cpp lib/MC/MCObjectFileInfo.cpp lib/Target/ARM/ARMTargetObjectFile.cpp test/CodeGen/ARM/ctor_order.ll
Anton Korobeynikov
asl at math.spbu.ru
Sat Dec 3 15:49:38 PST 2011
Author: asl
Date: Sat Dec 3 17:49:37 2011
New Revision: 145781
URL: http://llvm.org/viewvc/llvm-project?rev=145781&view=rev
Log:
Emit the ctors in the proper order on ARM/EABI.
Maybe some targets should use this as well.
Patch by Evgeniy Stepanov!
Added:
llvm/trunk/test/CodeGen/ARM/ctor_order.ll
Modified:
llvm/trunk/include/llvm/MC/MCAsmInfo.h
llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/MC/MCAsmInfo.cpp
llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
llvm/trunk/lib/MC/MCObjectFileInfo.cpp
llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp
Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=145781&r1=145780&r2=145781&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original)
+++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Sat Dec 3 17:49:37 2011
@@ -36,10 +36,6 @@
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 {
@@ -72,11 +68,6 @@
/// 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
@@ -428,9 +419,6 @@
//
bool hasMachoZeroFillDirective() const { return HasMachoZeroFillDirective; }
bool hasMachoTBSSDirective() const { return HasMachoTBSSDirective; }
- Structors::OutputOrder getStructorOutputOrder() const {
- return StructorOutputOrder;
- }
bool hasStaticCtorDtorReferenceInStaticMode() const {
return HasStaticCtorDtorReferenceInStaticMode;
}
Modified: llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectFileInfo.h?rev=145781&r1=145780&r2=145781&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectFileInfo.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectFileInfo.h Sat Dec 3 17:49:37 2011
@@ -19,10 +19,14 @@
#include "llvm/MC/SectionKind.h"
namespace llvm {
-class MCContext;
-class MCSection;
-class Triple;
+ class MCContext;
+ class MCSection;
+ class Triple;
+ namespace Structors {
+ enum OutputOrder { None, PriorityOrder, ReversePriorityOrder };
+ }
+
class MCObjectFileInfo {
protected:
/// CommDirectiveSupportsAlignment - True if .comm supports alignment. This
@@ -164,6 +168,11 @@
const MCSection *PDataSection;
const MCSection *XDataSection;
+ /// 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.
+
public:
void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
MCContext &ctx);
@@ -291,6 +300,10 @@
return EHFrameSection;
}
+ Structors::OutputOrder getStructorOutputOrder() const {
+ return StructorOutputOrder;
+ }
+
private:
enum Environment { IsMachO, IsELF, IsCOFF };
Environment Env;
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=145781&r1=145780&r2=145781&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sat Dec 3 17:49:37 2011
@@ -1291,7 +1291,7 @@
}
// Emit the function pointers in reverse priority order.
- switch (MAI->getStructorOutputOrder()) {
+ switch (getObjFileLowering().getStructorOutputOrder()) {
case Structors::None:
break;
case Structors::PriorityOrder:
Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=145781&r1=145780&r2=145781&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmInfo.cpp Sat Dec 3 17:49:37 2011
@@ -29,7 +29,6 @@
HasSubsectionsViaSymbols = false;
HasMachoZeroFillDirective = false;
HasMachoTBSSDirective = false;
- StructorOutputOrder = Structors::ReversePriorityOrder;
HasStaticCtorDtorReferenceInStaticMode = false;
LinkerRequiresNonEmptyDwarfLines = false;
MaxInstLength = 4;
Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=145781&r1=145780&r2=145781&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Sat Dec 3 17:49:37 2011
@@ -39,7 +39,6 @@
ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
HasMachoZeroFillDirective = true; // Uses .zerofill
HasMachoTBSSDirective = true; // Uses .tbss
- StructorOutputOrder = Structors::PriorityOrder;
HasStaticCtorDtorReferenceInStaticMode = true;
CodeBegin = "L$start$code$";
Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=145781&r1=145780&r2=145781&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Sat Dec 3 17:49:37 2011
@@ -31,6 +31,8 @@
if (T.isMacOSX() && T.isMacOSXVersionLT(10, 5))
CommDirectiveSupportsAlignment = false;
+ StructorOutputOrder = Structors::PriorityOrder;
+
TextSection // .text
= Ctx->getMachOSection("__TEXT", "__text",
MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
@@ -258,6 +260,8 @@
}
}
+ StructorOutputOrder = Structors::ReversePriorityOrder;
+
// ELF
BSSSection =
Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
@@ -385,6 +389,8 @@
void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
// COFF
+ StructorOutputOrder = Structors::ReversePriorityOrder;
+
TextSection =
Ctx->getCOFFSection(".text",
COFF::IMAGE_SCN_CNT_CODE |
Modified: llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp?rev=145781&r1=145780&r2=145781&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp Sat Dec 3 17:49:37 2011
@@ -36,6 +36,7 @@
ELF::SHF_WRITE |
ELF::SHF_ALLOC,
SectionKind::getDataRel());
+ StructorOutputOrder = Structors::PriorityOrder;
LSDASection = NULL;
}
Added: llvm/trunk/test/CodeGen/ARM/ctor_order.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/ctor_order.ll?rev=145781&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/ctor_order.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/ctor_order.ll Sat Dec 3 17:49:37 2011
@@ -0,0 +1,28 @@
+; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s -check-prefix=DARWIN
+; RUN: llc < %s -mtriple=arm-linux-gnu | FileCheck %s -check-prefix=ELF
+; RUN: llc < %s -mtriple=arm-linux-gnueabi | FileCheck %s -check-prefix=GNUEABI
+
+; DARWIN: .section __DATA,__mod_init_func,mod_init_funcs
+; DARWIN: .long _f151
+; DARWIN-NEXT: .long _f152
+
+; ELF: .section .ctors,"aw",%progbits
+; ELF: .long f152
+; ELF-NEXT: .long f151
+
+; GNUEABI: .section .init_array,"aw",%init_array
+; GNUEABI: .long f151
+; GNUEABI-NEXT: .long f152
+
+
+ at llvm.global_ctors = appending global [2 x { i32, void ()* }] [ { i32, void ()* } { i32 151, void ()* @f151 }, { i32, void ()* } { i32 152, void ()* @f152 } ]
+
+define void @f151() {
+entry:
+ ret void
+}
+
+define void @f152() {
+entry:
+ ret void
+}
More information about the llvm-commits
mailing list