summaryrefslogtreecommitdiff
path: root/include/llvm
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-02-19 17:23:20 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-02-19 17:23:20 +0000
commit737c9f6005594898eed4746cd310cd161ef209c6 (patch)
tree2990b943f1db8362282b23b6c1d01019f24dd96f /include/llvm
parentcf42174647af5265e35f0e15fbffa17445ae0e80 (diff)
downloadllvm-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 'include/llvm')
-rw-r--r--include/llvm/CodeGen/AsmPrinter.h3
-rw-r--r--include/llvm/CodeGen/TargetLoweringObjectFileImpl.h25
-rw-r--r--include/llvm/IR/Mangler.h7
-rw-r--r--include/llvm/Target/TargetLowering.h6
-rw-r--r--include/llvm/Target/TargetLoweringObjectFile.h36
5 files changed, 48 insertions, 29 deletions
diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h
index 79c7fec3ce..8a46d33171 100644
--- a/include/llvm/CodeGen/AsmPrinter.h
+++ b/include/llvm/CodeGen/AsmPrinter.h
@@ -161,6 +161,9 @@ namespace llvm {
/// getCurrentSection() - Return the current section we are emitting to.
const MCSection *getCurrentSection() const;
+ void getNameWithPrefix(SmallVectorImpl<char> &Name,
+ const GlobalValue *GV) const;
+
MCSymbol *getSymbol(const GlobalValue *GV) const;
//===------------------------------------------------------------------===//
diff --git a/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h b/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
index a2179fb490..d329ddd9a7 100644
--- a/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
+++ b/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
@@ -57,14 +57,15 @@ public:
/// Return an MCExpr to use for a reference to the specified type info global
/// variable from exception handling information.
- const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
- unsigned Encoding, Mangler &Mang,
- MachineModuleInfo *MMI,
- MCStreamer &Streamer) const
+ const MCExpr *
+ getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
+ Mangler &Mang, const TargetMachine &TM,
+ MachineModuleInfo *MMI, MCStreamer &Streamer) const
LLVM_OVERRIDE;
// The symbol that gets passed to .cfi_personality.
MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
+ const TargetMachine &TM,
MachineModuleInfo *MMI) const LLVM_OVERRIDE;
void InitializeELF(bool UseInitArray_);
@@ -90,6 +91,9 @@ public:
Mangler &Mang, const TargetMachine &TM) const
LLVM_OVERRIDE;
+ bool isSectionAtomizableBySymbols(const MCSection &Section) const
+ LLVM_OVERRIDE;
+
const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
SectionKind Kind, Mangler &Mang,
const TargetMachine &TM) const
@@ -105,18 +109,19 @@ public:
/// This hook allows targets to selectively decide not to emit the
/// UsedDirective for some symbols in llvm.used.
/// FIXME: REMOVE this (rdar://7071300)
- bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler &Mang) const
- LLVM_OVERRIDE;
+ bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler &Mang,
+ TargetMachine &TM) const LLVM_OVERRIDE;
/// The mach-o version of this method defaults to returning a stub reference.
- const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
- unsigned Encoding, Mangler &Mang,
- MachineModuleInfo *MMI,
- MCStreamer &Streamer) const
+ const MCExpr *
+ getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
+ Mangler &Mang, const TargetMachine &TM,
+ MachineModuleInfo *MMI, MCStreamer &Streamer) const
LLVM_OVERRIDE;
// The symbol that gets passed to .cfi_personality.
MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
+ const TargetMachine &TM,
MachineModuleInfo *MMI) const LLVM_OVERRIDE;
};
diff --git a/include/llvm/IR/Mangler.h b/include/llvm/IR/Mangler.h
index 07f4feda7e..c1ba5858a6 100644
--- a/include/llvm/IR/Mangler.h
+++ b/include/llvm/IR/Mangler.h
@@ -51,9 +51,10 @@ public:
/// Print the appropriate prefix and the specified global variable's name.
/// If the global variable doesn't have a name, this fills in a unique name
/// for the global.
- void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV) const;
- void getNameWithPrefix(SmallVectorImpl<char> &OutName,
- const GlobalValue *GV) const;
+ void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV,
+ bool CannotUsePrivateLabel) const;
+ void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
+ bool CannotUsePrivateLabel) const;
/// Print the appropriate prefix and the specified name as the global variable
/// name. GVName must not be empty.
diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h
index db4dcb0d1f..0b3428ed7a 100644
--- a/include/llvm/Target/TargetLowering.h
+++ b/include/llvm/Target/TargetLowering.h
@@ -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;
diff --git a/include/llvm/Target/TargetLoweringObjectFile.h b/include/llvm/Target/TargetLoweringObjectFile.h
index 628c010afc..2d9e8d3a2d 100644
--- a/include/llvm/Target/TargetLoweringObjectFile.h
+++ b/include/llvm/Target/TargetLoweringObjectFile.h
@@ -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,