diff options
Diffstat (limited to 'llvm/lib/Target/TargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/TargetMachine.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index 309e1bf2786..b3ff0010c43 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -21,6 +21,7 @@ #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCCodeGenInfo.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCTargetOptions.h" #include "llvm/MC/SectionKind.h" #include "llvm/Support/CommandLine.h" @@ -169,6 +170,19 @@ void TargetMachine::setDataSections(bool V) { Options.DataSections = V; } +static bool canUsePrivateLabel(const MCAsmInfo &AsmInfo, + const MCSection &Section) { + if (!AsmInfo.isSectionAtomizableBySymbols(Section)) + return true; + + // If it is not dead stripped, it is safe to use private labels. + const MCSectionMachO &SMO = cast<MCSectionMachO>(Section); + if (SMO.hasAttribute(MachO::S_ATTR_NO_DEAD_STRIP)) + return true; + + return false; +} + void TargetMachine::getNameWithPrefix(SmallVectorImpl<char> &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate) const { @@ -182,7 +196,7 @@ void TargetMachine::getNameWithPrefix(SmallVectorImpl<char> &Name, const TargetLoweringObjectFile &TLOF = getSubtargetImpl()->getTargetLowering()->getObjFileLowering(); const MCSection *TheSection = TLOF.SectionForGlobal(GV, GVKind, Mang, *this); - bool CannotUsePrivateLabel = TLOF.isSectionAtomizableBySymbols(*TheSection); + bool CannotUsePrivateLabel = !canUsePrivateLabel(*AsmInfo, *TheSection); Mang.getNameWithPrefix(Name, GV, CannotUsePrivateLabel); } |