summaryrefslogtreecommitdiff
path: root/lib/Target
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2008-09-09 22:29:13 +0000
committerDale Johannesen <dalej@apple.com>2008-09-09 22:29:13 +0000
commitd2e51af0358b571367a9f1e5175b87e9dd72edf8 (patch)
tree829af1ac09fe4d71385f4e3370c0854d79bbb7e8 /lib/Target
parentb4ec2830499b8c3c5e0de56a2620fb2b21c88b9e (diff)
downloadllvm-d2e51af0358b571367a9f1e5175b87e9dd72edf8.tar.gz
llvm-d2e51af0358b571367a9f1e5175b87e9dd72edf8.tar.bz2
llvm-d2e51af0358b571367a9f1e5175b87e9dd72edf8.tar.xz
Move the uglier parts of deciding not to emit a
UsedDirective for some symbols in llvm.used into Darwin-specific code. I've decided LessPrivateGlobal is potentially a useful abstraction and left it in the target-independent area, with improved comment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56024 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/DarwinTargetAsmInfo.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Target/DarwinTargetAsmInfo.cpp b/lib/Target/DarwinTargetAsmInfo.cpp
index 749cb71794..2fc1d28d2b 100644
--- a/lib/Target/DarwinTargetAsmInfo.cpp
+++ b/lib/Target/DarwinTargetAsmInfo.cpp
@@ -17,6 +17,7 @@
#include "llvm/Function.h"
#include "llvm/GlobalVariable.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Mangler.h"
#include "llvm/Target/DarwinTargetAsmInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetData.h"
@@ -50,6 +51,26 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) {
SectionFlags::Writeable);
}
+/// emitUsedDirectiveFor - On Darwin, internally linked data beginning with
+/// the PrivateGlobalPrefix or the LessPrivateGlobalPrefix does not have the
+/// directive emitted (this occurs in ObjC metadata).
+
+bool
+DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV,
+ Mangler *Mang) const {
+ if (GV==0)
+ return false;
+ if (GV->hasInternalLinkage() && !isa<Function>(GV) &&
+ ((strlen(getPrivateGlobalPrefix()) != 0 &&
+ Mang->getValueName(GV).substr(0,strlen(getPrivateGlobalPrefix())) ==
+ getPrivateGlobalPrefix()) ||
+ (strlen(getLessPrivateGlobalPrefix()) != 0 &&
+ Mang->getValueName(GV).substr(0,strlen(getLessPrivateGlobalPrefix())) ==
+ getLessPrivateGlobalPrefix())))
+ return false;
+ return true;
+}
+
const Section*
DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
SectionKind::Kind Kind = SectionKindForGlobal(GV);