[GOFF] Set reference to ADA (#179734)
Function symbols must have a reference to the ADA, because this becomes the value of the r5 register when the function is called. Simply get the value from the begin symbol of the section.
This commit is contained in:
@@ -43,6 +43,7 @@ public:
|
||||
: MCSymbol(Name, IsTemporary) {}
|
||||
|
||||
void setADA(MCSectionGOFF *AssociatedDataArea) {
|
||||
assert(AssociatedDataArea && "ADA must be non-null");
|
||||
ADA = AssociatedDataArea;
|
||||
AssociatedDataArea->RequiresNonZeroLength = true;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/MC/MCAsmInfoGOFF.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/BinaryFormat/GOFF.h"
|
||||
#include "llvm/MC/MCSectionGOFF.h"
|
||||
#include "llvm/MC/MCSymbolGOFF.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
@@ -83,17 +85,21 @@ static void emitCATTR(raw_ostream &OS, StringRef Name, GOFF::ESDRmode Rmode,
|
||||
OS << '\n';
|
||||
}
|
||||
|
||||
static void emitXATTR(raw_ostream &OS, StringRef Name,
|
||||
static void emitXATTR(raw_ostream &OS, StringRef Name, MCSectionGOFF *ADA,
|
||||
GOFF::ESDLinkageType Linkage,
|
||||
GOFF::ESDExecutable Executable,
|
||||
GOFF::ESDBindingScope BindingScope) {
|
||||
llvm::ListSeparator Sep(",");
|
||||
OS << Name << " XATTR ";
|
||||
OS << "LINKAGE(" << (Linkage == GOFF::ESD_LT_OS ? "OS" : "XPLINK") << "),";
|
||||
OS << Sep << "LINKAGE(" << (Linkage == GOFF::ESD_LT_OS ? "OS" : "XPLINK")
|
||||
<< ")";
|
||||
if (Executable != GOFF::ESD_EXE_Unspecified)
|
||||
OS << "REFERENCE(" << (Executable == GOFF::ESD_EXE_CODE ? "CODE" : "DATA")
|
||||
<< "),";
|
||||
OS << Sep << "REFERENCE("
|
||||
<< (Executable == GOFF::ESD_EXE_CODE ? "CODE" : "DATA") << ")";
|
||||
if (ADA)
|
||||
OS << Sep << "PSECT(" << ADA->getName() << ")";
|
||||
if (BindingScope != GOFF::ESD_BSC_Unspecified) {
|
||||
OS << "SCOPE(";
|
||||
OS << Sep << "SCOPE(";
|
||||
switch (BindingScope) {
|
||||
case GOFF::ESD_BSC_Section:
|
||||
OS << "SECTION";
|
||||
@@ -138,6 +144,12 @@ void MCAsmInfoGOFF::printSwitchToSection(const MCSection &Section,
|
||||
Sec.EDAttributes.Alignment, Sec.EDAttributes.LoadBehavior,
|
||||
GOFF::ESD_EXE_Unspecified, Sec.EDAttributes.IsReadOnly, 0,
|
||||
Sec.EDAttributes.FillByteValue, StringRef());
|
||||
if (auto *BeginSym = static_cast<MCSymbolGOFF *>(Sec.getBeginSymbol())) {
|
||||
if (BeginSym->getADA())
|
||||
emitXATTR(OS, BeginSym->getName(), BeginSym->getADA(),
|
||||
GOFF::ESD_LT_XPLink, GOFF::ESD_EXE_Unspecified,
|
||||
GOFF::ESD_BSC_Section);
|
||||
}
|
||||
Sec.Emitted = true;
|
||||
EmitExternalName();
|
||||
} else
|
||||
@@ -153,7 +165,11 @@ void MCAsmInfoGOFF::printSwitchToSection(const MCSection &Section,
|
||||
Sec.PRAttributes.Executable, ED->EDAttributes.IsReadOnly,
|
||||
Sec.PRAttributes.SortKey, ED->EDAttributes.FillByteValue,
|
||||
Sec.getName());
|
||||
emitXATTR(OS, Sec.getName(), Sec.PRAttributes.Linkage,
|
||||
MCSectionGOFF *ADA =
|
||||
Sec.getBeginSymbol() != nullptr
|
||||
? static_cast<MCSymbolGOFF *>(Sec.getBeginSymbol())->getADA()
|
||||
: nullptr;
|
||||
emitXATTR(OS, Sec.getName(), ADA, Sec.PRAttributes.Linkage,
|
||||
Sec.PRAttributes.Executable, Sec.PRAttributes.BindingScope);
|
||||
ED->Emitted = true;
|
||||
Sec.Emitted = true;
|
||||
|
||||
@@ -193,8 +193,8 @@ void SystemZHLASMAsmStreamer::emitInstruction(const MCInst &Inst,
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
static void emitXATTR(raw_ostream &OS, StringRef Name, bool IsIndirectReference,
|
||||
GOFF::ESDLinkageType Linkage,
|
||||
static void emitXATTR(raw_ostream &OS, StringRef Name, MCSectionGOFF *ADA,
|
||||
bool IsIndirectReference, GOFF::ESDLinkageType Linkage,
|
||||
GOFF::ESDExecutable Executable,
|
||||
GOFF::ESDBindingScope BindingScope) {
|
||||
llvm::ListSeparator Sep(",");
|
||||
@@ -215,6 +215,8 @@ static void emitXATTR(raw_ostream &OS, StringRef Name, bool IsIndirectReference,
|
||||
|
||||
OS << ")";
|
||||
}
|
||||
if (ADA)
|
||||
OS << Sep << "PSECT(" << ADA->getName() << ")";
|
||||
if (BindingScope != GOFF::ESD_BSC_Unspecified) {
|
||||
OS << Sep << "SCOPE(";
|
||||
switch (BindingScope) {
|
||||
@@ -255,8 +257,8 @@ void SystemZHLASMAsmStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
emitXATTR(OS, Sym->getName(), Sym->isIndirect(), Sym->getLinkage(),
|
||||
Sym->getCodeData(), Sym->getBindingScope());
|
||||
emitXATTR(OS, Sym->getName(), Sym->getADA(), Sym->isIndirect(),
|
||||
Sym->getLinkage(), Sym->getCodeData(), Sym->getBindingScope());
|
||||
EmitEOL();
|
||||
if (Sym->hasExternalName())
|
||||
OS << Sym->getName() << " ALIAS C'" << Sym->getExternalName() << "'\n";
|
||||
@@ -367,8 +369,8 @@ void SystemZHLASMAsmStreamer::finishImpl() {
|
||||
auto &Sym = static_cast<MCSymbolGOFF &>(const_cast<MCSymbol &>(Symbol));
|
||||
OS << " " << (Sym.isWeak() ? "WXTRN" : "EXTRN") << " " << Sym.getName();
|
||||
EmitEOL();
|
||||
emitXATTR(OS, Sym.getName(), Sym.isIndirect(), Sym.getLinkage(),
|
||||
Sym.getCodeData(), Sym.getBindingScope());
|
||||
emitXATTR(OS, Sym.getName(), Sym.getADA(), Sym.isIndirect(),
|
||||
Sym.getLinkage(), Sym.getCodeData(), Sym.getBindingScope());
|
||||
EmitEOL();
|
||||
if (Sym.hasExternalName())
|
||||
OS << Sym.getName() << " ALIAS C'" << Sym.getExternalName() << "'\n";
|
||||
|
||||
@@ -67,6 +67,8 @@ public:
|
||||
const MCSymbol *Lo) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void emitADA(MCSymbol *Sym, MCSection *Section) {}
|
||||
};
|
||||
|
||||
class SystemZTargetGOFFStreamer : public SystemZTargetStreamer {
|
||||
@@ -80,6 +82,10 @@ public:
|
||||
virtual void emitExternalName(MCSection *Sec, StringRef Name) override {
|
||||
static_cast<MCSectionGOFF *>(Sec)->setExternalName(Name);
|
||||
}
|
||||
void emitADA(MCSymbol *Sym, MCSection *Section) override {
|
||||
static_cast<MCSymbolGOFF *>(Sym)->setADA(
|
||||
static_cast<MCSectionGOFF *>(Section));
|
||||
}
|
||||
};
|
||||
|
||||
class SystemZTargetHLASMStreamer : public SystemZTargetStreamer {
|
||||
@@ -97,6 +103,10 @@ public:
|
||||
virtual void emitExternalName(MCSection *Sec, StringRef Name) override {
|
||||
static_cast<MCSectionGOFF *>(Sec)->setExternalName(Name);
|
||||
}
|
||||
void emitADA(MCSymbol *Sym, MCSection *Section) override {
|
||||
static_cast<MCSymbolGOFF *>(Sym)->setADA(
|
||||
static_cast<MCSectionGOFF *>(Section));
|
||||
}
|
||||
};
|
||||
|
||||
class SystemZTargetELFStreamer : public SystemZTargetStreamer {
|
||||
|
||||
@@ -1925,6 +1925,9 @@ void SystemZAsmPrinter::emitFunctionEntryLabel() {
|
||||
OutStreamer->AddComment(" Bit 2: 0 = Does not use alloca");
|
||||
}
|
||||
OutStreamer->emitInt32(DSAAndFlags);
|
||||
|
||||
getTargetStreamer()->emitADA(CurrentFnSym,
|
||||
getObjFileLowering().getADASection());
|
||||
}
|
||||
|
||||
AsmPrinter::emitFunctionEntryLabel();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
; RUN: llc < %s -mtriple=s390x-ibm-zos | FileCheck %s
|
||||
|
||||
; CHECK: ENTRY foo
|
||||
; CHECK-NEXT: foo XATTR LINKAGE(XPLINK),REFERENCE(CODE),SCOPE(LIBRARY)
|
||||
; CHECK-NEXT: foo XATTR LINKAGE(XPLINK),REFERENCE(CODE),PSECT(stdin#S),SCOPE(LIBRARY)
|
||||
; CHECK-NEXT: foo DS 0H
|
||||
; CHECK-NEXT: ENTRY foo
|
||||
; CHECK-NEXT: foo1 XATTR LINKAGE(XPLINK),REFERENCE(CODE),SCOPE(LIBRARY)
|
||||
|
||||
@@ -116,7 +116,7 @@ entry:
|
||||
; The name is me.
|
||||
; CHECK-NEXT: 000370 03 00 00 02 [[ME:00 00 00 0a]] [[C_CODE64]] 00 00 00 00
|
||||
; CHECK-NEXT: 000380 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
; CHECK-NEXT: 000390 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
|
||||
; CHECK-NEXT: 000390 00 00 00 00 00 00 00 00 01 00 00 00 [[TESTS]]
|
||||
; CHECK-NEXT: 0003a0 00 00 00 00 00 00 00 00 00 00 00 00 04 00 00 02
|
||||
; CHECK-NEXT: 0003b0 00 04 20 00 00 00 00 02 94 85 00 00 00 00 00 00
|
||||
|
||||
|
||||
@@ -20,14 +20,18 @@ entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: stdin#C CSECT
|
||||
; CHECK-NEXT: C_CODE64 CATTR ALIGN(3),FILL(0),READONLY,RMODE(64)
|
||||
; CHECK-NEXT: stdin#C XATTR LINKAGE(XPLINK),PSECT(stdin#S),SCOPE(SECTION)
|
||||
|
||||
; CHECK: ENTRY me1
|
||||
; CHECK-NEXT: me1 XATTR LINKAGE(XPLINK),REFERENCE(CODE),SCOPE(SECTION)
|
||||
; CHECK-NEXT: me1 XATTR LINKAGE(XPLINK),REFERENCE(CODE),PSECT(stdin#S),SCOPE(SECTION)
|
||||
|
||||
; CHECK: ENTRY me2
|
||||
; CHECK-NEXT: me2 XATTR LINKAGE(XPLINK),REFERENCE(CODE),SCOPE(LIBRARY)
|
||||
; CHECK-NEXT: me2 XATTR LINKAGE(XPLINK),REFERENCE(CODE),PSECT(stdin#S),SCOPE(LIBRARY)
|
||||
|
||||
; CHECK: ENTRY me3
|
||||
; CHECK-NEXT: me3 XATTR LINKAGE(XPLINK),REFERENCE(CODE),SCOPE(EXPORT)
|
||||
; CHECK-NEXT: me3 XATTR LINKAGE(XPLINK),REFERENCE(CODE),PSECT(stdin#S),SCOPE(EXPORT)
|
||||
|
||||
; CHECK: EXTRN CELQSTRT
|
||||
; CHECK-NEXT: CELQSTRT XATTR LINKAGE(OS),SCOPE(EXPORT)
|
||||
|
||||
@@ -19,7 +19,7 @@ entry:
|
||||
|
||||
; Check the attributes on the function
|
||||
; CHECK: ENTRY calc
|
||||
; CHECK-NEXT: calc XATTR LINKAGE(XPLINK),REFERENCE(CODE),SCOPE(EXPORT)
|
||||
; CHECK-NEXT: calc XATTR LINKAGE(XPLINK),REFERENCE(CODE),PSECT(stdin#S),SCOPE(EXPORT)
|
||||
; CHECK-NEXT: calc DS 0H
|
||||
|
||||
; Check the definition of the variable
|
||||
|
||||
Reference in New Issue
Block a user