From de5d3c717684f3821b8db58037bc7140acf134aa Mon Sep 17 00:00:00 2001 From: John McCall Date: Fri, 17 Feb 2012 03:33:10 +0000 Subject: Whether an argument is required (in contrast with being an optional argument passed through the variadic ellipsis) potentially affects how we need to lower it. Propagate this information down to the various getFunctionInfo(...) overloads on CodeGenTypes. Furthermore, rename those overloads to clarify their distinct purposes, and make sure we're calling the right one in the right place. This has a nice side-effect of making it easier to construct a function type, since the 'variadic' bit is no longer separable. This shouldn't really change anything for our existing platforms, with one minor exception --- we should now call variadic ObjC methods with the ... in the "right place" (see the test case), which I guess matters for anyone running GNUStep on MIPS. Mostly it's just a substantial clean-up. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150788 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib/CodeGen/CGExpr.cpp') diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index f67025a32c..3871f33a26 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -2454,7 +2454,8 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType, llvm::Value *Callee, CallArgList Args; EmitCallArgs(Args, dyn_cast(FnType), ArgBeg, ArgEnd); - const CGFunctionInfo &FnInfo = CGM.getTypes().getFunctionInfo(Args, FnType); + const CGFunctionInfo &FnInfo = + CGM.getTypes().arrangeFunctionCall(Args, FnType); // C99 6.5.2.2p6: // If the expression that denotes the called function has a type @@ -2473,11 +2474,8 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType, llvm::Value *Callee, // through an unprototyped function type works like a *non-variadic* // call. The way we make this work is to cast to the exact type // of the promoted arguments. - if (isa(FnType) && - !getTargetHooks().isNoProtoCallVariadic(FnInfo)) { - assert(cast(Callee->getType()->getContainedType(0)) - ->isVarArg()); - llvm::Type *CalleeTy = getTypes().GetFunctionType(FnInfo, false); + if (isa(FnType) && !FnInfo.isVariadic()) { + llvm::Type *CalleeTy = getTypes().GetFunctionType(FnInfo); CalleeTy = CalleeTy->getPointerTo(); Callee = Builder.CreateBitCast(Callee, CalleeTy, "callee.knr.cast"); } @@ -2678,7 +2676,8 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) { Args.add(RValue::get(llvm::ConstantInt::get(SizeTy, Size)), getContext().getSizeType()); const CGFunctionInfo &FuncInfo = - CGM.getTypes().getFunctionInfo(RetTy, Args, FunctionType::ExtInfo()); + CGM.getTypes().arrangeFunctionCall(RetTy, Args, FunctionType::ExtInfo(), + /*variadic*/ false); llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(FuncInfo, false); llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, LibCallName); RValue Res = EmitCall(FuncInfo, Func, ReturnValueSlot(), Args); -- cgit v1.2.3