Move more of the blocks code up and out.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66046 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index 8aabada..d877b17 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -501,7 +501,7 @@
}
llvm::Constant *
-CodeGenModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) {
+BlockModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) {
// Generate the block descriptor.
const llvm::Type *UnsignedLongTy = Types.ConvertType(Context.UnsignedLongTy);
const llvm::IntegerType *IntTy = cast<llvm::IntegerType>(
@@ -534,9 +534,9 @@
uint64_t subBlockSize, subBlockAlign;
llvm::SmallVector<const Expr *, 8> subBlockDeclRefDecls;
llvm::Function *Fn
- = CodeGenFunction(*this).GenerateBlockFunction(BE, Info, subBlockSize,
- subBlockAlign,
- subBlockDeclRefDecls);
+ = CodeGenFunction(CGM).GenerateBlockFunction(BE, Info, subBlockSize,
+ subBlockAlign,
+ subBlockDeclRefDecls);
assert(subBlockSize == BlockLiteralSize
&& "no imports allowed for global block");
diff --git a/lib/CodeGen/CGBlocks.h b/lib/CodeGen/CGBlocks.h
index a55c578..f588314 100644
--- a/lib/CodeGen/CGBlocks.h
+++ b/lib/CodeGen/CGBlocks.h
@@ -43,6 +43,7 @@
namespace clang {
namespace CodeGen {
+class CodeGenModule;
class BlockBase {
public:
@@ -59,11 +60,14 @@
class BlockModule : public BlockBase {
ASTContext &Context;
llvm::Module &TheModule;
+ const llvm::TargetData &TheTargetData;
CodeGenTypes &Types;
+ CodeGenModule &CGM;
ASTContext &getContext() const { return Context; }
llvm::Module &getModule() const { return TheModule; }
CodeGenTypes &getTypes() { return Types; }
+ const llvm::TargetData &getTargetData() const { return TheTargetData; }
public:
llvm::Constant *getNSConcreteGlobalBlock();
llvm::Constant *getNSConcreteStackBlock();
@@ -73,6 +77,8 @@
const llvm::Type *getGenericBlockLiteralType();
const llvm::Type *getGenericExtendedBlockLiteralType();
+ llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, const char *);
+
/// NSConcreteGlobalBlock - Cached reference to the class pointer for global
/// blocks.
llvm::Constant *NSConcreteGlobalBlock;
@@ -88,9 +94,11 @@
int GlobalUniqueCount;
} Block;
- BlockModule(ASTContext &C, llvm::Module &M, CodeGenTypes &T)
- : Context(C), TheModule(M), Types(T), NSConcreteGlobalBlock(0),
- NSConcreteStackBlock(0), BlockDescriptorType(0),
+ BlockModule(ASTContext &C, llvm::Module &M, const llvm::TargetData &TD,
+ CodeGenTypes &T, CodeGenModule &CodeGen)
+ : Context(C), TheModule(M), TheTargetData(TD), Types(T),
+ CGM(CodeGen),
+ NSConcreteGlobalBlock(0), NSConcreteStackBlock(0), BlockDescriptorType(0),
GenericBlockLiteralType(0) {
Block.GlobalUniqueCount = 0;
}
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index c0dba74..422415c 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -34,7 +34,7 @@
CodeGenModule::CodeGenModule(ASTContext &C, const LangOptions &LO,
llvm::Module &M, const llvm::TargetData &TD,
Diagnostic &diags, bool GenerateDebugInfo)
- : BlockModule(C, M, Types), Context(C), Features(LO), TheModule(M),
+ : BlockModule(C, M, TD, Types, *this), Context(C), Features(LO), TheModule(M),
TheTargetData(TD), Diags(diags), Types(C, M, TD), Runtime(0),
MemCpyFn(0), MemMoveFn(0), MemSetFn(0), CFConstantStringClassRef(0) {
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h
index d20d22b..a2b45a0 100644
--- a/lib/CodeGen/CodeGenModule.h
+++ b/lib/CodeGen/CodeGenModule.h
@@ -217,8 +217,6 @@
llvm::Constant *GetAddrOfConstantCString(const std::string &str,
const char *GlobalName=0);
- llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, const char *);
-
/// getBuiltinLibFunction - Given a builtin id for a function like
/// "__builtin_fabsf", return a Function* for "fabsf".
llvm::Value *getBuiltinLibFunction(unsigned BuiltinID);