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
This commit is contained in:
Chris Lattner 2009-07-31 20:52:39 +00:00
parent 9c6c4d57be
commit 48bdeff884
6 changed files with 37 additions and 33 deletions

View File

@ -25,8 +25,6 @@ namespace llvm {
struct DarwinTargetAsmInfo : public TargetAsmInfo {
explicit DarwinTargetAsmInfo(const TargetMachine &TM);
virtual bool emitUsedDirectiveFor(const GlobalValue *GV,
Mangler *Mang) const;
};
}

View File

@ -23,8 +23,6 @@
namespace llvm {
template <typename T> 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

View File

@ -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;
};

View File

@ -564,7 +564,7 @@ void AsmPrinter::EmitLLVMUsedList(Constant *List) {
for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
const GlobalValue *GV =
dyn_cast<GlobalValue>(InitList->getOperand(i)->stripPointerCasts());
if (GV && TAI->emitUsedDirectiveFor(GV, Mang)) {
if (GV && getObjFileLowering().shouldEmitUsedDirectiveFor(GV, Mang)) {
O << Directive;
EmitConstantValueOnly(InitList->getOperand(i));
O << '\n';

View File

@ -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<Function>(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;
}

View File

@ -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<Function>(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
//===----------------------------------------------------------------------===//