summaryrefslogtreecommitdiffstats
path: root/clang/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-06-22 22:02:34 +0000
committerChris Lattner <sabre@nondot.org>2007-06-22 22:02:34 +0000
commit54fb19efaaa18f9417e6881506cdf15292ecccb6 (patch)
treef159e5fbcd66b2040200738264c4b892afc619ba /clang/CodeGen/CodeGenFunction.cpp
parente9a6453ded48e319aec7a8be4a0a477915aaa8f8 (diff)
downloadbcm5719-llvm-54fb19efaaa18f9417e6881506cdf15292ecccb6.tar.gz
bcm5719-llvm-54fb19efaaa18f9417e6881506cdf15292ecccb6.zip
implement support for struct and complex returns.
llvm-svn: 39674
Diffstat (limited to 'clang/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/CodeGen/CodeGenFunction.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/CodeGen/CodeGenFunction.cpp b/clang/CodeGen/CodeGenFunction.cpp
index b315ab40b4f..59336489c97 100644
--- a/clang/CodeGen/CodeGenFunction.cpp
+++ b/clang/CodeGen/CodeGenFunction.cpp
@@ -43,6 +43,11 @@ const llvm::Type *CodeGenFunction::ConvertType(QualType T) {
return CGM.getTypes().ConvertType(T);
}
+bool CodeGenFunction::hasAggregateLLVMType(QualType T) {
+ return !T->isRealType() && !T->isPointerType();
+}
+
+
void CodeGenFunction::GenerateCode(const FunctionDecl *FD) {
LLVMIntTy = ConvertType(getContext().IntTy);
LLVMPointerWidth = Target.getPointerWidth(SourceLocation());
@@ -62,8 +67,15 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD) {
llvm::Value *Undef = llvm::UndefValue::get(llvm::Type::Int32Ty);
AllocaInsertPt = Builder.CreateBitCast(Undef,llvm::Type::Int32Ty, "allocapt");
- // Emit allocs for param decls.
+ // Emit allocs for param decls. Give the LLVM Argument nodes names.
llvm::Function::arg_iterator AI = CurFn->arg_begin();
+
+ // Name the struct return argument.
+ if (hasAggregateLLVMType(FD->getResultType())) {
+ AI->setName("agg.result");
+ ++AI;
+ }
+
for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i, ++AI) {
assert(AI != CurFn->arg_end() && "Argument mismatch!");
EmitParmDecl(*FD->getParamDecl(i), AI);
OpenPOWER on IntegriCloud