forked from OSchip/llvm-project
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
This commit is contained in:
parent
377b9c84d0
commit
75acb0c356
|
@ -859,10 +859,13 @@ void CodeGenModule::EmitGlobalFunctionDefinition(const FunctionDecl *D) {
|
||||||
// As a special case, make sure that definitions of K&R function
|
// As a special case, make sure that definitions of K&R function
|
||||||
// "type foo()" aren't declared as varargs (which forces the backend
|
// "type foo()" aren't declared as varargs (which forces the backend
|
||||||
// to do unnecessary work).
|
// to do unnecessary work).
|
||||||
// FIXME: what about stret() functions, this doesn't handle them!?
|
if (D->getType()->isFunctionNoProtoType()) {
|
||||||
if (Ty->isVarArg() && Ty->getNumParams() == 0)
|
assert(Ty->isVarArg() && "Didn't lower type as expected");
|
||||||
Ty = llvm::FunctionType::get(Ty->getReturnType(),
|
// Due to stret, the lowered function could have arguments. Just create the
|
||||||
std::vector<const llvm::Type*>(), false);
|
// 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.
|
// Get or create the prototype for teh function.
|
||||||
llvm::Constant *Entry = GetAddrOfFunction(D, Ty);
|
llvm::Constant *Entry = GetAddrOfFunction(D, Ty);
|
||||||
|
|
|
@ -27,5 +27,9 @@ void f1();
|
||||||
void f2(void) {
|
void f2(void) {
|
||||||
f1(1, 2, 3);
|
f1(1, 2, 3);
|
||||||
}
|
}
|
||||||
// RUN: grep 'define void @f1()' %t
|
// RUN: grep 'define void @f1()' %t &&
|
||||||
void f1() {}
|
void f1() {}
|
||||||
|
|
||||||
|
// RUN: grep 'define .* @f3' %t | not grep -F '...'
|
||||||
|
struct foo { int X, Y, Z; } f3() {
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue