[LLVMdev] an llvm-gcc bug

Dale Johannesen dalej at apple.com
Tue Feb 12 14:35:55 PST 2008


Here's a cute bug in llvm-gcc's struct translation:

struct S242 { char * a;int b[1]; } ;
struct S93 { __attribute__((aligned (8))) void * a; } ;

The second example is padded out to 8 bytes, so both of these look like
{ i8 *, [1 x i32] }
This leads the "struct type factory" StructType::get to think they are  
the same.
But, the second field is marked as Padding in the second case but not  
the first,
and CopyAggregate does not copy Padding.  When the second type
goes through ConvertType, it is converted to the same llvm Type as the  
first type,
and the StructTypeConversionInfo info is replaced; later copies of the  
first type
then think they don't have to copy the padding, producing wrong code.

I'm inclined to remove skipping the Padding in CopyAggregate; that's  
at best an unimportant optimization, and could result in code that's  
slower than doing a straightforward rep;movsl or equivalent.   
Alternatively I can take the Padding bit into account in the  
StructType::get code somehow.  Anyone have a strong opinion?





More information about the llvm-dev mailing list