From a985b31fc36aa22859983b4a5e7385796c627bdc Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 25 Feb 2009 19:45:19 +0000 Subject: [PATCH] Fold GeneraticStaticBlockVarDecl into callers. - No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65470 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDecl.cpp | 40 ++++++++++++----------------------- lib/CodeGen/CodeGenFunction.h | 8 ------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index c0f2054394..349656f58b 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -98,15 +98,15 @@ CodeGenFunction::CreateStaticBlockVarDecl(const VarDecl &D, &CGM.getModule(), 0, Ty.getAddressSpace()); } -llvm::GlobalVariable * -CodeGenFunction::GenerateStaticBlockVarDecl(const VarDecl &D, - bool NoInit, - const char *Separator, - llvm::GlobalValue - ::LinkageTypes Linkage) { - llvm::GlobalVariable *GV = CreateStaticBlockVarDecl(D, Separator, Linkage); - - if (D.getInit() && !NoInit) { +void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) { + + llvm::Value *&DMEntry = LocalDeclMap[&D]; + assert(DMEntry == 0 && "Decl already exists in localdeclmap!"); + + llvm::GlobalVariable *GV = + CreateStaticBlockVarDecl(D, ".", llvm::GlobalValue::InternalLinkage); + + if (D.getInit()) { llvm::Constant *Init = CGM.EmitConstantExpr(D.getInit(), this); // If constant emission failed, then this should be a C++ static @@ -147,18 +147,6 @@ CodeGenFunction::GenerateStaticBlockVarDecl(const VarDecl &D, } } - return GV; -} - -void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) { - - llvm::Value *&DMEntry = LocalDeclMap[&D]; - assert(DMEntry == 0 && "Decl already exists in localdeclmap!"); - - llvm::GlobalValue *GV; - GV = GenerateStaticBlockVarDecl(D, false, ".", - llvm::GlobalValue::InternalLinkage); - // FIXME: Merge attribute handling. if (const AnnotateAttr *AA = D.getAttr()) { SourceManager &SM = CGM.getContext().getSourceManager(); @@ -206,9 +194,9 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { // Targets that don't support recursion emit locals as globals. const char *Class = D.getStorageClass() == VarDecl::Register ? ".reg." : ".auto."; - DeclPtr = GenerateStaticBlockVarDecl(D, true, Class, - llvm::GlobalValue - ::InternalLinkage); + DeclPtr = CreateStaticBlockVarDecl(D, Class, + llvm::GlobalValue + ::InternalLinkage); } if (Ty->isVariablyModifiedType()) @@ -306,8 +294,8 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) { // Targets that don't have stack use global address space for parameters. // Specify external linkage for such globals so that llvm optimizer do // not assume there values initialized as zero. - DeclPtr = GenerateStaticBlockVarDecl(D, true, ".auto.", - llvm::GlobalValue::ExternalLinkage); + DeclPtr = CreateStaticBlockVarDecl(D, ".auto.", + llvm::GlobalValue::ExternalLinkage); } else { // A fixed sized single-value variable becomes an alloca in the entry block. const llvm::Type *LTy = ConvertType(Ty); diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 02276b98b0..6ee22bba00 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -753,14 +753,6 @@ public: llvm::GlobalValue::LinkageTypes Linkage); - /// GenerateStaticBlockVarDecl - Return the the static declaration of local - /// variable. - llvm::GlobalVariable * GenerateStaticBlockVarDecl(const VarDecl &D, - bool NoInit, - const char *Separator, - llvm::GlobalValue - ::LinkageTypes Linkage); - /// GenerateStaticCXXBlockVarDecl - Create the initializer for a C++ /// runtime initialized static block var decl. void GenerateStaticCXXBlockVarDeclInit(const VarDecl &D, -- 2.40.0