From 2ffee610dac058f42a25e6a574b31414b47866db Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 5 Sep 2008 00:57:45 +0000 Subject: Set sext/zext on function result. - llvm-svn: 55815 --- clang/lib/CodeGen/CodeGenModule.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 4c12011c4be..373027bbff4 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -207,14 +207,21 @@ SetFunctionAttributesFromTypes(const Decl *FD, FuncAttrs |= llvm::ParamAttr::NoReturn; llvm::SmallVector ParamAttrList; - if (FuncAttrs) - ParamAttrList.push_back(llvm::ParamAttrsWithIndex::get(0, FuncAttrs)); // Note that there is parallel code in CodeGenFunction::EmitCallExpr - bool AggregateReturn = CodeGenFunction::hasAggregateLLVMType(ArgTypes[0]); - if (AggregateReturn) + unsigned increment = 1; + if (CodeGenFunction::hasAggregateLLVMType(ArgTypes[0])) { ParamAttrList.push_back( llvm::ParamAttrsWithIndex::get(1, llvm::ParamAttr::StructRet)); - unsigned increment = AggregateReturn ? 2 : 1; + ++increment; + } else if (ArgTypes[0]->isPromotableIntegerType()) { + if (ArgTypes[0]->isSignedIntegerType()) { + FuncAttrs |= llvm::ParamAttr::SExt; + } else if (ArgTypes[0]->isUnsignedIntegerType()) { + FuncAttrs |= llvm::ParamAttr::ZExt; + } + } + if (FuncAttrs) + ParamAttrList.push_back(llvm::ParamAttrsWithIndex::get(0, FuncAttrs)); for (llvm::SmallVector::const_iterator i = ArgTypes.begin() + 1, e = ArgTypes.end(); i != e; ++i, ++increment) { QualType ParamType = *i; -- cgit v1.2.3