diff options
| author | Dale Johannesen <dalej@apple.com> | 2008-09-09 22:29:13 +0000 |
|---|---|---|
| committer | Dale Johannesen <dalej@apple.com> | 2008-09-09 22:29:13 +0000 |
| commit | abb1e7770bc58ecb7d790db4ebf7ebf2995e2735 (patch) | |
| tree | 728f5b0f3d44a9fcfc61a988ebaae14b2b76efc8 /llvm/lib | |
| parent | 48217d89b4226bac6e72e46fb8a49b50dd96ba3e (diff) | |
| download | bcm5719-llvm-abb1e7770bc58ecb7d790db4ebf7ebf2995e2735.tar.gz bcm5719-llvm-abb1e7770bc58ecb7d790db4ebf7ebf2995e2735.zip | |
Move the uglier parts of deciding not to emit a
UsedDirective for some symbols in llvm.used into
Darwin-specific code. I've decided LessPrivateGlobal
is potentially a useful abstraction and left it in
the target-independent area, with improved comment.
llvm-svn: 56024
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 19 | ||||
| -rw-r--r-- | llvm/lib/Target/DarwinTargetAsmInfo.cpp | 21 |
2 files changed, 25 insertions, 15 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index f041f3be56f..98f4b7d13cd 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -451,10 +451,9 @@ const GlobalValue * AsmPrinter::findGlobalValue(const Constant *CV) { } /// EmitLLVMUsedList - For targets that define a TAI::UsedDirective, mark each -/// global in the specified llvm.used list as being used with this directive. -/// Internally linked data beginning with the PrivateGlobalPrefix or the -/// LessPrivateGlobalPrefix does not have the directive emitted (this -/// occurs in ObjC metadata). +/// 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 = TAI->getUsedDirective(); @@ -464,17 +463,7 @@ void AsmPrinter::EmitLLVMUsedList(Constant *List) { for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) { const GlobalValue *GV = findGlobalValue(InitList->getOperand(i)); - 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; + if (TAI->emitUsedDirectiveFor(GV, Mang)) { O << Directive; EmitConstantValueOnly(InitList->getOperand(i)); O << '\n'; diff --git a/llvm/lib/Target/DarwinTargetAsmInfo.cpp b/llvm/lib/Target/DarwinTargetAsmInfo.cpp index 749cb717943..2fc1d28d2b6 100644 --- a/llvm/lib/Target/DarwinTargetAsmInfo.cpp +++ b/llvm/lib/Target/DarwinTargetAsmInfo.cpp @@ -17,6 +17,7 @@ #include "llvm/Function.h" #include "llvm/GlobalVariable.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Mangler.h" #include "llvm/Target/DarwinTargetAsmInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetData.h" @@ -50,6 +51,26 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) { SectionFlags::Writeable); } +/// emitUsedDirectiveFor - On Darwin, internally linked data beginning with +/// the PrivateGlobalPrefix or the LessPrivateGlobalPrefix does not have the +/// directive emitted (this occurs in ObjC metadata). + +bool +DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV, + Mangler *Mang) const { + if (GV==0) + return false; + if (GV->hasInternalLinkage() && !isa<Function>(GV) && + ((strlen(getPrivateGlobalPrefix()) != 0 && + Mang->getValueName(GV).substr(0,strlen(getPrivateGlobalPrefix())) == + getPrivateGlobalPrefix()) || + (strlen(getLessPrivateGlobalPrefix()) != 0 && + Mang->getValueName(GV).substr(0,strlen(getLessPrivateGlobalPrefix())) == + getLessPrivateGlobalPrefix()))) + return false; + return true; +} + const Section* DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { SectionKind::Kind Kind = SectionKindForGlobal(GV); |

