<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 29, 2020 at 6:39 AM Henri Rosten via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Given a DICompositeType, is there a convenient way to map the <br>
DICompositeType to llvm::Type?<br></blockquote><div><br></div><div>No there isn't - that's not usually a thing that folks need to do. What use case do you have in mind?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
As an example:<br>
<br>
```<br>
class Base {<br>
public:<br>
virtual void base_pure_virtual() = 0;<br>
};<br>
<br>
class Child : public Base {<br>
public:<br>
void base_pure_virtual() {<br>
std::cout << __PRETTY_FUNCTION__ << "\n";<br>
}<br>
};<br>
<br>
Child child;<br>
Base *baseptr = &child;<br>
```<br>
<br>
Relevant IR snippets:<br>
<br>
```<br>
@child = dso_local global { i8** } { i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV5Child, i32 0, inrange i32 0, i32 2) }, align 8, !dbg !19<br>
@baseptr = dso_local global %class.Base* bitcast ({ i8** }* @child to %class.Base*), align 8, !dbg !25<br>
...<br>
!914 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "Child", file: !22, line: 8, size: 64, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !915, vtableHolder: !28, identifier: "_ZTS5Child")<br>
```<br>
<br>
I would like to know the Type of the value assigned to baseptr.<br>
<br>
I figured global variable has a link to DIGlobalVariable, which has a <br>
link to DICompositeType. However, it seems there is no way to get to the <br>
llvm::Type from DICompositeType. Is this the case or did I overlook <br>
something?<br>
<br>
Alternatively, if there's a simpler way to get the Type of the value <br>
assigned to baseptr (class.Child*), I would welcome your suggestion.<br></blockquote><div><br>if you have the baseptr llvm::Value* you shuold be able to ask that llvm::Value for its type directly <a href="https://llvm.org/doxygen/classllvm_1_1Value.html#a6393a2d4fe7e10b28a0dcc35f881567b">https://llvm.org/doxygen/classllvm_1_1Value.html#a6393a2d4fe7e10b28a0dcc35f881567b</a> </div></div></div>