From d25701c114e108af5e2f9f40a05c6ad0276ecb40 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 31 Jul 2009 20:52:39 +0000 Subject: 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/lib/Target/TargetLoweringObjectFile.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'llvm/lib/Target/TargetLoweringObjectFile.cpp') 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 //===----------------------------------------------------------------------===// -- cgit v1.1