diff options
author | Anders Carlsson <andersca@mac.com> | 2009-04-07 22:10:22 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-04-07 22:10:22 +0000 |
commit | 6e460ff03f984d34d6f3ba7f191380b823b6062f (patch) | |
tree | 0d50785a78ef78bc458f9e24c502754fd27b492e /lib/CodeGen/CGBlocks.cpp | |
parent | 3aaf082689d3235937a2e56a60f90fc1b3aebfb2 (diff) |
Shuffle some call code around. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68557 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBlocks.cpp')
-rw-r--r-- | lib/CodeGen/CGBlocks.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index e01df8d074..c8d9655951 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -412,10 +412,6 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) { const BlockPointerType *BPT = E->getCallee()->getType()->getAsBlockPointerType(); - const CGFunctionInfo &FnInfo = CGM.getTypes().getFunctionInfo(BPT); - bool IsVariadic = - BPT->getPointeeType()->getAsFunctionProtoType()->isVariadic(); - llvm::Value *Callee = EmitScalarExpr(E->getCallee()); // Get a pointer to the generic block literal. @@ -428,14 +424,6 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) { // Get the function pointer from the literal. llvm::Value *FuncPtr = Builder.CreateStructGEP(BlockLiteral, 3, "tmp"); - llvm::Value *Func = Builder.CreateLoad(FuncPtr, false, "tmp"); - - // Cast the function pointer to the right type. - const llvm::Type *BlockFTy = - CGM.getTypes().GetFunctionType(FnInfo, IsVariadic); - - const llvm::Type *BlockFTyPtr = llvm::PointerType::getUnqual(BlockFTy); - Func = Builder.CreateBitCast(Func, BlockFTyPtr); BlockLiteral = Builder.CreateBitCast(BlockLiteral, @@ -453,6 +441,20 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) { Args.push_back(std::make_pair(EmitAnyExprToTemp(*i), i->getType())); + // Load the function. + llvm::Value *Func = Builder.CreateLoad(FuncPtr, false, "tmp"); + + const CGFunctionInfo &FnInfo = CGM.getTypes().getFunctionInfo(BPT); + bool IsVariadic = + BPT->getPointeeType()->getAsFunctionProtoType()->isVariadic(); + + // Cast the function pointer to the right type. + const llvm::Type *BlockFTy = + CGM.getTypes().GetFunctionType(FnInfo, IsVariadic); + + const llvm::Type *BlockFTyPtr = llvm::PointerType::getUnqual(BlockFTy); + Func = Builder.CreateBitCast(Func, BlockFTyPtr); + // And call the block. return EmitCall(FnInfo, Func, Args); } |