aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-22 19:35:37 +0000
committerChris Lattner <sabre@nondot.org>2009-03-22 19:35:37 +0000
commitff75e1db95a53c7606e0bb114cf9adc59ab3d7f6 (patch)
tree91991672ba9d6335aaebdf6d044f9552e9c80cfd /lib/CodeGen/CodeGenModule.cpp
parent26d1a40edc612f4c53399427480592101acb0dbe (diff)
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 { git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67475 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--lib/CodeGen/CodeGenModule.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 4cd046d74e..6f745f2b90 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/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);