https://github.com/amy-kwan updated https://github.com/llvm/llvm-project/pull/183443
>From d2154271ce73d0c3345f798cc0741fe05a777814 Mon Sep 17 00:00:00 2001 From: Amy Kwan <[email protected]> Date: Wed, 25 Feb 2026 23:21:18 -0500 Subject: [PATCH] [SystemZ] Emit external aliases for indirect function descriptors in the ADA section This is the last of the three patches aimed to support indirect symbol handling for the SystemZ backend. An external alias is emitted for indirect function descriptors within the ADA section, rather than a temporary alias, while also setting all of the appropriate symbol attributes that are needed for the HLASM streamer to emit the correct XATTR and ALIAS instructions for the indirect symbols. Moreover, this patch updates the `CodeGen/SystemZ/zos-ada-relocations.ll` test as the ADA section is currently the only user of indirect symbols on z/OS. --- llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp | 11 +++++++---- llvm/test/CodeGen/SystemZ/zos-ada-relocations.ll | 6 +++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp index 58c8b30f96b4c..cb451a1ca4f55 100644 --- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp +++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp @@ -1275,12 +1275,15 @@ void SystemZAsmPrinter::emitADASection() { EmittedBytes += PointerSize; break; case SystemZII::MO_ADA_INDIRECT_FUNC_DESC: { - MCSymbol *Alias = OutContext.createTempSymbol( + MCSymbol *Alias = OutContext.getOrCreateSymbol( Twine(Sym->getName()).concat("@indirect")); - OutStreamer->emitAssignment(Alias, - MCSymbolRefExpr::create(Sym, OutContext)); OutStreamer->emitSymbolAttribute(Alias, MCSA_IndirectSymbol); - + OutStreamer->emitSymbolAttribute(Alias, MCSA_ELF_TypeFunction); + OutStreamer->emitSymbolAttribute(Alias, MCSA_Global); + OutStreamer->emitSymbolAttribute(Alias, MCSA_Extern); + MCSymbolGOFF *GOFFSym = + static_cast<llvm::MCSymbolGOFF *>(const_cast<llvm::MCSymbol *>(Sym)); + getTargetStreamer()->emitExternalName(Alias, GOFFSym->getExternalName()); EMIT_COMMENT("pointer to function descriptor"); OutStreamer->emitValue( MCSpecifierExpr::create(MCSymbolRefExpr::create(Alias, OutContext), diff --git a/llvm/test/CodeGen/SystemZ/zos-ada-relocations.ll b/llvm/test/CodeGen/SystemZ/zos-ada-relocations.ll index f3bdf64683bb6..dd12226049ed9 100644 --- a/llvm/test/CodeGen/SystemZ/zos-ada-relocations.ll +++ b/llvm/test/CodeGen/SystemZ/zos-ada-relocations.ll @@ -60,7 +60,7 @@ declare signext i32 @callout(i32 signext) ; CHECK: in#S) ; CHECK: stdin#S XATTR LINKAGE(XPLINK),REFERENCE(DATA),SCOPE(SECTION) ; CHECK: * Offset 0 pointer to function descriptor DoFunc -; CHECK: DC VD(L#DoFunc@indirect0) +; CHECK: DC VD(DoFunc@indirect) ; CHECK: * Offset 8 function descriptor of Caller ; CHECK: DC RD(Caller) ; CHECK: DC VD(Caller) @@ -71,3 +71,7 @@ declare signext i32 @callout(i32 signext) ; CHECK: * Offset 40 function descriptor of callout ; CHECK: DC RD(callout) ; CHECK: DC VD(callout) +; CHECK: EXTRN DoFunc@indirect +; CHECK: DoFunc@indirect XATTR LINKAGE(XPLINK),REFERENCE(CODE,INDIRECT),SCOPE(EX +; CHECK: PORT) +; CHECK: DoFunc@indirect ALIAS "DoFunc" _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
