Hi all, I've a question about something that's bothering me for quite some time now: why is a llvm::Function seen as a llvm::Value (in a sense that llvm::Function is a subclass of llvm::Value), but llvm::Type is not? Should they not - technically seen - be equal? And to ask a concrete question: is there any way to store a reference to a llvm::Type within the LLVM metadata? As far as I know, the MD nodes take only llvm::Values, so I see no way of storing a reference to a type; it would be a nice thing to be able to store such informations, e.g. when using the metadata to store some more user-specific informations about the module. Hope someone has a nice idea about this! Greetings Marcus
On Mon, Mar 26, 2012 at 3:08 PM, Marcus Frenkel <marcus.frenkel at fernuni-hagen.de> wrote:> Hi all, > > I've a question about something that's bothering me for quite some time now: why is a llvm::Function seen as a llvm::Value (in a sense that llvm::Function is a subclass of llvm::Value), but llvm::Type is not? Should they not - technically seen - be equal?llvm::Function is a subclass of llvm::Value because you can use a llvm::Function as a value (of type pointer-to-function). The same is not true for llvm::Type. -Eli
On Tue, Mar 27, 2012 at 01:55 AM, Eli Friedman <eli.friedman at gmail.com> wrote:> On Mon, Mar 26, 2012 at 3:08 PM, Marcus Frenkel > <marcus.frenkel at fernuni-hagen.de> wrote: >> Hi all, >> >> I've a question about something that's bothering me for quite some time now: why is a llvm::Function seen as a llvm::Value (in a sense that llvm::Function is a subclass of llvm::Value), but llvm::Type is not? Should they not - technically seen - be equal? > > llvm::Function is a subclass of llvm::Value because you can use a > llvm::Function as a value (of type pointer-to-function). The same is > not true for llvm::Type.Yeah, I know that (in fact, I hoped to express exactly that ;) ). The question is, why is that so? And how can you store references to llvm::Types in the metadata section of a module? Greetings, Marcus
Hi Marcus,> And to ask a concrete question: is there any way to store a reference to a llvm::Type within the LLVM metadata?Not directly, but you can store a null value (Constant::getNullValue()) of the respective type. Cheers, Clemens -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 6392 bytes Desc: S/MIME Cryptographic Signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120327/d4043471/attachment.bin>
>> And to ask a concrete question: is there any way to store a reference to a llvm::Type within the LLVM metadata? > > Not directly, but you can store a null value (Constant::getNullValue()) > of the respective type. > > Cheers, > ClemensHi Clemens, I thought about this already, yes. It would still require me to know that a specific information in the metadata refers to a type (which originally I wanted to avoid), but I guess it can't be helped and I have to implement it that way. So long, Marcus
Apparently Analagous Threads
- [LLVMdev] llvm::Type as llvm::Value in metadata
- [LLVMdev] llvm::Type as llvm::Value in metadata
- [LLVMdev] llvm::Type as llvm::Value in metadata
- [LLVMdev] Problem with linking modules which use a shared type
- [LLVMdev] Problem with linking modules which use a shared type