I’d like to figure out a clean way to annotate LLVM types with additional information. This is related to the garbage collection discussion - I’d like to figure out a good way to do this, so I can add it to the proposal.
Basically what I want is to be able to take a Constant and associate it with a type, such that (1) any backend pass that has a reference to the type can quickly and efficiently get a reference to the associated Constant, and (2) this information can be serialized into a bitcode file along with the rest of the module contents. (By “quickly and efficiently” I mean that a backend pass should be able to do a test on every value in a given module and check to see if there associated data with that value’s type, and not significantly affect compilation time.)
For garbage collection, I’d use this feature to annotate each type with it’s trace table - basically it’s the same information that I pass to llvm.gcroot() today, but associated with a type rather than with a value.
However, I would imagine other uses for this facility. What this effectively is “metadata for types”, although unlike metadata nodes this data would be immutable.
Also, it’s OK if the solution requires changes to LLVM, as long as it doesn’t significantly impact performance for people who aren’t using this feature.