diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-19 17:23:20 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-19 17:23:20 +0000 |
commit | 737c9f6005594898eed4746cd310cd161ef209c6 (patch) | |
tree | 2990b943f1db8362282b23b6c1d01019f24dd96f /lib/LTO/LTOModule.cpp | |
parent | cf42174647af5265e35f0e15fbffa17445ae0e80 (diff) | |
download | llvm-737c9f6005594898eed4746cd310cd161ef209c6.tar.gz llvm-737c9f6005594898eed4746cd310cd161ef209c6.tar.bz2 llvm-737c9f6005594898eed4746cd310cd161ef209c6.tar.xz |
Add back r201608, r201622, r201624 and r201625
r201608 made llvm corretly handle private globals with MachO. r201622 fixed
a bug in it and r201624 and r201625 were changes for using private linkage,
assuming that llvm would do the right thing.
They all got reverted because r201608 introduced a crash in LTO. This patch
includes a fix for that. The issue was that TargetLoweringObjectFile now has
to be initialized before we can mangle names of private globals. This is
trivially true during the normal codegen pipeline (the asm printer does it),
but LTO has to do it manually.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201700 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/LTO/LTOModule.cpp')
-rw-r--r-- | lib/LTO/LTOModule.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/LTO/LTOModule.cpp b/lib/LTO/LTOModule.cpp index 909b92e888..86b67ef205 100644 --- a/lib/LTO/LTOModule.cpp +++ b/lib/LTO/LTOModule.cpp @@ -176,6 +176,16 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer, m->materializeAllPermanently(); LTOModule *Ret = new LTOModule(m.take(), target); + + // We need a MCContext set up in order to get mangled names of private + // symbols. It is a bit odd that we need to report uses and definitions + // of private symbols, but it does look like ld64 expects to be informed + // of at least the ones with an 'l' prefix. + MCContext &Context = Ret->_context; + const TargetLoweringObjectFile &TLOF = + target->getTargetLowering()->getObjFileLowering(); + const_cast<TargetLoweringObjectFile &>(TLOF).Initialize(Context, *target); + if (Ret->parseSymbols(errMsg)) { delete Ret; return NULL; @@ -381,7 +391,7 @@ void LTOModule::addDefinedSymbol(const GlobalValue *def, bool isFunction) { // string is owned by _defines SmallString<64> Buffer; - _mangler.getNameWithPrefix(Buffer, def); + _target->getTargetLowering()->getNameWithPrefix(Buffer, def, _mangler); // set alignment part log2() can have rounding errors uint32_t align = def->getAlignment(); @@ -517,7 +527,7 @@ LTOModule::addPotentialUndefinedSymbol(const GlobalValue *decl, bool isFunc) { return; SmallString<64> name; - _mangler.getNameWithPrefix(name, decl); + _target->getTargetLowering()->getNameWithPrefix(name, decl, _mangler); StringMap<NameAndAttributes>::value_type &entry = _undefines.GetOrCreateValue(name); |