[llvm] [SystemZ][zOS] Override emitGlobalAlias for ADA (PR #84829)

Neumann Hon via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 12 12:33:25 PDT 2024


================
@@ -1026,17 +1027,15 @@ void SystemZAsmPrinter::emitADASection() {
       EmittedBytes += PointerSize;
       break;
     case SystemZII::MO_ADA_INDIRECT_FUNC_DESC: {
-      MCSymbol *Alias = OutContext.createTempSymbol(
-          Twine(Sym->getName()).concat("@indirect"));
-      OutStreamer->emitAssignment(Alias,
-                                  MCSymbolRefExpr::create(Sym, OutContext));
-      OutStreamer->emitSymbolAttribute(Alias, MCSA_IndirectSymbol);
+      MCSymbolGOFF *IndirectSym =
+          static_cast<MCSymbolGOFF *>(OutContext.getOrCreateSymbol(
+              Twine(Sym->getName()).concat("@indirect")));
----------------
Everybody0523 wrote:

One of the issues is that using the alias construct isn't entirely accurate. If Symbol A aliases Symbol B, then uses of A can (and are) be replaced by uses of B.

However, this isn't really the case here. The `MO_ADA_INDIRECT_FUNC_DESC` here means that we have a symbol that has a value containing the location of the function descriptor of the symbol it points to. 

![onno_art_is_hard](https://github.com/llvm/llvm-project/assets/22278196/463325c8-738b-4837-b648-a5fec8945998)

What we want to do here is to create a new symbol that points to a location in the ADA. That location contains the offset in the ADA to the location where the original symbol's ADA entry resides.

The GOFF writer creates an external reference (ErWx) symbol to represent this newly-created symbol in our symbol table (Specifically, the "external symbol dictionary"). This new symbol will have the same name as the original symbol, and that name is used by the binder to associate it back to the original symbol's address).

https://github.com/llvm/llvm-project/pull/84829


More information about the llvm-commits mailing list