Skip to content

Commit 1ca5fdc

Browse files
committed
Fix failing tests
Changes the `printSwitchToSection()` to be more HLASM-ish, and updates the test cases. That was necessary because the emitted name has changed. However, zos-landingpad.ll is still failing due to a bug.
1 parent c7fcda9 commit 1ca5fdc

File tree

11 files changed

+82
-64
lines changed

11 files changed

+82
-64
lines changed

llvm/include/llvm/MC/MCContext.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,7 @@ class MCContext {
621621
GOFF::PRAttr PRAttributes);
622622
// Create a section with root-SD/ED/LD symbols.
623623
MCSectionGOFF *getGOFFSection(SectionKind Kind, StringRef EDName,
624-
GOFF::EDAttr EDAttributes,
625-
StringRef LDorPRName,
624+
GOFF::EDAttr EDAttributes, StringRef LDorPRName,
626625
GOFF::LDAttr LDAttributes);
627626
// Create a section with root-SD/ED/PR symbols.
628627
MCSectionGOFF *getGOFFSection(SectionKind Kind, StringRef EDName,

llvm/include/llvm/MC/MCSectionGOFF.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,18 @@ class MCSectionGOFF final : public MCSection {
5757
GOFF::LDAttr LDAttributes, GOFF::PRAttr PRAttributes)
5858
: MCSection(SV_GOFF, SynName, K.isText(), /*IsVirtual=*/false, nullptr),
5959
SDName(SDName), EDName(EDName), LDorPRName(LDorPRName),
60-
SDAttributes(SDAttributes), EDAttributes(EDAttributes), Flags(Flags) {}
60+
SDAttributes(SDAttributes), EDAttributes(EDAttributes),
61+
LDAttributes(LDAttributes), PRAttributes(PRAttributes), Flags(Flags) {}
6162

6263
public:
6364
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
6465
raw_ostream &OS,
6566
uint32_t /*Subsection*/) const override {
66-
OS << "\t.section\t\"" << getName() << "\"\n";
67+
if (!usesRootSD())
68+
OS << getSDName() << " CSECT\n";
69+
OS << getEDName() << " CATTR\n";
70+
if ((hasLD() || hasPR()) && !getLDorPRName().empty())
71+
OS << getLDorPRName() << " XATTR\n";
6772
}
6873

6974
bool useCodeAlign() const override { return false; }

llvm/lib/MC/GOFFObjectWriter.cpp

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
#include "llvm/BinaryFormat/GOFF.h"
1414
#include "llvm/MC/MCAssembler.h"
15-
#include "llvm/MC/MCGOFFObjectWriter.h"
1615
#include "llvm/MC/MCGOFFAttributes.h"
16+
#include "llvm/MC/MCGOFFObjectWriter.h"
1717
#include "llvm/MC/MCSectionGOFF.h"
1818
#include "llvm/MC/MCValue.h"
1919
#include "llvm/Support/Casting.h"
@@ -310,67 +310,71 @@ class GOFFWriter {
310310
GOFFWriter::GOFFWriter(raw_pwrite_stream &OS, MCAssembler &Asm)
311311
: OS(OS), Asm(Asm) {}
312312

313-
GOFFSymbol GOFFWriter::createGOFFSymbol(StringRef Name, const GOFF::SDAttr &Attr) {
313+
GOFFSymbol GOFFWriter::createGOFFSymbol(StringRef Name,
314+
const GOFF::SDAttr &Attr) {
314315
return GOFFSymbol(Name, ++EsdIdCounter, Attr);
315316
}
316317

317-
GOFFSymbol GOFFWriter::createGOFFSymbol(StringRef Name, const GOFF::EDAttr &Attr,
318+
GOFFSymbol GOFFWriter::createGOFFSymbol(StringRef Name,
319+
const GOFF::EDAttr &Attr,
318320
uint32_t ParentEsdId) {
319321
return GOFFSymbol(Name, ++EsdIdCounter, ParentEsdId, Attr);
320322
}
321323

322-
GOFFSymbol GOFFWriter::createGOFFSymbol(StringRef Name, const GOFF::LDAttr &Attr,
324+
GOFFSymbol GOFFWriter::createGOFFSymbol(StringRef Name,
325+
const GOFF::LDAttr &Attr,
323326
uint32_t ParentEsdId) {
324327
return GOFFSymbol(Name, ++EsdIdCounter, ParentEsdId, Attr);
325328
}
326329

327-
GOFFSymbol GOFFWriter::createGOFFSymbol(StringRef Name, const GOFF::PRAttr &Attr,
330+
GOFFSymbol GOFFWriter::createGOFFSymbol(StringRef Name,
331+
const GOFF::PRAttr &Attr,
328332
uint32_t ParentEsdId) {
329333
return GOFFSymbol(Name, ++EsdIdCounter, ParentEsdId, Attr);
330334
}
331335

332336
void GOFFWriter::defineSectionSymbols(const MCSectionGOFF &Section) {
333-
uint32_t SDEsdId = RootSDEsdId;
334-
if (!Section.usesRootSD()) {
335-
GOFFSymbol SD =
336-
createGOFFSymbol(Section.getSDName(), Section.getSDAttributes());
337-
SDEsdId = SD.EsdId;
338-
if (RootSDEsdId == 0)
339-
RootSDEsdId = SDEsdId;
340-
writeSymbol(SD);
341-
}
337+
uint32_t SDEsdId = RootSDEsdId;
338+
if (!Section.usesRootSD()) {
339+
GOFFSymbol SD =
340+
createGOFFSymbol(Section.getSDName(), Section.getSDAttributes());
341+
SDEsdId = SD.EsdId;
342+
if (RootSDEsdId == 0)
343+
RootSDEsdId = SDEsdId;
344+
writeSymbol(SD);
345+
}
342346

343-
GOFFSymbol ED = createGOFFSymbol(Section.getEDName(),
344-
Section.getEDAttributes(), SDEsdId);
345-
if ((!Section.hasLD() && !Section.hasPR()) || Section.hasLD()) {
346-
ED.SectionLength = Asm.getSectionAddressSize(Section);
347-
}
348-
writeSymbol(ED);
349-
350-
if (Section.hasLD()) {
351-
GOFFSymbol LD = createGOFFSymbol(Section.getLDorPRName(),
352-
Section.getLDAttributes(), ED.EsdId);
353-
if (Section.isText())
354-
LD.ADAEsdId = ADAEsdId;
355-
writeSymbol(LD);
356-
}
347+
GOFFSymbol ED =
348+
createGOFFSymbol(Section.getEDName(), Section.getEDAttributes(), SDEsdId);
349+
if ((!Section.hasLD() && !Section.hasPR()) || Section.hasLD()) {
350+
ED.SectionLength = Asm.getSectionAddressSize(Section);
351+
}
352+
writeSymbol(ED);
353+
354+
if (Section.hasLD()) {
355+
GOFFSymbol LD = createGOFFSymbol(Section.getLDorPRName(),
356+
Section.getLDAttributes(), ED.EsdId);
357+
if (Section.isText())
358+
LD.ADAEsdId = ADAEsdId;
359+
writeSymbol(LD);
360+
}
357361

358-
if (Section.hasPR()) {
359-
GOFFSymbol PR = createGOFFSymbol(Section.getLDorPRName(),
360-
Section.getPRAttributes(), ED.EsdId);
361-
PR.SectionLength = Asm.getSectionAddressSize(Section);
362-
if (&Section == ADA) {
363-
// We cannot have a zero-length section for data. If we do,
364-
// artificially inflate it. Use 2 bytes to avoid odd alignments. Note:
365-
// if this is ever changed, you will need to update the code in
366-
// SystemZAsmPrinter::emitCEEMAIN and SystemZAsmPrinter::emitCELQMAIN to
367-
// generate -1 if there is no ADA
368-
if (!PR.SectionLength)
369-
PR.SectionLength = 2;
370-
ADAEsdId = PR.EsdId;
371-
}
372-
writeSymbol(PR);
362+
if (Section.hasPR()) {
363+
GOFFSymbol PR = createGOFFSymbol(Section.getLDorPRName(),
364+
Section.getPRAttributes(), ED.EsdId);
365+
PR.SectionLength = Asm.getSectionAddressSize(Section);
366+
if (&Section == ADA) {
367+
// We cannot have a zero-length section for data. If we do,
368+
// artificially inflate it. Use 2 bytes to avoid odd alignments. Note:
369+
// if this is ever changed, you will need to update the code in
370+
// SystemZAsmPrinter::emitCEEMAIN and SystemZAsmPrinter::emitCELQMAIN to
371+
// generate -1 if there is no ADA
372+
if (!PR.SectionLength)
373+
PR.SectionLength = 2;
374+
ADAEsdId = PR.EsdId;
373375
}
376+
writeSymbol(PR);
377+
}
374378
}
375379

376380
void GOFFWriter::defineSymbols() {

llvm/lib/MC/MCObjectFileInfo.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ void MCObjectFileInfo::initGOFFMCObjectFileInfo(const Triple &T) {
552552
GOFF::EDAttr{true, GOFF::ESD_EXE_CODE, GOFF::AMODE, GOFF::RMODE,
553553
GOFF::ESD_NS_NormalName, GOFF::ESD_TS_ByteOriented,
554554
GOFF::ESD_BA_Concatenate, GOFF::ESD_LB_Initial,
555-
GOFF::ESD_RQ_0, GOFF::ESD_ALIGN_Doubleword}, "",
555+
GOFF::ESD_RQ_0, GOFF::ESD_ALIGN_Doubleword},
556+
"#C",
556557
GOFF::LDAttr{false, GOFF::ESD_EXE_CODE, GOFF::ESD_NS_NormalName,
557558
GOFF::ESD_BST_Strong, GOFF::LINKAGE, GOFF::AMODE,
558559
GOFF::ESD_BSC_Section});
@@ -569,13 +570,13 @@ void MCObjectFileInfo::initGOFFMCObjectFileInfo(const Triple &T) {
569570
GOFF::ESD_DSS_NoWarning, GOFF::ESD_ALIGN_Doubleword, 0});
570571

571572
ADASection = Ctx->getGOFFSection(
572-
SectionKind::getData(), "",
573+
SectionKind::getData(), "#C",
573574
GOFF::SDAttr{GOFF::ESD_TA_Rent, GOFF::ESD_BSC_Section}, GOFF::CLASS_WSA,
574575
GOFF::EDAttr{false, GOFF::ESD_EXE_DATA, GOFF::AMODE, GOFF::RMODE,
575576
GOFF::ESD_NS_Parts, GOFF::ESD_TS_ByteOriented,
576577
GOFF::ESD_BA_Merge, GOFF::ESD_LB_Deferred, GOFF::ESD_RQ_1,
577578
GOFF::ESD_ALIGN_Quadword},
578-
"",
579+
"#S",
579580
GOFF::PRAttr{false, false, GOFF::ESD_EXE_DATA, GOFF::ESD_NS_Parts,
580581
GOFF::ESD_LT_XPLink, GOFF::AMODE, GOFF::ESD_BSC_Section,
581582
GOFF::ESD_DSS_NoWarning, GOFF::ESD_ALIGN_Quadword, 0});

llvm/test/CodeGen/SystemZ/zos-ada-relocations.ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ entry:
5555

5656
declare signext i32 @callout(i32 signext)
5757

58-
; CHECK: .section ".ada"
58+
; CHECK: #C CSECT
59+
; CHECK: C_WSA64 CATTR
60+
; CHECK: #S XATTR
5961
; CHECK: .set L#DoFunc@indirect0, DoFunc
6062
; CHECK: .indirect_symbol L#DoFunc@indirect0
6163
; CHECK: .quad V(L#DoFunc@indirect0) * Offset 0 pointer to function descriptor DoFunc

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ declare double @llvm.sin.f64(double)
3030
declare fp128 @llvm.exp2.f128(fp128)
3131

3232
; Check the calls in the ADA.
33-
; CHECK: .section ".ada"
33+
; CHECK: #C CSECT
34+
; CHECK: C_WSA64 CATTR
35+
; CHECK: #S XATTR
3436

3537
; Check that there is no call to sqrt.
3638
; CHECK-NOT: .quad R(@@WSQT@B)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ lpad:
3737
; CHECK: Personality routine
3838
; CHECK: LSDA location
3939
; Check that the exception table is emitted into .lsda section.
40-
; CHECK: .section ".gcc_exception_table.test1"
40+
; CHECK: C_WSA64 CATTR
41+
; CHECK: GCC_except_table0 XATTR
4142
; CHECK: GCC_except_table0:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: llc -mtriple s390x-ibm-zos -mcpu=z15 -asm-verbose=true < %s | FileCheck %s
22

3-
; CHECK: .section ".ppa2"
3+
; CHECK: C_CODE64 CATTR
44
; CHECK: L#PPA2:
55
; CHECK: .byte 3
66
; CHECK: .byte 231
@@ -19,7 +19,7 @@
1919
; CHECK: .quad L#PPA2-CELQSTRT * A(PPA2-CELQSTRT)
2020
; CHECK: L#PPA1_void_test_0:
2121
; CHECK: .long L#PPA2-L#PPA1_void_test_0 * Offset to PPA2
22-
; CHECK: .section ".idrl"
22+
; CHECK: B_IDRL CATTR
2323
; CHECK: .byte 0
2424
; CHECK: .byte 3
2525
; CHECK: .short 30

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
@a = global i32 0, align 4
66

77
define signext i32 @main() {
8-
; CHECK: .section ".text"
8+
; CHECK: C_CODE64 CATTR
9+
; CHECK: #C XATTR
910
; CHECK: main:
10-
; CHECK: .section "a"
11+
; CHECK: a CSECT
12+
; CHECK: C_WSA64 CATTR
13+
; CHECK: a XATTR
1114
entry:
1215
ret i32 0
1316
}

llvm/test/MC/GOFF/empty-goff.s

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* 03 is prefix byte
1818
* 4. is header type
1919
* .0 is version
20-
* CHECK: 000050 03 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00
21-
* CHECK: 000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
22-
* CHECK: 000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
23-
* CHECK: 000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
24-
* CHECK: 000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
20+
* CHECK: {{([[:xdigit:]]{6})}} 03 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00
21+
* CHECK: {{([[:xdigit:]]{6})}} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
22+
* CHECK: {{([[:xdigit:]]{6})}} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
23+
* CHECK: {{([[:xdigit:]]{6})}} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
24+
* CHECK: {{([[:xdigit:]]{6})}} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

0 commit comments

Comments
 (0)