[llvm-commits] [llvm] r94290 - in /llvm/trunk: include/llvm/MC/MCAsmInfo.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DwarfException.cpp lib/CodeGen/AsmPrinter/DwarfException.h lib/MC/MCAsmInfo.cpp lib/MC/MCAsmInfoDarwin.cpp lib/MC/MCMachOStreamer.cpp
Chris Lattner
sabre at nondot.org
Fri Jan 22 21:51:37 PST 2010
Author: lattner
Date: Fri Jan 22 23:51:36 2010
New Revision: 94290
URL: http://llvm.org/viewvc/llvm-project?rev=94290&view=rev
Log:
mcstreamerize .no_dead_strip and .reference for static ctors/dtors.
Modified:
llvm/trunk/include/llvm/MC/MCAsmInfo.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h
llvm/trunk/lib/MC/MCAsmInfo.cpp
llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
llvm/trunk/lib/MC/MCMachOStreamer.cpp
Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=94290&r1=94289&r2=94290&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original)
+++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Fri Jan 22 23:51:36 2010
@@ -209,10 +209,9 @@
/// .file directive, this is true for ELF targets.
bool HasSingleParameterDotFile; // Defaults to true.
- /// UsedDirective - This directive, if non-null, is used to declare a global
- /// as being used somehow that the assembler can't see. This prevents dead
- /// code elimination on some targets.
- const char *UsedDirective; // Defaults to NULL.
+ /// HasNoDeadStrip - True if this target supports the MachO .no_dead_strip
+ /// directive.
+ bool HasNoDeadStrip; // Defaults to false.
/// WeakRefDirective - This directive, if non-null, is used to declare a
/// global as being a weak undefined symbol.
@@ -410,15 +409,9 @@
bool getCOMMDirectiveTakesAlignment() const {
return COMMDirectiveTakesAlignment;
}
- bool hasDotTypeDotSizeDirective() const {
- return HasDotTypeDotSizeDirective;
- }
- bool hasSingleParameterDotFile() const {
- return HasSingleParameterDotFile;
- }
- const char *getUsedDirective() const {
- return UsedDirective;
- }
+ bool hasDotTypeDotSizeDirective() const {return HasDotTypeDotSizeDirective;}
+ bool hasSingleParameterDotFile() const { return HasSingleParameterDotFile; }
+ bool hasNoDeadStrip() const { return HasNoDeadStrip; }
const char *getWeakRefDirective() const { return WeakRefDirective; }
const char *getWeakDefDirective() const { return WeakDefDirective; }
const char *getLinkOnceDirective() const { return LinkOnceDirective; }
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=94290&r1=94289&r2=94290&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Jan 22 23:51:36 2010
@@ -313,7 +313,7 @@
}
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 @@
} 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 @@
/// 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 @@
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 @@
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 @@
/// 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 @@
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 @@
// 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())
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=94290&r1=94289&r2=94290&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Fri Jan 22 23:51:36 2010
@@ -245,8 +245,9 @@
// 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 @@
// 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 @@
EmitLabel("eh_func_end", SubprogramCount);
EmitExceptionTable();
- const MCSymbol *FunctionEHSym =
+ MCSymbol *FunctionEHSym =
Asm->GetSymbolWithGlobalValueBase(MF->getFunction(), ".eh",
Asm->MAI->is_EHSymbolPrivate());
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h?rev=94290&r1=94289&r2=94290&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h Fri Jan 22 23:51:36 2010
@@ -34,7 +34,7 @@
///
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 @@
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):
Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=94290&r1=94289&r2=94290&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmInfo.cpp Fri Jan 22 23:51:36 2010
@@ -57,7 +57,7 @@
COMMDirectiveTakesAlignment = true;
HasDotTypeDotSizeDirective = true;
HasSingleParameterDotFile = true;
- UsedDirective = 0;
+ HasNoDeadStrip = false;
WeakRefDirective = 0;
WeakDefDirective = 0;
LinkOnceDirective = 0;
Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=94290&r1=94289&r2=94290&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Fri Jan 22 23:51:36 2010
@@ -39,7 +39,7 @@
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.
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=94290&r1=94289&r2=94290&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Fri Jan 22 23:51:36 2010
@@ -234,6 +234,7 @@
case MCStreamer::Internal:
case MCStreamer::Protected:
case MCStreamer::Weak:
+ case MCStreamer::Local:
assert(0 && "Invalid symbol attribute for Mach-O!");
break;
More information about the llvm-commits
mailing list