[cfe-commits] r99038 - in /cfe/trunk/lib/CodeGen: CGDeclCXX.cpp CodeGenFunction.h
Daniel Dunbar
daniel at zuster.org
Fri Mar 19 21:15:29 PDT 2010
Author: ddunbar
Date: Fri Mar 19 23:15:29 2010
New Revision: 99038
URL: http://llvm.org/viewvc/llvm-project?rev=99038&view=rev
Log:
IRgen: Inline GenerateCXXGlobal[VarDecl]InitFunc into sole caller.
Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=99038&r1=99037&r2=99038&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Fri Mar 19 23:15:29 2010
@@ -64,7 +64,7 @@
llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
DeclPtr = llvm::Constant::getNullValue(Int8PtrTy);
} else
- DtorFn = CGM.GetAddrOfCXXDestructor(Dtor, Dtor_Complete);
+ DtorFn = CGM.GetAddrOfCXXDestructor(Dtor, Dtor_Complete);
CGF.EmitCXXGlobalDtorRegistration(DtorFn, DeclPtr);
}
@@ -89,9 +89,8 @@
"global variable that binds reference to a non-lvalue");
}
-void
-CodeGenFunction::EmitCXXGlobalDtorRegistration(llvm::Constant *DtorFn,
- llvm::Constant *DeclPtr) {
+void CodeGenFunction::EmitCXXGlobalDtorRegistration(llvm::Constant *DtorFn,
+ llvm::Constant *DeclPtr) {
const llvm::Type *Int8PtrTy =
llvm::Type::getInt8Ty(VMContext)->getPointerTo();
@@ -124,8 +123,7 @@
Builder.CreateCall(AtExitFn, &Args[0], llvm::array_endof(Args));
}
-void
-CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D) {
+void CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D) {
const llvm::FunctionType *FTy
= llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext),
false);
@@ -135,13 +133,18 @@
llvm::Function::Create(FTy, llvm::GlobalValue::InternalLinkage,
"__cxx_global_var_init", &TheModule);
- CodeGenFunction(*this).GenerateCXXGlobalVarDeclInitFunc(Fn, D);
+ StartFunction(GlobalDecl(), getContext().VoidTy, Fn, FunctionArgList(),
+ SourceLocation());
+
+ llvm::Constant *DeclPtr = CGM.GetAddrOfGlobalVar(D);
+ EmitCXXGlobalVarDeclInit(*D, DeclPtr);
+
+ FinishFunction();
CXXGlobalInits.push_back(Fn);
}
-void
-CodeGenModule::EmitCXXGlobalInitFunc() {
+void CodeGenModule::EmitCXXGlobalInitFunc() {
if (CXXGlobalInits.empty())
return;
@@ -155,33 +158,15 @@
llvm::Function::Create(FTy, llvm::GlobalValue::InternalLinkage,
"__cxx_global_initialization", &TheModule);
- CodeGenFunction(*this).GenerateCXXGlobalInitFunc(Fn,
- &CXXGlobalInits[0],
- CXXGlobalInits.size());
- AddGlobalCtor(Fn);
-}
-
-void CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
- const VarDecl *D) {
StartFunction(GlobalDecl(), getContext().VoidTy, Fn, FunctionArgList(),
SourceLocation());
- llvm::Constant *DeclPtr = CGM.GetAddrOfGlobalVar(D);
- EmitCXXGlobalVarDeclInit(*D, DeclPtr);
+ for (unsigned i = 0, e = CXXGlobalInits.size(); i != e; ++i)
+ Builder.CreateCall(CXXGlobalInits[i]);
FinishFunction();
-}
-void CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn,
- llvm::Constant **Decls,
- unsigned NumDecls) {
- StartFunction(GlobalDecl(), getContext().VoidTy, Fn, FunctionArgList(),
- SourceLocation());
-
- for (unsigned i = 0; i != NumDecls; ++i)
- Builder.CreateCall(Decls[i]);
-
- FinishFunction();
+ AddGlobalCtor(Fn);
}
static llvm::Constant *getGuardAcquireFn(CodeGenFunction &CGF) {
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=99038&r1=99037&r2=99038&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Mar 19 23:15:29 2010
@@ -1225,14 +1225,6 @@
void EmitCXXGlobalDtorRegistration(llvm::Constant *DtorFn,
llvm::Constant *DeclPtr);
- /// GenerateCXXGlobalInitFunc - Generates code for initializing global
- /// variables.
- void GenerateCXXGlobalInitFunc(llvm::Function *Fn,
- llvm::Constant **Decls,
- unsigned NumDecls);
-
- void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn, const VarDecl *D);
-
void EmitCXXConstructExpr(llvm::Value *Dest, const CXXConstructExpr *E);
RValue EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
More information about the cfe-commits
mailing list