[llvm-commits] [127801] When an LLVM type has struct padding that overlaps with important fields of

Chris Lattner clattner at apple.com
Fri Jun 1 10:48:03 PDT 2007


>> Does this actually cause a problem?  This function is only called if
>> the outer struct has constant size.  TreeToLLVM::EmitAggregateCopy
>> checks that TREE_CODE(TYPE_SIZE(type)) == INTEGER_CST is true before
>> calling into this code.
>
> Yes, it crashes the compiler.  Remember that the function is  
> recursive.
> The problem is that a type of fixed size can have a field of  
> variable size.
> For example, a record field which is a variable sized array, where  
> the length
> is given by another field L in the record.  In this case the size  
> of the record
> type may be a constant equal to the maximum size obtained over all  
> possible
> values of L.
>
> In the case in question, a record R contains a field F, which is also
> a record type.  The fields present in F depend on the value of field E
> (of an enumeration type) in R.  Yes this is possible!  The size of F
> is thus an expression: it is calculated in terms of the value of E.
> The size of R is a constant: the maximum possible size, the maximum
> being taken over all values of E.

Okay, do you have a testcase that demonstrates this?

Also, the code for handling "large arrays" isn't needed.  This code  
is only called for fixed size structures that are small.

-Chris



More information about the llvm-commits mailing list