From: Chris Lattner Date: Tue, 6 May 2008 00:56:42 +0000 (+0000) Subject: simplify some builder calls. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3eae03e7d165f20a863a9a4d7122ba2a691ab16d;p=clang simplify some builder calls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50694 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 98e01b04a5..f32031325d 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -140,9 +140,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { DstPtr = Builder.CreateBitCast(DstPtr, Type); SrcPtr = Builder.CreateBitCast(SrcPtr, Type); - Value *Args[] = { DstPtr, SrcPtr }; - return RValue::get(Builder.CreateCall(CGM.getIntrinsic(Intrinsic::vacopy), - &Args[0], &Args[2])); + return RValue::get(Builder.CreateCall2(CGM.getIntrinsic(Intrinsic::vacopy), + DstPtr, SrcPtr)); } case Builtin::BI__builtin_classify_type: { APSInt Result(32); @@ -559,18 +558,16 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, llvm::Type *PtrTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); Value *One = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1); Value *Tmp = Builder.CreateAlloca(llvm::Type::Int32Ty, One, "tmp"); - One = Builder.CreateBitCast(Tmp, PtrTy); Builder.CreateStore(Ops[0], Tmp); return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_ldmxcsr), - &One, &One+1); + Builder.CreateBitCast(Tmp, PtrTy)); } case X86::BI__builtin_ia32_stmxcsr: { llvm::Type *PtrTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); Value *One = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1); Value *Tmp = Builder.CreateAlloca(llvm::Type::Int32Ty, One, "tmp"); - One = Builder.CreateBitCast(Tmp, PtrTy); One = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_stmxcsr), - &One, &One+1); + Builder.CreateBitCast(Tmp, PtrTy)); return Builder.CreateLoad(Tmp, "stmxcsr"); } case X86::BI__builtin_ia32_cmpordps: diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index f91c39253c..508bf75383 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -330,14 +330,10 @@ void AggExprEmitter::EmitNullInitializationToLValue(LValue LV, QualType T) { const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); llvm::Value* DestPtr = Builder.CreateBitCast(LV.getAddress(), BP, "tmp"); - - llvm::Value *MemSetOps[4] = { - DestPtr, llvm::ConstantInt::get(llvm::Type::Int8Ty, 0), - llvm::ConstantInt::get(llvm::Type::Int64Ty, Size/8), - llvm::ConstantInt::get(llvm::Type::Int32Ty, 0) - }; - - Builder.CreateCall(MemSet, MemSetOps, MemSetOps+4); + Builder.CreateCall4(MemSet, DestPtr, + llvm::ConstantInt::get(llvm::Type::Int8Ty, 0), + llvm::ConstantInt::get(llvm::Type::Int64Ty, Size/8), + llvm::ConstantInt::get(llvm::Type::Int32Ty, 0)); } } diff --git a/lib/CodeGen/CGObjCEtoile.cpp b/lib/CodeGen/CGObjCEtoile.cpp index 4ff48f12b6..d5023b4240 100644 --- a/lib/CodeGen/CGObjCEtoile.cpp +++ b/lib/CodeGen/CGObjCEtoile.cpp @@ -131,10 +131,7 @@ llvm::Value *CGObjCEtoile::getSelector(llvm::IRBuilder &Builder, PtrToInt8Ty, PtrToInt8Ty, NULL); - llvm::SmallVector Args; - Args.push_back(SelName); - Args.push_back(SelTypes); - return Builder.CreateCall(SelFunction, Args.begin(), Args.end()); + return Builder.CreateCall2(SelFunction, SelName, SelTypes); } static void SetField(llvm::IRBuilder &Builder, llvm::Value *Structure, @@ -180,9 +177,8 @@ llvm::Value *CGObjCEtoile::generateMessageSend(llvm::IRBuilder &Builder, LookupArgs.push_back(Receiver); LookupArgs.push_back(cmd); LookupArgs.push_back(Sender); - llvm::Value *Slot = Builder.CreateCall(Lookup, - LookupArgs.begin(), - LookupArgs.end()); + llvm::Value *Slot = Builder.CreateCall(Lookup, LookupArgs.begin(), + LookupArgs.end()); // Create the call structure llvm::Value *Call = Builder.CreateAlloca(CallTy); diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 5bb8fac73b..8373cfd84f 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -108,8 +108,7 @@ llvm::Value *CGObjCGNU::getSelector(llvm::IRBuilder &Builder, PtrToInt8Ty, PtrToInt8Ty, NULL); - llvm::Value *Args[] = { SelName, SelTypes }; - cmd = Builder.CreateCall(SelFunction, Args, Args+2); + cmd = Builder.CreateCall2(SelFunction, SelName, SelTypes); } return cmd; } @@ -142,13 +141,12 @@ llvm::Value *CGObjCGNU::generateMessageSend(llvm::IRBuilder &Builder, TheModule.getOrInsertFunction("objc_msg_lookup", llvm::PointerType::getUnqual(impType), Receiver->getType(), SelectorTy, NULL); + llvm::Value *imp = Builder.CreateCall2(lookupFunction, Receiver, cmd); + + // Call the method. llvm::SmallVector lookupArgs; lookupArgs.push_back(Receiver); lookupArgs.push_back(cmd); - llvm::Value *imp = Builder.CreateCall(lookupFunction, - lookupArgs.begin(), lookupArgs.end()); - - // Call the method. lookupArgs.insert(lookupArgs.end(), ArgV, ArgV+ArgC); return Builder.CreateCall(imp, lookupArgs.begin(), lookupArgs.end()); }