llvm.org GIT mirror llvm / 84acf09
Revert r224935 "Refactor duplicated code. No intended functionality change." This is affecting the behavior of some ObjC++ / AArch64 test cases on Darwin. Reverting to get the bots green while I track down the source of the changed behavior. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225311 91177308-0d34-0410-b5e6-96231b3b80d8 Lang Hames 5 years ago
15 changed file(s) with 104 addition(s) and 74 deletion(s). Raw diff Collapse all Expand all
8888 ArrayRef ModuleFlags,
8989 Mangler &Mang, const TargetMachine &TM) const override;
9090
91 bool isSectionAtomizableBySymbols(const MCSection &Section) const override;
92
9193 const MCSection *
9294 SelectSectionForGlobal(const GlobalValue *GV,
9395 SectionKind Kind, Mangler &Mang,
6464 /// all symbols (even temporaries) have symbol table entries.
6565 virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
6666 return false;
67 }
68
69 /// isSectionAtomizable - Check whether the given section can be split into
70 /// atoms.
71 ///
72 /// \see MCAssembler::isSymbolLinkerVisible().
73 virtual bool isSectionAtomizable(const MCSection &Section) const {
74 return true;
6775 }
6876
6977 /// @name Target Fixup Interfaces
381381 return nullptr;
382382 }
383383
384 /// \brief True if the section is atomized using the symbols in it.
385 /// This is false if the section is not atomized at all (most ELF sections) or
386 /// if it is atomized based on its contents (MachO' __TEXT,__cstring for
387 /// example).
388 virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const;
389
390384 virtual const MCExpr *getExprForPersonalitySymbol(const MCSymbol *Sym,
391385 unsigned Encoding,
392386 MCStreamer &Streamer) const;
1818
1919 namespace llvm {
2020 class MCAsmInfoDarwin : public MCAsmInfo {
21 virtual void anchor();
2122 public:
2223 explicit MCAsmInfoDarwin();
23 bool isSectionAtomizableBySymbols(const MCSection &Section) const override;
2424 };
2525 }
2626
150150 return nullptr;
151151 }
152152
153 /// \brief True if the section is atomized using the symbols in it.
154 /// This is false if the section is not atomized at all (most ELF sections) or
155 /// if it is atomized based on its contents (MachO' __TEXT,__cstring for
156 /// example).
157 virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const;
158
153159 protected:
154160 virtual const MCSection *
155161 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
572572 return S;
573573 }
574574
575 bool TargetLoweringObjectFileMachO::isSectionAtomizableBySymbols(
576 const MCSection &Section) const {
577 const MCSectionMachO &SMO = static_cast(Section);
578
579 // Sections holding 1 byte strings are atomized based on the data
580 // they contain.
581 // Sections holding 2 byte strings require symbols in order to be
582 // atomized.
583 // There is no dedicated section for 4 byte strings.
584 if (SMO.getKind().isMergeable1ByteCString())
585 return false;
586
587 if (SMO.getSegmentName() == "__TEXT" &&
588 SMO.getSectionName() == "__objc_classname" &&
589 SMO.getType() == MachO::S_CSTRING_LITERALS)
590 return false;
591
592 if (SMO.getSegmentName() == "__TEXT" &&
593 SMO.getSectionName() == "__objc_methname" &&
594 SMO.getType() == MachO::S_CSTRING_LITERALS)
595 return false;
596
597 if (SMO.getSegmentName() == "__TEXT" &&
598 SMO.getSectionName() == "__objc_methtype" &&
599 SMO.getType() == MachO::S_CSTRING_LITERALS)
600 return false;
601
602 if (SMO.getSegmentName() == "__DATA" &&
603 SMO.getSectionName() == "__cfstring")
604 return false;
605
606 // no_dead_strip sections are not atomized in practice.
607 if (SMO.hasAttribute(MachO::S_ATTR_NO_DEAD_STRIP))
608 return false;
609
610 switch (SMO.getType()) {
611 default:
612 return true;
613
614 // These sections are atomized at the element boundaries without using
615 // symbols.
616 case MachO::S_4BYTE_LITERALS:
617 case MachO::S_8BYTE_LITERALS:
618 case MachO::S_16BYTE_LITERALS:
619 case MachO::S_LITERAL_POINTERS:
620 case MachO::S_NON_LAZY_SYMBOL_POINTERS:
621 case MachO::S_LAZY_SYMBOL_POINTERS:
622 case MachO::S_MOD_INIT_FUNC_POINTERS:
623 case MachO::S_MOD_TERM_FUNC_POINTERS:
624 case MachO::S_INTERPOSING:
625 return false;
626 }
627 }
628
575629 const MCSection *TargetLoweringObjectFileMachO::
576630 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
577631 Mangler &Mang, const TargetMachine &TM) const {
108108 MCAsmInfo::~MCAsmInfo() {
109109 }
110110
111 bool MCAsmInfo::isSectionAtomizableBySymbols(const MCSection &Section) const {
112 return false;
113 }
114
115111 const MCExpr *
116112 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
117113 unsigned Encoding,
1414 #include "llvm/MC/MCAsmInfoDarwin.h"
1515 #include "llvm/MC/MCContext.h"
1616 #include "llvm/MC/MCExpr.h"
17 #include "llvm/MC/MCSectionMachO.h"
1817 #include "llvm/MC/MCStreamer.h"
1918 using namespace llvm;
2019
21 bool MCAsmInfoDarwin::isSectionAtomizableBySymbols(
22 const MCSection &Section) const {
23 const MCSectionMachO &SMO = static_cast(Section);
24
25 // Sections holding 1 byte strings are atomized based on the data they
26 // contain.
27 // Sections holding 2 byte strings require symbols in order to be atomized.
28 // There is no dedicated section for 4 byte strings.
29 if (SMO.getKind().isMergeable1ByteCString())
30 return false;
31
32 if (SMO.getSegmentName() == "__TEXT" &&
33 SMO.getSectionName() == "__objc_classname" &&
34 SMO.getType() == MachO::S_CSTRING_LITERALS)
35 return false;
36
37 if (SMO.getSegmentName() == "__TEXT" &&
38 SMO.getSectionName() == "__objc_methname" &&
39 SMO.getType() == MachO::S_CSTRING_LITERALS)
40 return false;
41
42 if (SMO.getSegmentName() == "__TEXT" &&
43 SMO.getSectionName() == "__objc_methtype" &&
44 SMO.getType() == MachO::S_CSTRING_LITERALS)
45 return false;
46
47 if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring")
48 return false;
49
50 // no_dead_strip sections are not atomized in practice.
51 if (SMO.hasAttribute(MachO::S_ATTR_NO_DEAD_STRIP))
52 return false;
53
54 switch (SMO.getType()) {
55 default:
56 return true;
57
58 // These sections are atomized at the element boundaries without using
59 // symbols.
60 case MachO::S_4BYTE_LITERALS:
61 case MachO::S_8BYTE_LITERALS:
62 case MachO::S_16BYTE_LITERALS:
63 case MachO::S_LITERAL_POINTERS:
64 case MachO::S_NON_LAZY_SYMBOL_POINTERS:
65 case MachO::S_LAZY_SYMBOL_POINTERS:
66 case MachO::S_MOD_INIT_FUNC_POINTERS:
67 case MachO::S_MOD_TERM_FUNC_POINTERS:
68 case MachO::S_INTERPOSING:
69 return false;
70 }
71 }
20 void MCAsmInfoDarwin::anchor() { }
7221
7322 MCAsmInfoDarwin::MCAsmInfoDarwin() {
7423 // Common settings for all Darwin targets.
1111 #include "llvm/ADT/StringExtras.h"
1212 #include "llvm/ADT/Twine.h"
1313 #include "llvm/MC/MCAsmBackend.h"
14 #include "llvm/MC/MCAsmInfo.h"
1514 #include "llvm/MC/MCAsmLayout.h"
1615 #include "llvm/MC/MCCodeEmitter.h"
1716 #include "llvm/MC/MCContext.h"
448447
449448 // Non-linker visible symbols in sections which can't be atomized have no
450449 // defining atom.
451 if (!getContext().getAsmInfo()->isSectionAtomizableBySymbols(
452 SD->getFragment()->getParent()->getSection()))
450 if (!getBackend().isSectionAtomizable(
451 SD->getFragment()->getParent()->getSection()))
453452 return nullptr;
454453
455454 // Otherwise, return the atom for the containing fragment.
2020 namespace llvm {
2121
2222 class ARMMCAsmInfoDarwin : public MCAsmInfoDarwin {
23 virtual void anchor();
24
23 void anchor() override;
2524 public:
2625 explicit ARMMCAsmInfoDarwin(StringRef TT);
2726 };
2020 class Triple;
2121
2222 class PPCMCAsmInfoDarwin : public MCAsmInfoDarwin {
23 virtual void anchor();
24
23 void anchor() override;
2524 public:
2625 explicit PPCMCAsmInfoDarwin(bool is64Bit, const Triple&);
2726 };
269269 return SelectSectionForGlobal(GV, Kind, Mang, TM);
270270 }
271271
272 bool TargetLoweringObjectFile::isSectionAtomizableBySymbols(
273 const MCSection &Section) const {
274 return false;
275 }
276
277
272278 /// getSectionForConstant - Given a mergable constant with the
273279 /// specified size and relocation information, return a section that it
274280 /// should be placed in.
181181 const TargetLoweringObjectFile &TLOF =
182182 getSubtargetImpl()->getTargetLowering()->getObjFileLowering();
183183 const MCSection *TheSection = TLOF.SectionForGlobal(GV, GVKind, Mang, *this);
184 bool CannotUsePrivateLabel =
185 AsmInfo->isSectionAtomizableBySymbols(*TheSection);
184 bool CannotUsePrivateLabel = TLOF.isSectionAtomizableBySymbols(*TheSection);
186185 Mang.getNameWithPrefix(Name, GV, CannotUsePrivateLabel);
187186 }
188187
789789 return SMO.getType() == MachO::S_CSTRING_LITERALS;
790790 }
791791
792 bool isSectionAtomizable(const MCSection &Section) const override {
793 const MCSectionMachO &SMO = static_cast(Section);
794 // Fixed sized data sections are uniqued, they cannot be diced into atoms.
795 switch (SMO.getType()) {
796 default:
797 return true;
798
799 case MachO::S_4BYTE_LITERALS:
800 case MachO::S_8BYTE_LITERALS:
801 case MachO::S_16BYTE_LITERALS:
802 case MachO::S_LITERAL_POINTERS:
803 case MachO::S_NON_LAZY_SYMBOL_POINTERS:
804 case MachO::S_LAZY_SYMBOL_POINTERS:
805 case MachO::S_MOD_INIT_FUNC_POINTERS:
806 case MachO::S_MOD_TERM_FUNC_POINTERS:
807 case MachO::S_INTERPOSING:
808 return false;
809 }
810 }
811
792812 /// \brief Generate the compact unwind encoding for the CFI instructions.
793813 uint32_t generateCompactUnwindEncoding(
794814 ArrayRef Instrs) const override {
2222 class Triple;
2323
2424 class X86MCAsmInfoDarwin : public MCAsmInfoDarwin {
25 virtual void anchor();
26
25 void anchor() override;
2726 public:
2827 explicit X86MCAsmInfoDarwin(const Triple &Triple);
2928 };