diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-01-19 04:34:02 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-01-19 04:34:02 +0000 |
| commit | e9d28b19cf3864c0e44e15036dc71e8e4eb31088 (patch) | |
| tree | 57430d35bc32d0a9143f9c43608caf92c1c5c4bf | |
| parent | 58d59fe394e7c773bff27b412d90f5d0523187aa (diff) | |
| download | bcm5719-llvm-e9d28b19cf3864c0e44e15036dc71e8e4eb31088.tar.gz bcm5719-llvm-e9d28b19cf3864c0e44e15036dc71e8e4eb31088.zip | |
move production of .reference directives for static ctor/dtor list on
darwin into common code.
llvm-svn: 93849
| -rw-r--r-- | llvm/include/llvm/MC/MCAsmInfo.h | 12 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/MC/MCAsmInfo.cpp | 1 | ||||
| -rw-r--r-- | llvm/lib/MC/MCAsmInfoDarwin.cpp | 1 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 11 | ||||
| -rw-r--r-- | llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 9 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp | 10 |
7 files changed, 23 insertions, 29 deletions
diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h index 6d01278711f..1368e1f4249 100644 --- a/llvm/include/llvm/MC/MCAsmInfo.h +++ b/llvm/include/llvm/MC/MCAsmInfo.h @@ -36,7 +36,13 @@ namespace llvm { /// HasMachoZeroFillDirective - True if this is a MachO target that supports /// the macho-specific .zerofill directive for emitting BSS Symbols. - bool HasMachoZeroFillDirective; // Default is false. + bool HasMachoZeroFillDirective; // Default is false. + + /// 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 + /// emitted in Static relocation model. + bool HasStaticCtorDtorReferenceInStaticMode; // Default is false. /// NeedsSet - True if target asm treats expressions in data directives /// as linktime-relocatable. For assembly-time computation, we need to @@ -314,7 +320,9 @@ namespace llvm { // Accessors. // bool hasMachoZeroFillDirective() const { return HasMachoZeroFillDirective; } - + bool hasStaticCtorDtorReferenceInStaticMode() const { + return HasStaticCtorDtorReferenceInStaticMode; + } const char *getNonexecutableStackDirective() const { return NonexecutableStackDirective; } diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 3beb4d66ac8..9a19f81e38b 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -449,6 +449,10 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) { OutStreamer.SwitchSection(getObjFileLowering().getStaticCtorSection()); EmitAlignment(Align, 0); EmitXXStructorList(GV->getInitializer()); + + if (TM.getRelocationModel() == Reloc::Static && + MAI->hasStaticCtorDtorReferenceInStaticMode()) + O << ".reference .constructors_used\n"; return true; } @@ -456,6 +460,10 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) { OutStreamer.SwitchSection(getObjFileLowering().getStaticDtorSection()); EmitAlignment(Align, 0); EmitXXStructorList(GV->getInitializer()); + + if (TM.getRelocationModel() == Reloc::Static && + MAI->hasStaticCtorDtorReferenceInStaticMode()) + O << ".reference .destructors_used\n"; return true; } diff --git a/llvm/lib/MC/MCAsmInfo.cpp b/llvm/lib/MC/MCAsmInfo.cpp index 6e8cd0ce8d7..277a09e9e9a 100644 --- a/llvm/lib/MC/MCAsmInfo.cpp +++ b/llvm/lib/MC/MCAsmInfo.cpp @@ -20,6 +20,7 @@ using namespace llvm; MCAsmInfo::MCAsmInfo() { HasMachoZeroFillDirective = false; + HasStaticCtorDtorReferenceInStaticMode = false; NonexecutableStackDirective = 0; NeedsSet = false; MaxInstLength = 4; diff --git a/llvm/lib/MC/MCAsmInfoDarwin.cpp b/llvm/lib/MC/MCAsmInfoDarwin.cpp index 8719bee89bf..5de86e0c901 100644 --- a/llvm/lib/MC/MCAsmInfoDarwin.cpp +++ b/llvm/lib/MC/MCAsmInfoDarwin.cpp @@ -36,6 +36,7 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() { LCOMMDirective = "\t.lcomm\t"; ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. HasMachoZeroFillDirective = true; // Uses .zerofill + HasStaticCtorDtorReferenceInStaticMode = true; SetDirective = "\t.set"; ProtectedDirective = "\t.globl\t"; HasDotTypeDotSizeDirective = false; diff --git a/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index fd26169db3f..070c29a24dd 100644 --- a/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -1171,17 +1171,8 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { return; // Check to see if this is a special global used by LLVM, if so, emit it. - - if (EmitSpecialLLVMGlobal(GVar)) { - if (Subtarget->isTargetDarwin() && - TM.getRelocationModel() == Reloc::Static) { - if (GVar->getName() == "llvm.global_ctors") - O << ".reference .constructors_used\n"; - else if (GVar->getName() == "llvm.global_dtors") - O << ".reference .destructors_used\n"; - } + if (EmitSpecialLLVMGlobal(GVar)) return; - } MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); diff --git a/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index e17d89a363b..a1c117dd041 100644 --- a/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -933,15 +933,8 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) { return; // External global require no code // Check to see if this is a special global used by LLVM, if so, emit it. - if (EmitSpecialLLVMGlobal(GVar)) { - if (TM.getRelocationModel() == Reloc::Static) { - if (GVar->getName() == "llvm.global_ctors") - O << ".reference .constructors_used\n"; - else if (GVar->getName() == "llvm.global_dtors") - O << ".reference .destructors_used\n"; - } + if (EmitSpecialLLVMGlobal(GVar)) return; - } MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); printVisibility(GVarSym, GVar->getVisibility()); diff --git a/llvm/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp b/llvm/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp index 438c208ad8f..bdbb2946faf 100644 --- a/llvm/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp +++ b/llvm/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp @@ -651,16 +651,8 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { return; // External global require no code // Check to see if this is a special global used by LLVM, if so, emit it. - if (EmitSpecialLLVMGlobal(GVar)) { - if (Subtarget->isTargetDarwin() && - TM.getRelocationModel() == Reloc::Static) { - if (GVar->getName() == "llvm.global_ctors") - O << ".reference .constructors_used\n"; - else if (GVar->getName() == "llvm.global_dtors") - O << ".reference .destructors_used\n"; - } + if (EmitSpecialLLVMGlobal(GVar)) return; - } const TargetData *TD = TM.getTargetData(); |

