[llvm] [Xtensa] Lower GlobalAddress/BlockAddress/JumpTable (PR #95256)

Andrei Safronov via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 17 16:09:36 PDT 2024


================
@@ -52,16 +64,25 @@ void XtensaAsmPrinter::emitMachineConstantPoolValue(
   XtensaConstantPoolValue *ACPV = static_cast<XtensaConstantPoolValue *>(MCPV);
   MCSymbol *MCSym;
 
-  assert(ACPV->isExtSymbol() && "unrecognized constant pool value");
+  if (ACPV->isBlockAddress()) {
+    const BlockAddress *BA =
+        cast<XtensaConstantPoolConstant>(ACPV)->getBlockAddress();
+    MCSym = GetBlockAddressSymbol(BA);
+  } else if (ACPV->isJumpTable()) {
+    unsigned Idx = cast<XtensaConstantPoolJumpTable>(ACPV)->getIndex();
+    MCSym = this->GetJTISymbol(Idx, false);
+  } else {
+    assert(ACPV->isExtSymbol() && "unrecognized constant pool value");
+    XtensaConstantPoolSymbol *XtensaSym = cast<XtensaConstantPoolSymbol>(ACPV);
+    const char *Sym = XtensaSym->getSymbol();
+    std::string SymName(Sym);
 
-  XtensaConstantPoolSymbol *XtensaSym = cast<XtensaConstantPoolSymbol>(ACPV);
-  const char *Sym = XtensaSym->getSymbol();
-  std::string SymName(Sym);
+    if (XtensaSym->isPrivateLinkage())
+      SymName = ".L" + SymName;
 
-  if (XtensaSym->isPrivateLinkage())
-    SymName = ".L" + SymName;
+    MCSym = GetExternalSymbolSymbol(StringRef(SymName));
----------------
andreisfr wrote:

I substituted GetExternalSymbolSymbol to getOrCreateSymbol, hope I understood proposed solution correctly.

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


More information about the llvm-commits mailing list