diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-22 19:35:37 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-22 19:35:37 +0000 |
commit | 75acb0c35604796a1d7457c4e591b408dddde614 (patch) | |
tree | 16d97f71d040a084cb611e9dbd7ddca3dbb8bf96 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 377b9c84d01a954c9f39221e66b5f109b2a21662 (diff) | |
download | bcm5719-llvm-75acb0c35604796a1d7457c4e591b408dddde614.tar.gz bcm5719-llvm-75acb0c35604796a1d7457c4e591b408dddde614.zip |
fix a fixme: non-proto struct returning function definitions should be compiled
to something like:
define void @bar(%struct.foo* noalias sret %agg.result) nounwind {
instead of:
define void @bar(%struct.foo* noalias sret %agg.result, ...) nounwind {
llvm-svn: 67475
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 4cd046d74ed..6f745f2b90c 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -859,10 +859,13 @@ void CodeGenModule::EmitGlobalFunctionDefinition(const FunctionDecl *D) { // As a special case, make sure that definitions of K&R function // "type foo()" aren't declared as varargs (which forces the backend // to do unnecessary work). - // FIXME: what about stret() functions, this doesn't handle them!? - if (Ty->isVarArg() && Ty->getNumParams() == 0) - Ty = llvm::FunctionType::get(Ty->getReturnType(), - std::vector<const llvm::Type*>(), false); + if (D->getType()->isFunctionNoProtoType()) { + assert(Ty->isVarArg() && "Didn't lower type as expected"); + // Due to stret, the lowered function could have arguments. Just create the + // same type as was lowered by ConvertType but strip off the varargs bit. + std::vector<const llvm::Type*> Args(Ty->param_begin(), Ty->param_end()); + Ty = llvm::FunctionType::get(Ty->getReturnType(), Args, false); + } // Get or create the prototype for teh function. llvm::Constant *Entry = GetAddrOfFunction(D, Ty); |