Skip to content

Commit 5d522fd

Browse files
committed
More work on reviewer comments
Most comments are resolved except: - I kept the RootSDSection variable - The attributes are not yet in a union - I still need to extend the unique section key for hashmap
1 parent 682f07b commit 5d522fd

File tree

13 files changed

+47
-50
lines changed

13 files changed

+47
-50
lines changed

llvm/include/llvm/MC/MCContext.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -624,14 +624,11 @@ class MCContext {
624624

625625
public:
626626
MCSectionGOFF *getGOFFSection(SectionKind Kind, StringRef Name,
627-
GOFF::SDAttr SDAttributes,
628-
MCSection *Parent = nullptr);
627+
GOFF::SDAttr SDAttributes);
629628
MCSectionGOFF *getGOFFSection(SectionKind Kind, StringRef Name,
630-
GOFF::EDAttr EDAttributes,
631-
MCSection *Parent = nullptr);
629+
GOFF::EDAttr EDAttributes, MCSection *Parent);
632630
MCSectionGOFF *getGOFFSection(SectionKind Kind, StringRef Name,
633-
GOFF::PRAttr PRAttributes,
634-
MCSection *Parent = nullptr);
631+
GOFF::PRAttr PRAttributes, MCSection *Parent);
635632

636633
MCSectionCOFF *getCOFFSection(StringRef Section, unsigned Characteristics,
637634
StringRef COMDATSymName, int Selection,

llvm/include/llvm/MC/MCGOFFStreamer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ namespace llvm {
1616
class GOFFObjectWriter;
1717

1818
class MCGOFFStreamer : public MCObjectStreamer {
19-
std::string RootSDName;
20-
std::string ADAPRName;
2119

2220
public:
2321
MCGOFFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,

llvm/include/llvm/MC/MCObjectFileInfo.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,8 @@ class MCObjectFileInfo {
231231

232232
// GOFF specific sections.
233233
MCSection *RootSDSection = nullptr;
234-
MCSection *PPA2ListEDSection = nullptr;
235-
MCSection *PPA2ListPRSection = nullptr;
236-
MCSection *ADAEDSection = nullptr;
237-
MCSection *ADAPRSection = nullptr;
234+
MCSection *PPA2ListSection = nullptr;
235+
MCSection *ADASection = nullptr;
238236
MCSection *IDRLSection = nullptr;
239237

240238
// XCOFF specific sections
@@ -439,11 +437,8 @@ class MCObjectFileInfo {
439437
MCSection *getGLJMPSection() const { return GLJMPSection; }
440438

441439
// GOFF specific sections.
442-
MCSection *getRootSDSection() const { return RootSDSection; }
443-
MCSection *getPPA2ListEDSection() const { return PPA2ListEDSection; }
444-
MCSection *getPPA2ListSection() const { return PPA2ListPRSection; }
445-
MCSection *getADAEDSection() const { return ADAEDSection; }
446-
MCSection *getADASection() const { return ADAPRSection; }
440+
MCSection *getPPA2ListSection() const { return PPA2ListSection; }
441+
MCSection *getADASection() const { return ADASection; }
447442
MCSection *getIDRLSection() const { return IDRLSection; }
448443

449444
// XCOFF specific sections

llvm/include/llvm/MC/MCSectionGOFF.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ class MCSectionGOFF final : public MCSection {
3737
// The type of this section.
3838
GOFF::ESDSymbolType SymbolType;
3939

40-
// Indicates that the ED symbol needs to set the length of the section.
41-
unsigned RequiresLength : 1;
42-
4340
// Indicates that the PR symbol needs to set the length of the section to a
44-
// non-zero value.
41+
// non-zero value. This is only a problem with the ADA PR - the binder will
42+
// generate an error in this case.
4543
unsigned RequiresNonZeroLength : 1;
4644

4745
friend class MCContext;
@@ -55,16 +53,17 @@ class MCSectionGOFF final : public MCSection {
5553
public:
5654
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
5755
raw_ostream &OS,
58-
uint32_t /*Subsection*/) const override {
59-
;
56+
uint32_t Subsection) const override {
6057
switch (SymbolType) {
6158
case GOFF::ESD_ST_SectionDefinition:
6259
OS << Name << " CSECT\n";
6360
break;
6461
case GOFF::ESD_ST_ElementDefinition:
62+
getParent()->printSwitchToSection(MAI, T, OS, Subsection);
6563
OS << Name << " CATTR\n";
6664
break;
6765
case GOFF::ESD_ST_PartReference:
66+
getParent()->printSwitchToSection(MAI, T, OS, Subsection);
6867
OS << Name << " XATTR\n";
6968
break;
7069
default:
@@ -101,7 +100,7 @@ class MCSectionGOFF final : public MCSection {
101100
return PRAttributes;
102101
}
103102

104-
bool requiresLength() const { return RequiresLength; }
103+
void setRequiresNonZeroLength() { RequiresNonZeroLength = true; }
105104
bool requiresNonZeroLength() const { return RequiresNonZeroLength; }
106105

107106
void setName(StringRef SectionName) { Name = SectionName; }

llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#include "llvm/Support/CodeGen.h"
6767
#include "llvm/Support/ErrorHandling.h"
6868
#include "llvm/Support/Format.h"
69+
#include "llvm/Support/Path.h"
6970
#include "llvm/Support/raw_ostream.h"
7071
#include "llvm/Target/TargetMachine.h"
7172
#include "llvm/TargetParser/Triple.h"
@@ -2763,12 +2764,15 @@ TargetLoweringObjectFileGOFF::TargetLoweringObjectFileGOFF() = default;
27632764

27642765
void TargetLoweringObjectFileGOFF::getModuleMetadata(Module &M) {
27652766
// Construct the default names for the root SD and the ADA PR symbol.
2766-
DefaultRootSDName = Twine(M.getSourceFileName()).concat("#C").str();
2767-
DefaultADAPRName = Twine(M.getSourceFileName()).concat("#S").str();
2767+
StringRef FileName = sys::path::stem(M.getSourceFileName());
2768+
DefaultRootSDName = Twine(FileName).concat("#C").str();
2769+
DefaultADAPRName = Twine(FileName).concat("#S").str();
27682770
MCSectionGOFF *RootSD = static_cast<MCSectionGOFF *>(RootSDSection);
2769-
MCSectionGOFF *ADAPR = static_cast<MCSectionGOFF *>(ADAPRSection);
2771+
MCSectionGOFF *ADAPR = static_cast<MCSectionGOFF *>(ADASection);
27702772
RootSD->setName(DefaultRootSDName);
27712773
ADAPR->setName(DefaultADAPRName);
2774+
// The length of the ADA needs to be adjusted in case it is 0.
2775+
ADAPR->setRequiresNonZeroLength();
27722776
// Initialize the label for the text section.
27732777
MCSymbolGOFF *TextLD = static_cast<MCSymbolGOFF *>(
27742778
getContext().getOrCreateSymbol(RootSD->getName()));

llvm/lib/MC/GOFFObjectWriter.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,7 @@ void GOFFWriter::defineSectionSymbols(const MCSectionGOFF &Section) {
308308
if (Section.isED()) {
309309
GOFFSymbol ED(Section.getName(), Section.getId(),
310310
Section.getParent()->getId(), Section.getEDAttributes());
311-
if (Section.requiresLength())
312-
ED.SectionLength = Asm.getSectionAddressSize(Section);
311+
ED.SectionLength = Asm.getSectionAddressSize(Section);
313312
writeSymbol(ED);
314313
}
315314

@@ -331,7 +330,9 @@ void GOFFWriter::defineSectionSymbols(const MCSectionGOFF &Section) {
331330
}
332331

333332
void GOFFWriter::defineLabel(const MCSymbolGOFF &Symbol) {
334-
GOFFSymbol LD(Symbol.getName(), ++EsdIdCounter, 0, Symbol.getLDAttributes());
333+
GOFFSymbol LD(Symbol.getName(), ++EsdIdCounter,
334+
static_cast<MCSectionGOFF &>(Symbol.getSection()).getId(),
335+
Symbol.getLDAttributes());
335336
if (Symbol.getADA())
336337
LD.ADAEsdId = Symbol.getADA()->getId();
337338
writeSymbol(LD);
@@ -351,6 +352,7 @@ void GOFFWriter::defineSymbols() {
351352
continue;
352353
auto &Symbol = cast<MCSymbolGOFF>(Sym);
353354
if (Symbol.hasLDAttributes()) {
355+
defineLabel(Symbol);
354356
}
355357
}
356358
}

llvm/lib/MC/MCContext.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,9 @@ MCContext::getGOFFSection(SectionKind Kind, GOFF::ESDSymbolType SymbolType,
694694
}
695695

696696
MCSectionGOFF *MCContext::getGOFFSection(SectionKind Kind, StringRef Name,
697-
GOFF::SDAttr SDAttributes,
698-
MCSection *Parent) {
697+
GOFF::SDAttr SDAttributes) {
699698
return getGOFFSection(Kind, GOFF::ESD_ST_SectionDefinition, Name,
700-
SDAttributes, GOFF::EDAttr{}, GOFF::PRAttr{}, Parent);
699+
SDAttributes, GOFF::EDAttr{}, GOFF::PRAttr{}, nullptr);
701700
}
702701

703702
MCSectionGOFF *MCContext::getGOFFSection(SectionKind Kind, StringRef Name,
@@ -710,8 +709,8 @@ MCSectionGOFF *MCContext::getGOFFSection(SectionKind Kind, StringRef Name,
710709
MCSectionGOFF *MCContext::getGOFFSection(SectionKind Kind, StringRef Name,
711710
GOFF::PRAttr PRAttributes,
712711
MCSection *Parent) {
713-
return getGOFFSection(Kind, GOFF::ESD_ST_SectionDefinition, Name,
714-
GOFF::SDAttr{}, GOFF::EDAttr{}, PRAttributes, Parent);
712+
return getGOFFSection(Kind, GOFF::ESD_ST_PartReference, Name, GOFF::SDAttr{},
713+
GOFF::EDAttr{}, PRAttributes, Parent);
715714
}
716715

717716
MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,

llvm/lib/MC/MCGOFFStreamer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void MCGOFFStreamer::initSections(bool /*NoExecStack*/,
3131
const MCSubtargetInfo &STI) {
3232
MCContext &Ctx = getContext();
3333
// Emit the text section.
34+
switchSection(Ctx.getObjectFileInfo()->getADASection());
3435
switchSection(Ctx.getObjectFileInfo()->getTextSection());
3536
}
3637

@@ -41,7 +42,7 @@ void registerSectionHierarchy(MCAssembler &Asm, MCSectionGOFF *Section) {
4142
return;
4243
if (Section->getParent())
4344
registerSectionHierarchy(Asm, Section->getParent());
44-
registerSectionHierarchy(Asm, Section);
45+
Asm.registerSection(*Section);
4546
}
4647
} // namespace
4748

llvm/lib/MC/MCObjectFileInfo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,14 +551,14 @@ void MCObjectFileInfo::initGOFFMCObjectFileInfo(const Triple &T) {
551551
SectionKind::getMetadata(), "#C",
552552
GOFF::SDAttr{GOFF::ESD_TA_Rent, GOFF::ESD_BSC_Section});
553553

554-
ADAEDSection = Ctx->getGOFFSection(
554+
MCSectionGOFF *ADAEDSection = Ctx->getGOFFSection(
555555
SectionKind::getMetadata(), GOFF::CLASS_WSA,
556556
GOFF::EDAttr{false, GOFF::ESD_EXE_DATA, GOFF::AMODE, GOFF::RMODE,
557557
GOFF::ESD_NS_Parts, GOFF::ESD_TS_ByteOriented,
558558
GOFF::ESD_BA_Merge, GOFF::ESD_LB_Deferred, GOFF::ESD_RQ_1,
559559
GOFF::ESD_ALIGN_Quadword},
560560
RootSDSection);
561-
ADAPRSection = Ctx->getGOFFSection(
561+
ADASection = Ctx->getGOFFSection(
562562
SectionKind::getData(), "#S",
563563
GOFF::PRAttr{false, false, GOFF::ESD_EXE_DATA, GOFF::ESD_NS_Parts,
564564
GOFF::ESD_LT_XPLink, GOFF::AMODE, GOFF::ESD_BSC_Section,
@@ -573,14 +573,14 @@ void MCObjectFileInfo::initGOFFMCObjectFileInfo(const Triple &T) {
573573
GOFF::ESD_RQ_0, GOFF::ESD_ALIGN_Doubleword},
574574
RootSDSection);
575575

576-
PPA2ListEDSection = Ctx->getGOFFSection(
576+
MCSectionGOFF *PPA2ListEDSection = Ctx->getGOFFSection(
577577
SectionKind::getMetadata(), GOFF::CLASS_PPA2,
578578
GOFF::EDAttr{true, GOFF::ESD_EXE_DATA, GOFF::AMODE, GOFF::RMODE,
579579
GOFF::ESD_NS_Parts, GOFF::ESD_TS_ByteOriented,
580580
GOFF::ESD_BA_Merge, GOFF::ESD_LB_Initial, GOFF::ESD_RQ_0,
581581
GOFF::ESD_ALIGN_Doubleword},
582582
RootSDSection);
583-
PPA2ListPRSection = Ctx->getGOFFSection(
583+
PPA2ListSection = Ctx->getGOFFSection(
584584
SectionKind::getData(), ".&ppa2",
585585
GOFF::PRAttr{true, false, GOFF::ESD_EXE_Unspecified, GOFF::ESD_NS_Parts,
586586
GOFF::ESD_LT_OS, GOFF::AMODE, GOFF::ESD_BSC_Section,

llvm/test/CodeGen/SystemZ/zos-landingpad.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ lpad:
3737
; CHECK: Personality routine
3838
; CHECK: LSDA location
3939
; Check that the exception table is emitted into .lsda section.
40-
; CHECK: C_WSA64 CATTR
41-
; CHECK: GCC_except_table0 XATTR
40+
; CHECK: <stdin>#C CSECT
41+
; CHECK: C_WSA64 CATTR
42+
; CHECK: .gcc_exception_table.test1 XATTR
4243
; CHECK: GCC_except_table0:

0 commit comments

Comments
 (0)