From bb46ff589d60c109277728c9f94ff9ce9553eca1 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 6 Mar 2014 22:15:10 +0000 Subject: Use llvm.compiler.used instead of llvm.used for objc symbols. LLVM currently has a hack (shouldEmitUsedDirectiveFor) that causes it to not print no_dead_strip for symbols starting with 'l' or 'L'. These are exactly the ones that the clang's objc codegen is producing. The net result, is that it is equivalent to llvm.compiler.used. The need for putting the private symbol in llvm.compiler.used should be clear (the objc runtime uses them). The reason for also putting the weak symbols in it is for LTO: ld64 will not ask us to preserve the it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203172 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/CodeGen/CodeGenModule.h') diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 151cb33d67..11272fc2ca 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -298,6 +298,7 @@ class CodeGenModule : public CodeGenTypeCache { /// forcing visibility of symbols which may otherwise be optimized /// out. std::vector LLVMUsed; + std::vector LLVMCompilerUsed; /// GlobalCtors - Store the list of global constructors and their respective /// priorities to be emitted when the translation unit is complete. @@ -799,10 +800,11 @@ public: template void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV); - /// AddUsedGlobal - Add a global which should be forced to be - /// present in the object file; these are emitted to the llvm.used - /// metadata global. - void AddUsedGlobal(llvm::GlobalValue *GV); + /// Add a global to a list to be added to the llvm.used metadata. + void addUsedGlobal(llvm::GlobalValue *GV); + + /// Add a global to a list to be added to the llvm.compiler.used metadata. + void addCompilerUsedGlobal(llvm::GlobalValue *GV); /// AddCXXDtorEntry - Add a destructor and object to add to the C++ global /// destructor function. @@ -1104,9 +1106,8 @@ private: /// still have a use for. void EmitDeferredVTables(); - /// EmitLLVMUsed - Emit the llvm.used metadata used to force - /// references to global which may otherwise be optimized out. - void EmitLLVMUsed(); + /// Emit the llvm.used and llvm.compiler.used metadata. + void emitLLVMUsed(); /// \brief Emit the link options introduced by imported modules. void EmitModuleLinkOptions(); -- cgit v1.2.3