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/Target/TargetLoweringObjectFile.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/Target/TargetLoweringObjectFile.cpp')
-rw-r--r-- | lib/Target/TargetLoweringObjectFile.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/lib/Target/TargetLoweringObjectFile.cpp b/lib/Target/TargetLoweringObjectFile.cpp index a0218a83df..9fff220d47 100644 --- a/lib/Target/TargetLoweringObjectFile.cpp +++ b/lib/Target/TargetLoweringObjectFile.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetOptions.h" using namespace llvm; @@ -99,30 +100,22 @@ static bool IsNullTerminatedString(const Constant *C) { return false; } -/// Return the MCSymbol for the specified global value. This -/// symbol is the main label that is the address of the global. -MCSymbol *TargetLoweringObjectFile::getSymbol(const GlobalValue *GV, - Mangler &M) const { - SmallString<60> NameStr; - M.getNameWithPrefix(NameStr, GV); - return Ctx->GetOrCreateSymbol(NameStr.str()); -} - MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase( - const GlobalValue *GV, StringRef Suffix, Mangler &M) const { + const GlobalValue *GV, StringRef Suffix, Mangler &Mang, + const TargetMachine &TM) const { assert(!Suffix.empty()); SmallString<60> NameStr; NameStr += DL->getPrivateGlobalPrefix(); - M.getNameWithPrefix(NameStr, GV); + TM.getTargetLowering()->getNameWithPrefix(NameStr, GV, Mang); NameStr.append(Suffix.begin(), Suffix.end()); return Ctx->GetOrCreateSymbol(NameStr.str()); } -MCSymbol *TargetLoweringObjectFile:: -getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang, - MachineModuleInfo *MMI) const { - return getSymbol(GV, Mang); +MCSymbol *TargetLoweringObjectFile::getCFIPersonalitySymbol( + const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM, + MachineModuleInfo *MMI) const { + return TM.getTargetLowering()->getSymbol(GV, Mang); } void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer, @@ -275,6 +268,10 @@ SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang, return SelectSectionForGlobal(GV, Kind, Mang, TM); } +bool TargetLoweringObjectFile::isSectionAtomizableBySymbols( + const MCSection &Section) const { + return false; +} // Lame default implementation. Calculate the section name for global. const MCSection * @@ -312,9 +309,11 @@ TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind) const { /// handling information. const MCExpr *TargetLoweringObjectFile::getTTypeGlobalReference( const GlobalValue *GV, unsigned Encoding, Mangler &Mang, - MachineModuleInfo *MMI, MCStreamer &Streamer) const { + const TargetMachine &TM, MachineModuleInfo *MMI, + MCStreamer &Streamer) const { const MCSymbolRefExpr *Ref = - MCSymbolRefExpr::Create(getSymbol(GV, Mang), getContext()); + MCSymbolRefExpr::Create(TM.getTargetLowering()->getSymbol(GV, Mang), + getContext()); return getTTypeReference(Ref, Encoding, Streamer); } |