[llvm-dev] DICompositeType to Type
Henri Rosten via llvm-dev
llvm-dev at lists.llvm.org
Thu Oct 29 06:38:50 PDT 2020
Given a DICompositeType, is there a convenient way to map the
DICompositeType to llvm::Type?
As an example:
```
class Base {
public:
virtual void base_pure_virtual() = 0;
};
class Child : public Base {
public:
void base_pure_virtual() {
std::cout << __PRETTY_FUNCTION__ << "\n";
}
};
Child child;
Base *baseptr = &child;
```
Relevant IR snippets:
```
@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
@baseptr = dso_local global %class.Base* bitcast ({ i8** }* @child to %class.Base*), align 8, !dbg !25
...
!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")
```
I would like to know the Type of the value assigned to baseptr.
I figured global variable has a link to DIGlobalVariable, which has a
link to DICompositeType. However, it seems there is no way to get to the
llvm::Type from DICompositeType. Is this the case or did I overlook
something?
Alternatively, if there's a simpler way to get the Type of the value
assigned to baseptr (class.Child*), I would welcome your suggestion.
Thanks,
-- Henri
More information about the llvm-dev
mailing list