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
This commit is contained in:
Rafael Espindola
2014-02-19 17:23:20 +00:00
parent cf42174647
commit 737c9f6005
35 changed files with 377 additions and 173 deletions

View File

@@ -48,8 +48,10 @@ namespace llvm {
class MachineFunction;
class MachineInstr;
class MachineJumpTableInfo;
class Mangler;
class MCContext;
class MCExpr;
class MCSymbol;
template<typename T> class SmallVectorImpl;
class DataLayout;
class TargetRegisterClass;
@@ -1343,6 +1345,10 @@ public:
return LibcallCallingConvs[Call];
}
void getNameWithPrefix(SmallVectorImpl<char> &Name, const GlobalValue *GV,
Mangler &Mang, bool MayAlwaysUsePrivate = false) const;
MCSymbol *getSymbol(const GlobalValue *GV, Mangler &Mang) const;
private:
const TargetMachine &TM;
const DataLayout *DL;

View File

@@ -71,8 +71,8 @@ public:
/// This hook allows targets to selectively decide not to emit the
/// UsedDirective for some symbols in llvm.used.
/// FIXME: REMOVE this (rdar://7071300)
virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
Mangler &Mang) const {
virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler &Mang,
TargetMachine &TM) const {
return GV != 0;
}
@@ -117,25 +117,22 @@ public:
/// Return an MCExpr to use for a reference to the specified global variable
/// from exception handling information.
virtual const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
unsigned Encoding,
Mangler &Mang,
MachineModuleInfo *MMI,
MCStreamer &Streamer) const;
/// Return the MCSymbol for the specified global value. This symbol is the
/// main label that is the address of the global
MCSymbol *getSymbol(const GlobalValue *GV, Mangler &M) const;
virtual const MCExpr *
getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
Mangler &Mang, const TargetMachine &TM,
MachineModuleInfo *MMI, MCStreamer &Streamer) const;
/// Return the MCSymbol for a private symbol with global value name as its
/// base, with the specified suffix.
MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV,
StringRef Suffix, Mangler &M) const;
StringRef Suffix, Mangler &Mang,
const TargetMachine &TM) const;
// The symbol that gets passed to .cfi_personality.
virtual MCSymbol *
getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
MachineModuleInfo *MMI) const;
virtual MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
Mangler &Mang,
const TargetMachine &TM,
MachineModuleInfo *MMI) const;
const MCExpr *
getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
@@ -157,10 +154,17 @@ public:
virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
virtual const MCExpr *
getExecutableRelativeSymbol(const ConstantExpr *CE, Mangler &Mang) const {
getExecutableRelativeSymbol(const ConstantExpr *CE, Mangler &Mang,
const TargetMachine &TM) const {
return 0;
}
/// \brief True if the section is atomized using the symbols in it.
/// This is false if the section is not atomized at all (most ELF sections) or
/// if it is atomized based on its contents (MachO' __TEXT,__cstring for
/// example).
virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const;
protected:
virtual const MCSection *
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,