Fix logic for not emitting no-dead-strip for some

objects in llvm.used (thanks Anton).  Makes visible
the magic 'l' prefix for symbols on Darwin which are
to be passed through the assembler, then removed at
linktime (previously all references to this had been
hidden in the ObjC FE code, oh well).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55973 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dale Johannesen 2008-09-09 01:21:22 +00:00
parent d8ee59b0ca
commit b2dfb89e0e
6 changed files with 27 additions and 3 deletions

View File

@ -216,10 +216,15 @@ namespace llvm {
const char *GlobalPrefix; // Defaults to "" const char *GlobalPrefix; // Defaults to ""
/// PrivateGlobalPrefix - This prefix is used for globals like constant /// PrivateGlobalPrefix - This prefix is used for globals like constant
/// pool entries that are completely private to the .o file and should not /// pool entries that are completely private to the .s file and should not
/// have names in the .o file. This is often "." or "L". /// have names in the .o file. This is often "." or "L".
const char *PrivateGlobalPrefix; // Defaults to "." const char *PrivateGlobalPrefix; // Defaults to "."
/// LessPrivateGlobalPrefix - This prefix is used for some Objective C
/// metadata symbols that should be passed through the assembler but be
/// removed by the linker. This is "l" on Darwin.
const char *LessPrivateGlobalPrefix; // Defaults to ""
/// JumpTableSpecialLabelPrefix - If not null, a extra (dead) label is /// JumpTableSpecialLabelPrefix - If not null, a extra (dead) label is
/// emitted before jump tables with the specified prefix. /// emitted before jump tables with the specified prefix.
const char *JumpTableSpecialLabelPrefix; // Default to null. const char *JumpTableSpecialLabelPrefix; // Default to null.
@ -653,6 +658,9 @@ namespace llvm {
const char *getPrivateGlobalPrefix() const { const char *getPrivateGlobalPrefix() const {
return PrivateGlobalPrefix; return PrivateGlobalPrefix;
} }
const char *getLessPrivateGlobalPrefix() const {
return LessPrivateGlobalPrefix;
}
const char *getJumpTableSpecialLabelPrefix() const { const char *getJumpTableSpecialLabelPrefix() const {
return JumpTableSpecialLabelPrefix; return JumpTableSpecialLabelPrefix;
} }

View File

@ -452,7 +452,9 @@ const GlobalValue * AsmPrinter::findGlobalValue(const Constant *CV) {
/// EmitLLVMUsedList - For targets that define a TAI::UsedDirective, mark each /// EmitLLVMUsedList - For targets that define a TAI::UsedDirective, mark each
/// global in the specified llvm.used list as being used with this directive. /// global in the specified llvm.used list as being used with this directive.
/// Non-globals (i.e. internal linkage) should not be emitted. /// Internally linked data beginning with the PrivateGlobalPrefix or the
/// LessPrivateGlobalPrefix does not have the directive emitted (this
/// occurs in ObjC metadata).
void AsmPrinter::EmitLLVMUsedList(Constant *List) { void AsmPrinter::EmitLLVMUsedList(Constant *List) {
const char *Directive = TAI->getUsedDirective(); const char *Directive = TAI->getUsedDirective();
@ -462,7 +464,17 @@ void AsmPrinter::EmitLLVMUsedList(Constant *List) {
for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) { for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
const GlobalValue *GV = findGlobalValue(InitList->getOperand(i)); const GlobalValue *GV = findGlobalValue(InitList->getOperand(i));
if (GV && (!GV->hasInternalLinkage() || isa<Function>(GV))) { if (GV) {
if (GV->hasInternalLinkage() && !isa<Function>(GV) &&
((strlen(TAI->getPrivateGlobalPrefix()) != 0 &&
Mang->getValueName(GV)
.substr(0,strlen(TAI->getPrivateGlobalPrefix())) ==
TAI->getPrivateGlobalPrefix()) ||
(strlen(TAI->getLessPrivateGlobalPrefix()) != 0 &&
Mang->getValueName(GV)
.substr(0,strlen(TAI->getLessPrivateGlobalPrefix())) ==
TAI->getLessPrivateGlobalPrefix())))
continue;
O << Directive; O << Directive;
EmitConstantValueOnly(InitList->getOperand(i)); EmitConstantValueOnly(InitList->getOperand(i));
O << '\n'; O << '\n';

View File

@ -62,6 +62,7 @@ ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM):
GlobalPrefix = "_"; GlobalPrefix = "_";
PrivateGlobalPrefix = "L"; PrivateGlobalPrefix = "L";
LessPrivateGlobalPrefix = "l";
StringConstantPrefix = "\1LC"; StringConstantPrefix = "\1LC";
BSSSection = 0; // no BSS section BSSSection = 0; // no BSS section
ZeroDirective = "\t.space\t"; ZeroDirective = "\t.space\t";

View File

@ -38,6 +38,7 @@ PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM):
CommentString = ";"; CommentString = ";";
GlobalPrefix = "_"; GlobalPrefix = "_";
PrivateGlobalPrefix = "L"; PrivateGlobalPrefix = "L";
LessPrivateGlobalPrefix = "l";
StringConstantPrefix = "\1LC"; StringConstantPrefix = "\1LC";
ConstantPoolSection = "\t.const\t"; ConstantPoolSection = "\t.const\t";
JumpTableDataSection = ".const"; JumpTableDataSection = ".const";

View File

@ -50,6 +50,7 @@ TargetAsmInfo::TargetAsmInfo() :
CommentString("#"), CommentString("#"),
GlobalPrefix(""), GlobalPrefix(""),
PrivateGlobalPrefix("."), PrivateGlobalPrefix("."),
LessPrivateGlobalPrefix(""),
JumpTableSpecialLabelPrefix(0), JumpTableSpecialLabelPrefix(0),
GlobalVarAddrPrefix(""), GlobalVarAddrPrefix(""),
GlobalVarAddrSuffix(""), GlobalVarAddrSuffix(""),

View File

@ -136,6 +136,7 @@ X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
Data64bitsDirective = 0; // we can't emit a 64-bit unit Data64bitsDirective = 0; // we can't emit a 64-bit unit
ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
PrivateGlobalPrefix = "L"; // Marker for constant pool idxs PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
LessPrivateGlobalPrefix = "l"; // Marker for some ObjC metadata
BSSSection = 0; // no BSS section. BSSSection = 0; // no BSS section.
ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill
if (DTM->getRelocationModel() != Reloc::Static) if (DTM->getRelocationModel() != Reloc::Static)