From b52d0c0d74c506c3d701cd61d03abbfa6446e274 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 6 Mar 2014 22:47:08 +0000 Subject: [PATCH] Remove shouldEmitUsedDirectiveFor. Clang now uses llvm.compiler.used for these cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203174 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../CodeGen/TargetLoweringObjectFileImpl.h | 6 ------ include/llvm/Target/TargetLoweringObjectFile.h | 8 -------- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 +- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 18 ------------------ test/CodeGen/X86/darwin-no-dead-strip.ll | 6 +++++- 5 files changed, 6 insertions(+), 34 deletions(-) diff --git a/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h b/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h index fd4fa46f09d..16fed32aa18 100644 --- a/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h +++ b/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h @@ -102,12 +102,6 @@ public: const MCSection *getSectionForConstant(SectionKind Kind) const override; - /// This hook allows targets to selectively decide not to emit the - /// UsedDirective for some symbols in llvm.used. - /// FIXME: REMOVE this (rdar://7071300) - bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler &Mang, - TargetMachine &TM) const override; - /// The mach-o version of this method defaults to returning a stub reference. const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, diff --git a/include/llvm/Target/TargetLoweringObjectFile.h b/include/llvm/Target/TargetLoweringObjectFile.h index 2d9e8d3a2df..cdb7ea6ca1b 100644 --- a/include/llvm/Target/TargetLoweringObjectFile.h +++ b/include/llvm/Target/TargetLoweringObjectFile.h @@ -68,14 +68,6 @@ public: ArrayRef Flags, Mangler &Mang, const TargetMachine &TM) const {} - /// 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 &Mang, - TargetMachine &TM) const { - return GV != 0; - } - /// Given a constant with the SectionKind, return a section that it should be /// placed in. virtual const MCSection *getSectionForConstant(SectionKind Kind) const; diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 40d6bde3722..cf5b944ee7d 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1453,7 +1453,7 @@ void AsmPrinter::EmitLLVMUsedList(const ConstantArray *InitList) { for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) { const GlobalValue *GV = dyn_cast(InitList->getOperand(i)->stripPointerCasts()); - if (GV && getObjFileLowering().shouldEmitUsedDirectiveFor(GV, *Mang, TM)) + if (GV) OutStreamer.EmitSymbolAttribute(getSymbol(GV), MCSA_NoDeadStrip); } } diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index a4eb0ca7ffc..0473729de04 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -641,24 +641,6 @@ TargetLoweringObjectFileMachO::getSectionForConstant(SectionKind Kind) const { return ReadOnlySection; // .const } -/// 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, TargetMachine &TM) const { - // 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. - MCSymbol *Sym = TM.getSymbol(GV, Mang); - if (Sym->getName()[0] == 'L' || Sym->getName()[0] == 'l') - return false; - } - - return true; -} - const MCExpr *TargetLoweringObjectFileMachO::getTTypeGlobalReference( const GlobalValue *GV, unsigned Encoding, Mangler &Mang, const TargetMachine &TM, MachineModuleInfo *MMI, diff --git a/test/CodeGen/X86/darwin-no-dead-strip.ll b/test/CodeGen/X86/darwin-no-dead-strip.ll index edbd8aaa067..35196aa5f8d 100644 --- a/test/CodeGen/X86/darwin-no-dead-strip.ll +++ b/test/CodeGen/X86/darwin-no-dead-strip.ll @@ -6,4 +6,8 @@ target triple = "i686-apple-darwin8.7.2" @x = weak global i32 0 ; CHECK: .no_dead_strip _x -@llvm.used = appending global [1 x i8*] [ i8* bitcast (i32* @x to i8*) ] +@"\01Ly" = private global i8 0 +; CHECK: no_dead_strip Ly + +@llvm.used = appending global [2 x i8*] [ i8* bitcast (i32* @x to i8*), + i8* @"\01Ly" ] -- 2.34.1