From d25701c114e108af5e2f9f40a05c6ad0276ecb40 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 31 Jul 2009 20:52:39 +0000 Subject: [PATCH] move emitUsedDirectiveFor to TargetLoweringObjectFile and rename it to indicate that it is a predicate, not an emitter. This eliminates TAI dependencies on Mangler and GlobalValue. llvm-svn: 77726 --- llvm/include/llvm/Target/DarwinTargetAsmInfo.h | 2 -- llvm/include/llvm/Target/TargetAsmInfo.h | 10 ---------- .../include/llvm/Target/TargetLoweringObjectFile.h | 13 ++++++++++++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 +- llvm/lib/Target/DarwinTargetAsmInfo.cpp | 20 ------------------- llvm/lib/Target/TargetLoweringObjectFile.cpp | 23 ++++++++++++++++++++++ 6 files changed, 37 insertions(+), 33 deletions(-) diff --git a/llvm/include/llvm/Target/DarwinTargetAsmInfo.h b/llvm/include/llvm/Target/DarwinTargetAsmInfo.h index c934c05..99e4130 100644 --- a/llvm/include/llvm/Target/DarwinTargetAsmInfo.h +++ b/llvm/include/llvm/Target/DarwinTargetAsmInfo.h @@ -25,8 +25,6 @@ namespace llvm { struct DarwinTargetAsmInfo : public TargetAsmInfo { explicit DarwinTargetAsmInfo(const TargetMachine &TM); - virtual bool emitUsedDirectiveFor(const GlobalValue *GV, - Mangler *Mang) const; }; } diff --git a/llvm/include/llvm/Target/TargetAsmInfo.h b/llvm/include/llvm/Target/TargetAsmInfo.h index 373e556..ad4f431 100644 --- a/llvm/include/llvm/Target/TargetAsmInfo.h +++ b/llvm/include/llvm/Target/TargetAsmInfo.h @@ -23,8 +23,6 @@ namespace llvm { template class SmallVectorImpl; class TargetMachine; - class GlobalValue; - class Mangler; // DWARF encoding query type namespace DwarfEncoding { @@ -430,14 +428,6 @@ namespace llvm { /// length. virtual unsigned getInlineAsmLength(const char *Str) const; - /// emitUsedDirectiveFor - This hook allows targets to selectively decide - /// not to emit the UsedDirective for some symbols in llvm.used. -// FIXME: REMOVE this (rdar://7071300) - virtual bool emitUsedDirectiveFor(const GlobalValue *GV, - Mangler *) const { - return (GV!=0); - } - /// PreferredEHDataFormat - This hook allows the target to select data /// format used for encoding pointers in exception handling data. Reason is /// 0 for data, 1 for code labels, 2 for function pointers. Global is true diff --git a/llvm/include/llvm/Target/TargetLoweringObjectFile.h b/llvm/include/llvm/Target/TargetLoweringObjectFile.h index feecaac..868b274 100644 --- a/llvm/include/llvm/Target/TargetLoweringObjectFile.h +++ b/llvm/include/llvm/Target/TargetLoweringObjectFile.h @@ -259,6 +259,13 @@ public: const MCSection *getTextSection() const { return TextSection; } const MCSection *getDataSection() const { return DataSection; } + /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively + /// decide not to emit the UsedDirective for some symbols in llvm.used. + /// FIXME: REMOVE this (rdar://7071300) + virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, + Mangler *) const { + return (GV!=0); + } /// getSectionForMergeableConstant - Given a mergeable constant with the /// specified size and relocation information, return a section that it @@ -368,6 +375,12 @@ public: virtual const MCSection * getSectionForMergeableConstant(SectionKind Kind) const; + + /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively + /// decide not to emit the UsedDirective for some symbols in llvm.used. + /// FIXME: REMOVE this (rdar://7071300) + virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, + Mangler *) const; }; diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 178bbaa..077d72e 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -564,7 +564,7 @@ void AsmPrinter::EmitLLVMUsedList(Constant *List) { for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) { const GlobalValue *GV = dyn_cast(InitList->getOperand(i)->stripPointerCasts()); - if (GV && TAI->emitUsedDirectiveFor(GV, Mang)) { + if (GV && getObjFileLowering().shouldEmitUsedDirectiveFor(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 aa93c0d..306300e 100644 --- a/llvm/lib/Target/DarwinTargetAsmInfo.cpp +++ b/llvm/lib/Target/DarwinTargetAsmInfo.cpp @@ -79,23 +79,3 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) DwarfMacroInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; } -/// emitUsedDirectiveFor - On Darwin, internally linked data beginning with -/// the PrivateGlobalPrefix or the LinkerPrivateGlobalPrefix does not have the -/// directive emitted (this occurs in ObjC metadata). -bool DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV, - Mangler *Mang) const { - if (!GV) return false; - - // Check whether the mangled name has the "Private" or "LinkerPrivate" prefix. - if (GV->hasLocalLinkage() && !isa(GV)) { - // FIXME: ObjC metadata is currently emitted as internal symbols that have - // \1L and \0l prefixes on them. Fix them to be Private/LinkerPrivate and - // this horrible hack can go away. - const std::string &Name = Mang->getMangledName(GV); - if (Name[0] == 'L' || Name[0] == 'l') - return false; - } - - return true; -} - diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp index 36fda0b..9ba12bb2 100644 --- a/llvm/lib/Target/TargetLoweringObjectFile.cpp +++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp @@ -585,6 +585,29 @@ getSectionForMergeableConstant(SectionKind Kind) const { return ReadOnlySection; // .const } +/// shouldEmitUsedDirectiveFor - This hook allows targets to selectively decide +/// not to emit the UsedDirective for some symbols in llvm.used. +// FIXME: REMOVE this (rdar://7071300) +bool TargetLoweringObjectFileMachO:: +shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const { + /// On Darwin, internally linked data beginning with "L" or "l" does not have + /// the directive emitted (this occurs in ObjC metadata). + if (!GV) return false; + + // Check whether the mangled name has the "Private" or "LinkerPrivate" prefix. + if (GV->hasLocalLinkage() && !isa(GV)) { + // FIXME: ObjC metadata is currently emitted as internal symbols that have + // \1L and \0l prefixes on them. Fix them to be Private/LinkerPrivate and + // this horrible hack can go away. + const std::string &Name = Mang->getMangledName(GV); + if (Name[0] == 'L' || Name[0] == 'l') + return false; + } + + return true; +} + + //===----------------------------------------------------------------------===// // COFF //===----------------------------------------------------------------------===// -- 2.7.4