The second one is used only by EmitNullConstant when the parameter asCompleteObject is false.
What kind of type should the function getBaseSubobjectLLVMType return? Should it always be less or equal to the type returned by getLLVMType?
For one of my tests I have that getBaseSubobjectLLVMType returns a bigger packed version of the type returned by getLLVMType. It is bigger because padding has been added.
Are you sure the base subobject type is actually bigger? If so, that’s a bug. Note that unpacked LLVM struct types can have tail padding, so these two structs have the same size on a 64-bit platform:
{ i8*, i32 }
<{ i8*, i32, [4 x i8] }>
The size is rounded up to the natural alignment of the struct.
The second function returns a type that is usable in a derived class. This class might lower to <{ void (i8*), i8 }> as the base subobject type and { void (i8)*, i8 } as the complete type, for example:
class A {
virtual void f();
char a;
};
Because when B derives from A, it can use the tail padding of A like so:
class B : public A {
char b;
};
B’s LLVM type could be <{ <{ void (i8*)*, i8 }>, i8 }>