[cfe-commits] r55815 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGen/function-attributes.c
Daniel Dunbar
daniel at zuster.org
Thu Sep 4 17:57:45 PDT 2008
Author: ddunbar
Date: Thu Sep 4 19:57:45 2008
New Revision: 55815
URL: http://llvm.org/viewvc/llvm-project?rev=55815&view=rev
Log:
Set sext/zext on function result.
- <rdar://problem/6156739>
Added:
cfe/trunk/test/CodeGen/function-attributes.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=55815&r1=55814&r2=55815&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Sep 4 19:57:45 2008
@@ -207,14 +207,21 @@
FuncAttrs |= llvm::ParamAttr::NoReturn;
llvm::SmallVector<llvm::ParamAttrsWithIndex, 8> 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<QualType, 8>::const_iterator i = ArgTypes.begin() + 1,
e = ArgTypes.end(); i != e; ++i, ++increment) {
QualType ParamType = *i;
Added: cfe/trunk/test/CodeGen/function-attributes.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/function-attributes.c?rev=55815&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/function-attributes.c (added)
+++ cfe/trunk/test/CodeGen/function-attributes.c Thu Sep 4 19:57:45 2008
@@ -0,0 +1,22 @@
+// RUN: clang -emit-llvm -o %t.clang.ll %s &&
+// RUN: %llvmgcc -c --emit-llvm -o - %s | llvm-dis -f -o %t.gcc.ll &&
+// RUN: grep "define" %t.clang.ll | sort > %t.clang.defs &&
+// RUN: grep "define" %t.gcc.ll | sort > %t.gcc.defs &&
+// RUN: diff %t.clang.defs %t.gcc.defs
+
+signed char f0(int x) { return x; }
+
+unsigned char f1(int x) { return x; }
+
+void f2(signed char x) { }
+
+void f3(unsigned char x) { }
+
+signed short f4(int x) { return x; }
+
+unsigned short f5(int x) { return x; }
+
+void f6(signed short x) { }
+
+void f7(unsigned short x) { }
+
More information about the cfe-commits
mailing list