summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-23 05:51:36 +0000
committerChris Lattner <sabre@nondot.org>2010-01-23 05:51:36 +0000
commit3a9be0ee36fe2143f514d28315f3dc1bda132b2e (patch)
tree1eba2579597f6e068b243e3c3593a004c2f788b3 /lib
parent63df4a4fec6aeff0a62d80d781019ac34d2fd98c (diff)
downloadllvm-3a9be0ee36fe2143f514d28315f3dc1bda132b2e.tar.gz
llvm-3a9be0ee36fe2143f514d28315f3dc1bda132b2e.tar.bz2
llvm-3a9be0ee36fe2143f514d28315f3dc1bda132b2e.tar.xz
mcstreamerize .no_dead_strip and .reference for static ctors/dtors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94290 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp31
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfException.cpp12
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfException.h4
-rw-r--r--lib/MC/MCAsmInfo.cpp2
-rw-r--r--lib/MC/MCAsmInfoDarwin.cpp2
-rw-r--r--lib/MC/MCMachOStreamer.cpp1
6 files changed, 29 insertions, 23 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 3d2f415741..415627eb9a 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -313,7 +313,7 @@ bool AsmPrinter::doFinalization(Module &M) {
}
if (MAI->getSetDirective()) {
- O << '\n';
+ OutStreamer.AddBlankLine();
for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end();
I != E; ++I) {
MCSymbol *Name = GetGlobalValueSymbol(I);
@@ -563,7 +563,7 @@ void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
} else {
O << *GetMBBSymbol(MBB->getNumber());
// If the arch uses custom Jump Table directives, don't calc relative to
- // JT
+ // JT.
if (!HadJTEntryDirective)
O << '-' << *GetJTISymbol(uid);
}
@@ -575,7 +575,7 @@ void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
/// do nothing and return false.
bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
if (GV->getName() == "llvm.used") {
- if (MAI->getUsedDirective() != 0) // No need to emit this at all.
+ if (MAI->hasNoDeadStrip()) // No need to emit this at all.
EmitLLVMUsedList(GV->getInitializer());
return true;
}
@@ -597,8 +597,11 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
EmitXXStructorList(GV->getInitializer());
if (TM.getRelocationModel() == Reloc::Static &&
- MAI->hasStaticCtorDtorReferenceInStaticMode())
- O << ".reference .constructors_used\n";
+ MAI->hasStaticCtorDtorReferenceInStaticMode()) {
+ StringRef Sym(".constructors_used");
+ OutStreamer.EmitSymbolAttribute(OutContext.GetOrCreateSymbol(Sym),
+ MCStreamer::Reference);
+ }
return true;
}
@@ -608,8 +611,11 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
EmitXXStructorList(GV->getInitializer());
if (TM.getRelocationModel() == Reloc::Static &&
- MAI->hasStaticCtorDtorReferenceInStaticMode())
- O << ".reference .destructors_used\n";
+ MAI->hasStaticCtorDtorReferenceInStaticMode()) {
+ StringRef Sym(".destructors_used");
+ OutStreamer.EmitSymbolAttribute(OutContext.GetOrCreateSymbol(Sym),
+ MCStreamer::Reference);
+ }
return true;
}
@@ -620,8 +626,6 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
/// global in the specified llvm.used list for which emitUsedDirectiveFor
/// is true, as being used with this directive.
void AsmPrinter::EmitLLVMUsedList(Constant *List) {
- const char *Directive = MAI->getUsedDirective();
-
// Should be an array of 'i8*'.
ConstantArray *InitList = dyn_cast<ConstantArray>(List);
if (InitList == 0) return;
@@ -629,11 +633,9 @@ void AsmPrinter::EmitLLVMUsedList(Constant *List) {
for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
const GlobalValue *GV =
dyn_cast<GlobalValue>(InitList->getOperand(i)->stripPointerCasts());
- if (GV && getObjFileLowering().shouldEmitUsedDirectiveFor(GV, Mang)) {
- O << Directive;
- EmitConstantValueOnly(InitList->getOperand(i));
- O << '\n';
- }
+ if (GV && getObjFileLowering().shouldEmitUsedDirectiveFor(GV, Mang))
+ OutStreamer.EmitSymbolAttribute(GetGlobalValueSymbol(GV),
+ MCStreamer::NoDeadStrip);
}
}
@@ -1584,6 +1586,7 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const {
// Print the main label for the block.
if (MBB->pred_empty() || MBB->isOnlyReachableByFallthrough()) {
if (VerboseAsm) {
+ // NOTE: Want this comment at start of line.
O << MAI->getCommentString() << " BB#" << MBB->getNumber() << ':';
if (const BasicBlock *BB = MBB->getBasicBlock())
if (BB->hasName())
diff --git a/lib/CodeGen/AsmPrinter/DwarfException.cpp b/lib/CodeGen/AsmPrinter/DwarfException.cpp
index 9a1c41c2a6..1b72f73fb1 100644
--- a/lib/CodeGen/AsmPrinter/DwarfException.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfException.cpp
@@ -245,8 +245,9 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
// This name has no connection to the function, so it might get
// dead-stripped when the function is not, erroneously. Prohibit
// dead-stripping unconditionally.
- if (const char *UsedDirective = MAI->getUsedDirective())
- O << UsedDirective << *EHFrameInfo.FunctionEHSym << "\n\n";
+ if (MAI->hasNoDeadStrip())
+ Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
+ MCStreamer::NoDeadStrip);
} else {
O << *EHFrameInfo.FunctionEHSym << ":\n";
@@ -313,8 +314,9 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
// on unused functions (calling undefined externals) being dead-stripped to
// link correctly. Yes, there really is.
if (MMI->isUsedFunction(EHFrameInfo.function))
- if (const char *UsedDirective = MAI->getUsedDirective())
- O << UsedDirective << *EHFrameInfo.FunctionEHSym << "\n\n";
+ if (MAI->hasNoDeadStrip())
+ Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
+ MCStreamer::NoDeadStrip);
}
Asm->O << '\n';
}
@@ -982,7 +984,7 @@ void DwarfException::EndFunction() {
EmitLabel("eh_func_end", SubprogramCount);
EmitExceptionTable();
- const MCSymbol *FunctionEHSym =
+ MCSymbol *FunctionEHSym =
Asm->GetSymbolWithGlobalValueBase(MF->getFunction(), ".eh",
Asm->MAI->is_EHSymbolPrivate());
diff --git a/lib/CodeGen/AsmPrinter/DwarfException.h b/lib/CodeGen/AsmPrinter/DwarfException.h
index 143e0e02d5..3921e91ea5 100644
--- a/lib/CodeGen/AsmPrinter/DwarfException.h
+++ b/lib/CodeGen/AsmPrinter/DwarfException.h
@@ -34,7 +34,7 @@ class raw_ostream;
///
class DwarfException : public DwarfPrinter {
struct FunctionEHFrameInfo {
- const MCSymbol *FunctionEHSym; // L_foo.eh
+ MCSymbol *FunctionEHSym; // L_foo.eh
unsigned Number;
unsigned PersonalityIndex;
bool hasCalls;
@@ -42,7 +42,7 @@ class DwarfException : public DwarfPrinter {
std::vector<MachineMove> Moves;
const Function *function;
- FunctionEHFrameInfo(const MCSymbol *EHSym, unsigned Num, unsigned P,
+ FunctionEHFrameInfo(MCSymbol *EHSym, unsigned Num, unsigned P,
bool hC, bool hL,
const std::vector<MachineMove> &M,
const Function *f):
diff --git a/lib/MC/MCAsmInfo.cpp b/lib/MC/MCAsmInfo.cpp
index cc03614157..ef6dd071e0 100644
--- a/lib/MC/MCAsmInfo.cpp
+++ b/lib/MC/MCAsmInfo.cpp
@@ -57,7 +57,7 @@ MCAsmInfo::MCAsmInfo() {
COMMDirectiveTakesAlignment = true;
HasDotTypeDotSizeDirective = true;
HasSingleParameterDotFile = true;
- UsedDirective = 0;
+ HasNoDeadStrip = false;
WeakRefDirective = 0;
WeakDefDirective = 0;
LinkOnceDirective = 0;
diff --git a/lib/MC/MCAsmInfoDarwin.cpp b/lib/MC/MCAsmInfoDarwin.cpp
index 664a55c088..a66a83d014 100644
--- a/lib/MC/MCAsmInfoDarwin.cpp
+++ b/lib/MC/MCAsmInfoDarwin.cpp
@@ -39,7 +39,7 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() {
SetDirective = "\t.set";
ProtectedDirective = "\t.globl\t";
HasDotTypeDotSizeDirective = false;
- UsedDirective = "\t.no_dead_strip\t";
+ HasNoDeadStrip = true;
// Note: Even though darwin has the .lcomm directive, it is just a synonym for
// zerofill, so we prefer to use .zerofill.
diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp
index ffdd421f4e..4ed8ec3521 100644
--- a/lib/MC/MCMachOStreamer.cpp
+++ b/lib/MC/MCMachOStreamer.cpp
@@ -234,6 +234,7 @@ void MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
case MCStreamer::Internal:
case MCStreamer::Protected:
case MCStreamer::Weak:
+ case MCStreamer::Local:
assert(0 && "Invalid symbol attribute for Mach-O!");
break;