[cfe-dev] CGRecordLayout: what difference should be between types returned by getLLVMType and getBaseSubobjectLLVMType

Reid Kleckner rnk at google.com
Tue Sep 30 10:28:48 PDT 2014


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 }>

On Tue, Sep 30, 2014 at 4:34 AM, Evgeny Astigeevich <
evgeny.astigeevich at arm.com> wrote:

> Hi all,
>
>
>
> I see that CGRecordLayout has two member functions:
>
>
>
> llvm::StructType *           getLLVMType () const
>
> llvm::StructType *           getBaseSubobjectLLVMType () const
>
>
>
> 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.
>
>
>
> Kind regards,
>
> Evgeny
>
>
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140930/b23cd844/attachment.html>


More information about the cfe-dev mailing list