From 2d34f9f9db93f596ea731c546d833ab5d6bb5735 Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Tue, 9 Sep 2008 01:21:22 +0000 Subject: 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 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/CodeGen/AsmPrinter/AsmPrinter.cpp') diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 273253a..f041f3b 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -452,7 +452,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. -/// 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) { const char *Directive = TAI->getUsedDirective(); @@ -462,7 +464,17 @@ void AsmPrinter::EmitLLVMUsedList(Constant *List) { for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) { const GlobalValue *GV = findGlobalValue(InitList->getOperand(i)); - if (GV && (!GV->hasInternalLinkage() || isa(GV))) { + if (GV) { + if (GV->hasInternalLinkage() && !isa(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; EmitConstantValueOnly(InitList->getOperand(i)); O << '\n'; -- cgit v1.1