From ce5605ecf76d8cde6372138f830bb144d174ced9 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 30 Mar 2008 23:25:33 +0000 Subject: some cleanups on top of David's patch. There are still two remaining open issues I've communicated to him: 1) self can be assigned to, and his patch didn't handle it correctly. 2) CollectObjCIvarTypes is N^2 (because each subclass reprocesses all parent class ivars) and flattens classes. If A derives from B, and both have an int, I'd expect to get { {i32}, i32}, not { i32, i32}. David, please review. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48970 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 8374f2bab6..21b372b347 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -41,9 +41,8 @@ CodeGenModule::CodeGenModule(ASTContext &C, const LangOptions &LO, CodeGenModule::~CodeGenModule() { llvm::Function *ObjCInitFunction = Runtime->ModuleInitFunction(); - if (ObjCInitFunction) { + if (ObjCInitFunction) AddGlobalCtor(ObjCInitFunction); - } EmitGlobalCtors(); delete Runtime; } @@ -80,15 +79,15 @@ void CodeGenModule::AddGlobalCtor(llvm::Function * Ctor) { /// called on module load, if any have been registered with AddGlobalCtor. void CodeGenModule::EmitGlobalCtors() { if (GlobalCtors.empty()) return; + // Get the type of @llvm.global_ctors std::vector CtorFields; CtorFields.push_back(llvm::IntegerType::get(32)); // Constructor function type std::vector VoidArgs; - llvm::FunctionType* CtorFuncTy = llvm::FunctionType::get( - llvm::Type::VoidTy, - VoidArgs, - false); + llvm::FunctionType* CtorFuncTy = + llvm::FunctionType::get(llvm::Type::VoidTy, VoidArgs, false); + // i32, function type pair const llvm::Type *FPType = llvm::PointerType::getUnqual(CtorFuncTy); llvm::StructType* CtorStructTy = @@ -120,7 +119,6 @@ void CodeGenModule::EmitGlobalCtors() { GlobalCtorsVal->setInitializer(llvm::ConstantArray::get(GlobalCtorsTy, CtorValues)); - } -- cgit v1.2.3-18-g5258