[llvm-dev] Link Struct to Metadata

Adrian Prantl via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 6 16:25:50 PST 2017


> On Jan 6, 2017, at 2:25 AM, Hong Hu via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi,
> 
> Given one structure type, is there any method to get the metadata that describes the structure information?
> 
> For example: 
> 
> %2 = getelementptr inbounds %"class.std::thread", %"class.std::thread"* %this, i64 0, i32 0, i32 0, !dbg !2748

> then I know the pointer operand type is class.std::thread. I want to find the associated metadata of this type:
> 
> !217 = !DICompositeType(tag: DW_TAG_class_type, name: "thread", scope: !34, file: !218, line: 60, size: 64, align: 64, elements: !219, identifier: "_ZTSSt6thread")                                         
> 
> The challenge is that the structure name is different in the IR instruction, from the one in the metadata. One is  class.std::thread, while another is _ZTSSt6thread. 
> 

What you are describing is not really possible.

- %"class.std::thread" is an LLVM type in the LLVM type system.
- !217 is an LLVM IR metadata node that describes a C++ type.

There exists no direct mapping between these two. The only link between the two is when there is a source variable of that type described by a llvm.dbg.value or llvm.dbg.declare intrinsic, such as a
- call @llvm.dbg.value(metadata %s, i64 0, metadata !217, metadata !DIExpression())

Can you explain your use-case some more? Perhaps there exists a better solution to what you are trying to do.

-- adrian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170106/dcdd4ba0/attachment.html>


More information about the llvm-dev mailing list