diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-02-25 19:24:29 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-02-25 19:24:29 +0000 |
commit | 0096acf421c4609ce7f43e8b05f8c5ca866d4611 (patch) | |
tree | b138a6cda73d80318e14c45fc3902baac44fbdb1 /lib/CodeGen/CGCXX.cpp | |
parent | 01e4b5c3bf9f529c0c873162119d56a4f9341167 (diff) |
Pull COdeGenFunction::CreateStaticBlockVarDecl (just for creating the
global variable) out of GenerateStaticBlockVarDecl.
- No intended functionality change.
- Prep for some mild cleanups and PR3662.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65466 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 489c67bc6b..f43130a12b 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -83,28 +83,24 @@ static std::string mangleGuardVariable(const VarDecl& D) return S; } -llvm::GlobalValue * -CodeGenFunction::GenerateStaticCXXBlockVarDecl(const VarDecl &D) -{ +void +CodeGenFunction::GenerateStaticCXXBlockVarDeclInit(const VarDecl &D, + llvm::GlobalVariable *GV) { + // FIXME: This should use __cxa_guard_{acquire,release}? + assert(!getContext().getLangOptions().ThreadsafeStatics && "thread safe statics are currently not supported!"); - const llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(D.getType()); - // FIXME: If the function is inline, the linkage should be weak. - llvm::GlobalValue::LinkageTypes linkage = llvm::GlobalValue::InternalLinkage; - // Create the guard variable. llvm::GlobalValue *GuardV = new llvm::GlobalVariable(llvm::Type::Int64Ty, false, - linkage, + GV->getLinkage(), llvm::Constant::getNullValue(llvm::Type::Int64Ty), mangleGuardVariable(D), &CGM.getModule()); - // FIXME: Address space. - const llvm::Type *PtrTy = llvm::PointerType::get(llvm::Type::Int8Ty, 0); - // Load the first byte of the guard variable. + const llvm::Type *PtrTy = llvm::PointerType::get(llvm::Type::Int8Ty, 0); llvm::Value *V = Builder.CreateLoad(Builder.CreateBitCast(GuardV, PtrTy), "tmp"); @@ -120,13 +116,8 @@ CodeGenFunction::GenerateStaticCXXBlockVarDecl(const VarDecl &D) EmitBlock(InitBlock); - llvm::GlobalValue *GV = - new llvm::GlobalVariable(LTy, false, - llvm::GlobalValue::InternalLinkage, - llvm::Constant::getNullValue(LTy), - mangleVarDecl(D), - &CGM.getModule(), 0, - D.getType().getAddressSpace()); + // Patch the name. FIXME: We shouldn't need to do this. + GV->setName(mangleVarDecl(D)); const Expr *Init = D.getInit(); if (!hasAggregateLLVMType(Init->getType())) { @@ -142,6 +133,5 @@ CodeGenFunction::GenerateStaticCXXBlockVarDecl(const VarDecl &D) Builder.CreateBitCast(GuardV, PtrTy)); EmitBlock(EndBlock); - return GV; } |