Hello, Everyone.
Please ignore my prev. patch, it's definitely wrong.
You might find attached new patch + testcase.
--
With best regards, Anton Korobeynikov.
Faculty of Mathematics & Mechanics, Saint Petersburg State University.
diff -r 6942c57f1ff9 gcc/llvm-types.cpp
--- a/gcc/llvm-types.cpp Fri Mar 30 09:02:21 2007 +0000
+++ b/gcc/llvm-types.cpp Sat Mar 31 01:51:42 2007 +0400
@@ -708,9 +708,10 @@ ConvertArgListToFnType(tree ReturnType,
FunctionType::ParamAttrsList ParamAttrs;
+ // Something for the return type.
+ ParamAttrs.push_back(FunctionType::NoAttributeSet);
+
if (static_chain) {
- // Something for the return type.
- ParamAttrs.push_back(FunctionType::NoAttributeSet);
// Pass the static chain in a register.
ParamAttrs.push_back(FunctionType::InRegAttribute);
}
@@ -796,10 +797,13 @@ const FunctionType *TypeConverter::Conve
if (static_chain)
// Pass the static chain in a register.
ParamAttrs.push_back(FunctionType::InRegAttribute);
-
+
+ // Handle struct return
+ if (ABIConverter.isStructReturn())
+ ParamAttrs.push_back(FunctionType::StructRetAttribute);
+
for (tree Args = TYPE_ARG_TYPES(type);
- Args && TREE_VALUE(Args) != void_type_node;
- Args = TREE_CHAIN(Args)) {
+ Args && TREE_VALUE(Args) != void_type_node; Args = TREE_CHAIN(Args)) {
unsigned Attributes = FunctionType::NoAttributeSet;
tree Ty = TREE_VALUE(Args);
@@ -814,15 +818,6 @@ const FunctionType *TypeConverter::Conve
else
Attributes |= FunctionType::SExtAttribute;
}
- }
-
- // Handle struct return
- if (isFirstArg) {
- if (ABIConverter.isStructReturn()) {
- Attributes |= FunctionType::StructRetAttribute;
- //printf("Struct return!\n");
- }
- isFirstArg = false;
}
#ifdef LLVM_TARGET_ENABLE_REGPARM
// RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | grep 'sret' | wc -l | grep '5'
struct abc {
int a;
int b;
int c;
};
struct abc foo1(void);
struct abc foo2();
void bar() {
struct abc dummy1 = foo1();
struct abc dummy2 = foo2();
}
_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits