llvm.org GIT mirror llvm / 80664e5
Add a variable to track whether or not we've used a unique section, e.g. linkonce, to TargetMachine and set it when we've done so for ELF targets currently. This involved making TargetMachine non-const in a TLOF use and propagating that change around - I'm open to other ideas. This will be used in a future commit to handle emitting debug information with ranges. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199871 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Christopher 6 years ago
14 changed file(s) with 38 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
5252
5353 virtual const MCSection *
5454 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
55 Mangler *Mang, const TargetMachine &TM) const;
55 Mangler *Mang, TargetMachine &TM) const;
5656
5757 /// getTTypeGlobalReference - Return an MCExpr to use for a reference to the
5858 /// specified type info global variable from exception handling information.
9191
9292 virtual const MCSection *
9393 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
94 Mangler *Mang, const TargetMachine &TM) const;
94 Mangler *Mang, TargetMachine &TM) const;
9595
9696 virtual const MCSection *
9797 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
130130
131131 virtual const MCSection *
132132 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
133 Mangler *Mang, const TargetMachine &TM) const;
133 Mangler *Mang, TargetMachine &TM) const;
134134
135135 /// getDepLibFromLinkerOpt - Extract the dependent library name from a linker
136136 /// option string. Returns StringRef() if the option does not specify a library.
3737 const DataLayout *DL;
3838
3939 TargetLoweringObjectFile(
40 const TargetLoweringObjectFile&) LLVM_DELETED_FUNCTION;
40 const TargetLoweringObjectFile &) LLVM_DELETED_FUNCTION;
4141 void operator=(const TargetLoweringObjectFile&) LLVM_DELETED_FUNCTION;
4242
4343 public:
9090 /// be passed external (or available externally) globals.
9191 const MCSection *SectionForGlobal(const GlobalValue *GV,
9292 SectionKind Kind, Mangler *Mang,
93 const TargetMachine &TM) const;
93 TargetMachine &TM) const;
9494
9595 /// SectionForGlobal - This method computes the appropriate section to emit
9696 /// the specified global variable or function definition. This should not
9797 /// be passed external (or available externally) globals.
9898 const MCSection *SectionForGlobal(const GlobalValue *GV,
9999 Mangler *Mang,
100 const TargetMachine &TM) const {
100 TargetMachine &TM) const {
101101 return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM);
102102 }
103103
166166 protected:
167167 virtual const MCSection *
168168 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
169 Mangler *Mang, const TargetMachine &TM) const;
169 Mangler *Mang, TargetMachine &TM) const;
170170 };
171171
172172 } // end namespace llvm
8787 unsigned MCUseLoc : 1;
8888 unsigned MCUseCFI : 1;
8989 unsigned MCUseDwarfDirectory : 1;
90 unsigned DebugUseUniqueSections : 1;
9091 unsigned RequireStructuredCFG : 1;
9192
9293 public:
159160 bool requiresStructuredCFG() const { return RequireStructuredCFG; }
160161 void setRequiresStructuredCFG(bool Value) { RequireStructuredCFG = Value; }
161162
163 bool debugUseUniqueSections() const { return DebugUseUniqueSections; }
164 void setDebugUseUniqueSections(bool Value) { DebugUseUniqueSections = Value; }
165
162166 /// hasMCRelaxAll - Check whether all machine code instructions should be
163167 /// relaxed.
164168 bool hasMCRelaxAll() const { return MCRelaxAll; }
231231
232232 const MCSection *TargetLoweringObjectFileELF::
233233 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
234 Mangler *Mang, const TargetMachine &TM) const {
234 Mangler *Mang, TargetMachine &TM) const {
235235 // If we have -ffunction-section or -fdata-section then we should emit the
236236 // global value to a uniqued section specifically for it.
237237 bool EmitUniquedSection;
257257 Flags |= ELF::SHF_GROUP;
258258 }
259259
260 // Set that we've used a unique section name in the target machine.
261 TM.setDebugUseUniqueSections(true);
260262 return getContext().getELFSection(Name.str(),
261263 getELFSectionType(Name.str(), Kind),
262264 Flags, Kind, 0, Group);
528530
529531 const MCSection *TargetLoweringObjectFileMachO::
530532 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
531 Mangler *Mang, const TargetMachine &TM) const {
533 Mangler *Mang, TargetMachine &TM) const {
532534
533535 // Handle thread local data.
534536 if (Kind.isThreadBSS()) return TLSBSSSection;
753755
754756 const MCSection *TargetLoweringObjectFileCOFF::
755757 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
756 Mangler *Mang, const TargetMachine &TM) const {
758 Mangler *Mang, TargetMachine &TM) const {
757759
758760 // If this global is linkonce/weak and the target handles this by emitting it
759761 // into a 'uniqued' section name, create and return the section now.
8686
8787 const MCSection *HexagonTargetObjectFile::
8888 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
89 Mangler *Mang, const TargetMachine &TM) const {
89 Mangler *Mang, TargetMachine &TM) const {
9090
9191 // Handle Small Section classification here.
9292 if (Kind.isBSS() && IsGlobalInSmallSection(GV, TM, Kind))
2929 const TargetMachine &TM) const;
3030
3131 bool IsSmallDataEnabled () const;
32 const MCSection* SelectSectionForGlobal(const GlobalValue *GV,
33 SectionKind Kind,
34 Mangler *Mang,
35 const TargetMachine &TM) const;
32 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
33 SectionKind Kind, Mangler *Mang,
34 TargetMachine &TM) const;
3635 };
3736
3837 } // namespace llvm
102102
103103 const MCSection *MipsTargetObjectFile::
104104 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
105 Mangler *Mang, const TargetMachine &TM) const {
105 Mangler *Mang, TargetMachine &TM) const {
106106 // TODO: Could also support "weak" symbols as well with ".gnu.linkonce.s.*"
107107 // sections?
108108
3030 const TargetMachine &TM) const;
3131
3232 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
33 SectionKind Kind,
34 Mangler *Mang,
35 const TargetMachine &TM) const;
33 SectionKind Kind, Mangler *Mang,
34 TargetMachine &TM) const;
3635
3736 // TODO: Classify globals as mips wishes.
3837 const MCSection *getReginfoSection() const { return ReginfoSection; }
2323
2424 const MCSection * PPC64LinuxTargetObjectFile::
2525 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
26 Mangler *Mang, const TargetMachine &TM) const {
26 Mangler *Mang, TargetMachine &TM) const {
2727
2828 const MCSection *DefaultSection =
2929 TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, Mang, TM);
2121
2222 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
2323
24 virtual const MCSection *
25 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
26 Mangler *Mang, const TargetMachine &TM) const;
24 virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
25 SectionKind Kind,
26 Mangler *Mang,
27 TargetMachine &TM) const;
2728
2829 /// \brief Describe a TLS variable address within debug info.
2930 virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
264264 /// be passed external (or available externally) globals.
265265 const MCSection *TargetLoweringObjectFile::
266266 SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang,
267 const TargetMachine &TM) const {
267 TargetMachine &TM) const {
268268 // Select section name.
269269 if (GV->hasSection())
270270 return getExplicitSectionGlobal(GV, Kind, Mang, TM);
276276
277277
278278 // Lame default implementation. Calculate the section name for global.
279 const MCSection *
280 TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
281 SectionKind Kind,
282 Mangler *Mang,
283 const TargetMachine &TM) const{
279 const MCSection *TargetLoweringObjectFile::SelectSectionForGlobal(
280 const GlobalValue *GV, SectionKind Kind, Mangler *Mang,
281 TargetMachine &TM) const {
284282 assert(!Kind.isThreadLocal() && "Doesn't support TLS");
285283
286284 if (Kind.isText())
5454 MCUseLoc(true),
5555 MCUseCFI(true),
5656 MCUseDwarfDirectory(false),
57 DebugUseUniqueSections(false),
5758 RequireStructuredCFG(false),
5859 Options(Options) {
5960 }
129129
130130 const MCSection *XCoreTargetObjectFile::
131131 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang,
132 const TargetMachine &TM) const{
132 TargetMachine &TM) const{
133133 if (Kind.isText()) return TextSection;
134134 if (Kind.isMergeable1ByteCString()) return CStringSection;
135135 if (Kind.isMergeableConst4()) return MergeableConst4Section;
2626 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
2727 Mangler *Mang, const TargetMachine &TM) const;
2828
29 virtual const MCSection *
30 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
31 Mangler *Mang, const TargetMachine &TM) const;
29 virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
30 SectionKind Kind,
31 Mangler *Mang,
32 TargetMachine &TM) const;
3233
3334 virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
3435 };