diff options
author | Chris Lattner <sabre@nondot.org> | 2007-08-26 22:55:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-08-26 22:55:13 +0000 |
commit | 660ac121373d416804ea22cc193e2cfcfac1c1b3 (patch) | |
tree | c5a13c583de9ac4203f7a4602e2ef753faf949b6 /CodeGen/CGExpr.cpp | |
parent | 6b5d0bf42fa4212f21ebb620b15e1024cb6a2a58 (diff) |
eliminate use of EmitAnyExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41467 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CGExpr.cpp')
-rw-r--r-- | CodeGen/CGExpr.cpp | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/CodeGen/CGExpr.cpp b/CodeGen/CGExpr.cpp index facca17ded..549402892f 100644 --- a/CodeGen/CGExpr.cpp +++ b/CodeGen/CGExpr.cpp @@ -428,27 +428,35 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E) { for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) { QualType ArgTy = E->getArg(i)->getType(); - RValue ArgVal = EmitAnyExpr(E->getArg(i)); - // If this argument has prototype information, convert it. - if (ArgTyIt == ArgTyEnd) { - // Otherwise, if passing through "..." or to a function with no prototype, - // perform the "default argument promotions" (C99 6.5.2.2p6), which - // includes the usual unary conversions, but also promotes float to - // double. - // FIXME: remove this when the impcast is in place. - if (const BuiltinType *BT = - dyn_cast<BuiltinType>(ArgTy.getCanonicalType())) { - if (BT->getKind() == BuiltinType::Float) - ArgVal = RValue::get(Builder.CreateFPExt(ArgVal.getVal(), - llvm::Type::DoubleTy,"tmp")); + if (!hasAggregateLLVMType(ArgTy)) { + // Scalar argument is passed by-value. + Args.push_back(EmitScalarExpr(E->getArg(i))); + + if (ArgTyIt == ArgTyEnd) { + // Otherwise, if passing through "..." or to a function with no prototype, + // perform the "default argument promotions" (C99 6.5.2.2p6), which + // includes the usual unary conversions, but also promotes float to + // double. + // FIXME: remove this when the impcast is in place. + if (Args.back()->getType() == llvm::Type::FloatTy) + Args.back() = Builder.CreateFPExt(Args.back(), llvm::Type::DoubleTy, + "tmp"); + // FIXME: Remove ArgIt when this is gone. } + } else if (ArgTy->isComplexType()) { + // Make a temporary alloca to pass the argument. + llvm::Value *DestMem = CreateTempAlloca(ConvertType(ArgTy)); + EmitComplexExprIntoAddr(E->getArg(i), DestMem, false); + Args.push_back(DestMem); + } else { + llvm::Value *DestMem = CreateTempAlloca(ConvertType(ArgTy)); + EmitAggExpr(E->getArg(i), DestMem, false); + Args.push_back(DestMem); } - if (ArgVal.isScalar()) - Args.push_back(ArgVal.getVal()); - else // Pass by-address. FIXME: Set attribute bit on call. - Args.push_back(ArgVal.getAggregateAddr()); + if (ArgTyIt != ArgTyEnd) + ++ArgTyIt; } llvm::Value *V = Builder.CreateCall(Callee, &Args[0], &Args[0]+Args.size()); |