The attached patch is already contained in the previous cumulative PR950 patch. This contains just today's changes so it can be more easily applied to the Apple internal SVN server.
Reid.
Index: gcc/llvm-types.cpp =================================================================== --- gcc/llvm-types.cpp (revision 236) +++ gcc/llvm-types.cpp (working copy) @@ -575,7 +575,43 @@ isVarArg = (Args == 0); assert(RetTy && "Return type not specified!"); - return FunctionType::get(RetTy, ArgTypes, isVarArg); + + // If this is the C Calling Convention then scan the FunctionType's result + // type and argument types looking for integers less than 32-bits and set + // the parameter attribute in the FunctionType so any arguments passed to + // the function will be correctly sign or zero extended to 32-bits by + // the LLVM code gen. + FunctionType::ParamAttrsList ParamAttrs; + if (CallingConv == CallingConv::C || CallingConv == CallingConv::CSRet) { + tree ResultTy = TREE_TYPE(type); + if (TREE_CODE(ResultTy) == BOOLEAN_TYPE) + ParamAttrs.push_back(FunctionType::ZExtAttribute); + else if (TREE_CODE(ResultTy) == INTEGER_TYPE && + TREE_INT_CST_LOW(TYPE_SIZE(ResultTy)) < 32) + if (TYPE_UNSIGNED(ResultTy)) + ParamAttrs.push_back(FunctionType::ZExtAttribute); + else + ParamAttrs.push_back(FunctionType::SExtAttribute); + else + ParamAttrs.push_back(FunctionType::NoAttributeSet); + tree Args = TYPE_ARG_TYPES(type); + unsigned Idx = 1; + for (; Args && TREE_VALUE(Args) != void_type_node; Args = TREE_CHAIN(Args)){ + tree Ty = TREE_VALUE(Args); + if (TREE_CODE(Ty) == BOOLEAN_TYPE) + ParamAttrs.push_back(FunctionType::ZExtAttribute); + else if (TREE_CODE(Ty) == INTEGER_TYPE && + TREE_INT_CST_LOW(TYPE_SIZE(Ty)) < 32) + if (TYPE_UNSIGNED(Ty)) + ParamAttrs.push_back(FunctionType::ZExtAttribute); + else + ParamAttrs.push_back(FunctionType::SExtAttribute); + else + ParamAttrs.push_back(FunctionType::NoAttributeSet); + Idx++; + } + } + return FunctionType::get(RetTy, ArgTypes, isVarArg, ParamAttrs); } //===----------------------------------------------------------------------===//
_______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits