diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-18 22:24:57 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-18 22:24:57 +0000 |
commit | 6880f0e19f24f7e7f0877e876b74c5cab10abc22 (patch) | |
tree | 87a2dc150f33e195518f8533ecdde923762aab8b /lib/LTO | |
parent | 1836fe5651722c638e32ac94c5b4fe885afa9f15 (diff) | |
download | llvm-6880f0e19f24f7e7f0877e876b74c5cab10abc22.tar.gz llvm-6880f0e19f24f7e7f0877e876b74c5cab10abc22.tar.bz2 llvm-6880f0e19f24f7e7f0877e876b74c5cab10abc22.tar.xz |
Fix PR18743.
The IR
@foo = private constant i32 42
is valid, but before this patch we would produce an invalid MachO from it. It
was invalid because it would use an L label in a section where the liker needs
the labels in order to atomize it.
One way of fixing it would be to just reject this IR in the backend, but that
would not be very front end friendly.
What this patch does is use an 'l' prefix in sections that we know the linker
requires symbols for atomizing them. This allows frontends to just use
private and not worry about which sections they go to or how the linker handles
them.
One small issue with this strategy is that now a symbol name depends on the
section, which is not available before codegen. This is not a problem in
practice. The reason is that it only happens with private linkage, which will
be ignored by the non codegen users (llvm-nm and llvm-ar).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201608 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/LTO')
-rw-r--r-- | lib/LTO/LTOCodeGenerator.cpp | 2 | ||||
-rw-r--r-- | lib/LTO/LTOModule.cpp | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp index 073947055a..01c8d405b4 100644 --- a/lib/LTO/LTOCodeGenerator.cpp +++ b/lib/LTO/LTOCodeGenerator.cpp @@ -336,7 +336,7 @@ applyRestriction(GlobalValue &GV, SmallPtrSet<GlobalValue*, 8> &AsmUsed, Mangler &Mangler) { SmallString<64> Buffer; - Mangler.getNameWithPrefix(Buffer, &GV); + TargetMach->getTargetLowering()->getNameWithPrefix(Buffer, &GV, Mangler); if (GV.isDeclaration()) return; diff --git a/lib/LTO/LTOModule.cpp b/lib/LTO/LTOModule.cpp index 909b92e888..a70c6e2c0a 100644 --- a/lib/LTO/LTOModule.cpp +++ b/lib/LTO/LTOModule.cpp @@ -381,7 +381,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 +517,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); |