consider the function struct long s{ long a; long b; } void f(struct s, char *, char); In x86_64 the struct s is passed in registers, so the llvm type should be f(i64, i64, i8 *, i8 sext) The problem is that in TypeConvert::ConvertFunctionType, the Idx is only incremented by one when passing by the first (C) argument. Because of this the llvm type generated is invalid: f(i64, i64, i8 * sext, i8)
Created attachment 1019 [details] hack that fixes this particular problem The general approach is to make ABIConverter.HandleArgument return the number of llvm arguments used. I think this is ok, what makes this patch a hack is that now ABIConverter.HandleArgument always return 1 except in the particular case that fixes this bug. I also don't understand why in TypeConverter::ConvertFunctionType the two loops that walk the argument list cannot be unified in one.
I'm taking a look. You're right, the attribute code should be in the abiconverter stuff. This is a good time for me to audit the attribute creation stuff in the front-end. I'll see if I can merge the loops etc.
Fixed. Testcase here: CFrontend/2007-06-18-SextAttrAggregate.c Patch here: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070618/050591.html Thanks Rafael! -Chris