[PATCH] D115749: [WebAssembly] Emit symbol labels for table global symbols

Paulo Matos via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 11 09:26:02 PST 2022


pmatos added inline comments.


================
Comment at: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp:202
+    // If the GlobalVariable refers to a table, we handle it here instead of
+    // in emitExternalDecls
+    if (Sym->isTable()) 
----------------
sbc100 wrote:
> pmatos wrote:
> > sbc100 wrote:
> > > Are you saying that for undefined/external tables we call `emitTableType` elsewhere?   IIUC the table type needs to be declared ragardless of whether the table has a definition (hasInitializer()) or not, right?
> > > 
> > > This comment seems a little odd to me given that the code below doesn't just handle table symbols.
> > Yes, so if the table is extern it's `tabletype` is emitted in `emitExternDecls`. If it's a global defined in the current compilation unit, then it needs to be emitted here.  That's what I was trying to say with my comment, but maybe I need to be more precise.
> > 
> > Regarding the mention of `hasInitializer()`, I am unsure how to actually test this. I haven't managed to create a table as a global that doesn't enter the condition, i.e. without an initializer. Do you have a suggestion?
> I'm not sure... with globals and functions and data symbols you just skip the label, and that makes them externally defined (i.e. without an initializer).
> 
> It could be that for some reason we don't support that yet, but maybe thats a case for anther CL?
we might be talking about different things when referring to globals. Sorry. Just to clarify. You are referring to globals in asm, as far as I understand. I am referring to globals in LLVM IR. Tables are implemented as LLVM IR globals (https://llvm.org/docs/LangRef.html#global-variables) . 

If I define a table as an LLVM IR global, the question is, what asm directives are needed to define that table. I would think we need just `.tabletype` and the label to actually allocate the table symbol. At the moment, all tables start by being initialized with `undef` in IR. However, that might mean that at the asm level they always have an initializer.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115749/new/

https://reviews.llvm.org/D115749



More information about the llvm-commits mailing list