[PATCH] D78793: Names for structs are held on the Context, not the Module. Move getTypeByName from Module to Type taking a Context parameter.

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 30 13:56:59 PST 2020


dexonsmith added subscribers: arsenm, dblaikie.
dexonsmith added a comment.

@nicholas, I missed this when it was reviewed, but seeing it now that you've landed it.

Can you help me understand if there's a deeper motivation than the one in the patch description? I ask because I would have envisioned eventually moving these "named" types to the module (i.e., keep the old API before your change, but change the implementation to make sense of it).

In particular, it would be nice if LLVMContext were restricted to types / values / metadata that are purely functional, and anything non-functional or open to interpretation is put on the Module.

- For values and metadata, this requires some significant work (I have some concrete ideas of how, but it seems quite tangential to this patch).
- For types, this could be done as a very simple follow-up to the opaque pointer work (@dblaikie @arsenm, not sure if you have thoughts). The `Type` class would be purely functional, and the struct names would move to a symbol table in each `Module`. The name is not inherent to the type, it's just a handle that some module wants to use to refer to it (the type itself can be shared between modules even if they disagree about what to call it).

One benefit of this hypothetical change is that we could change everything in `LLVMContext` to be immutable, potentially using lock-free data structures, etc.; I think that would open up some interesting possibilities.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78793



More information about the llvm-commits mailing list