I can use GetElementPtr.getResultElementType() to get struct.hid_device* type of %hid35, but how can I get get the corresponding DICompositeType metadata through this type?
Or if I can get all the metadata of the module, and then search for the target metadata through traversal, but I can’t find a way to get all the metadata.
I don’t believe there’s a direct connection between the two – the type provides data layout information for optimisations during compilation, while the debug-info metadata provides declaration information, field names, line numbers and so forth.
The only connection between the two (as far as I’m aware) is when LLVM records debug-info about variables. The simplest example is that if you declare (in the source language) a global variable then you should find a !dbg attachment to the global from which you can reach a DIGlobalVariableExpression, then DIGlobalVariable, and from there the DICompositeType or other type record.