[LLVMdev] Associating types directly with debug metadata?

Devang Patel dpatel at apple.com
Wed Sep 29 10:05:12 PDT 2010


On Sep 29, 2010, at 4:30 AM, Pekka Nikander wrote:

> We would need to access the LLVM debug metadata type information directly from LLVM types.  It looks like the current clang and llvm-gcc don't support such an association, nor appears the LLVM itself do.

True. I am curious how do you want to use this association ? 
> 
> Then the type would probably need to be added to a new named metadata tag as well, maybe !llvm.dbg.ty?

This is a preferred way to do. BTW, I used llvm.dbg.ty name so it is a good idea to pick up some name that also conveys your use of this association.

> Would the right starting point be to simply add an MDNode pointer to the Type class?  That should be then convertible to a DIType?  

We want to avoid any Type class modification. Instead you can use pair in named metadata to match metadata with type.

!11 = metadata !{i32 524307, metadata !1, metadata !"T", metadata !1, i32 2, i64 32, i64 32, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_structure_type ]

!21 = metadata !{ metadata !11,  %struct.T %z}

!llvm.my_special_type_info = !{!21}

> 
> The next step apparently would be to support to LLParser to read in such associations, and to AsmPrinter to print it out.

Yes.

>  But how about the bitcode?  Would this require a new LLVMBitCode?  

You need to modify bitcode writer/reader.

> 
> With that, would LLVM be able to deal with the type-associated metadata, or is there something in the LLVM side that I'm missing?

Yes. BTW, Dan Gohman is working on TBAA. He is also working on necessary support to associate Type with a metadata.

> Once that works, I guess I need to ask how to extend clang to emit the information, but the right place for that would be cfe-dev, wouldn't it?

yes.
-
Devang





More information about the llvm-dev mailing list