diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2012-06-26 16:06:38 +0000 | 
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-06-26 16:06:38 +0000 | 
| commit | 6362803cfed99bc008b12b488d2c2a682df0cc2d (patch) | |
| tree | f476f5ae436635f48d58742bdf2d66f0311b3488 /clang/lib/CodeGen | |
| parent | 41960467142142e8b2eef91436b1345a372e5d14 (diff) | |
| download | bcm5719-llvm-6362803cfed99bc008b12b488d2c2a682df0cc2d.tar.gz bcm5719-llvm-6362803cfed99bc008b12b488d2c2a682df0cc2d.zip  | |
block literal irgen: several improvements on naming block
literal helper functions. All helper functions (global
and locals) use block_invoke as their prefix. Local literal
helper names are prefixed by their enclosing mangled function
names. Blocks in non-local initializers (e.g. a global variable 
or a C++11 field) are prefixed by their mangled variable name. 
The descriminator number added to end of the name starts off 
with blank (for first block) and _<N> (for the N+2-th block).
llvm-svn: 159206
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGBlocks.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 2 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 4 | 
5 files changed, 17 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 47c6c48018e..e89841c0404 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -630,7 +630,7 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) {    // Using the computed layout, generate the actual block function.    bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();    llvm::Constant *blockFn -    = CodeGenFunction(CGM).GenerateBlockFunction(CurGD, blockInfo, +    = CodeGenFunction(CGM, true).GenerateBlockFunction(CurGD, blockInfo,                                                   CurFuncDecl, LocalDeclMap,                                                   isLambdaConv);    blockFn = llvm::ConstantExpr::getBitCast(blockFn, VoidPtrTy); @@ -1003,7 +1003,8 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD,    // Check if we should generate debug info for this block function.    if (CGM.getModuleDebugInfo())      DebugInfo = CGM.getModuleDebugInfo(); - +  CurGD = GD; +      BlockInfo = &blockInfo;    // Arrange for local static and local extern declarations to appear diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index ceffbd4989d..68593946f6d 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -28,7 +28,7 @@  using namespace clang;  using namespace CodeGen; -CodeGenFunction::CodeGenFunction(CodeGenModule &cgm) +CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext)    : CodeGenTypeCache(cgm), CGM(cgm),      Target(CGM.getContext().getTargetInfo()),      Builder(cgm.getModule().getContext()), @@ -42,7 +42,8 @@ CodeGenFunction::CodeGenFunction(CodeGenModule &cgm)      TerminateHandler(0), TrapBB(0) {    CatchUndefined = getContext().getLangOpts().CatchUndefined; -  CGM.getCXXABI().getMangleContext().startNewFunction(); +  if (!suppressNewContext) +    CGM.getCXXABI().getMangleContext().startNewFunction();  }  CodeGenFunction::~CodeGenFunction() { diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index a6d77e31c7f..b26d174180a 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -1198,7 +1198,7 @@ private:    llvm::BasicBlock *TrapBB;  public: -  CodeGenFunction(CodeGenModule &cgm); +  CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext=false);    ~CodeGenFunction();    CodeGenTypes &getTypes() const { return CGM.getTypes(); } diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8c1588b174e..8f769d90204 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -347,7 +347,8 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) {    else if (const CXXDestructorDecl *D = dyn_cast<CXXDestructorDecl>(ND))      getCXXABI().getMangleContext().mangleCXXDtor(D, GD.getDtorType(), Out);    else if (const BlockDecl *BD = dyn_cast<BlockDecl>(ND)) -    getCXXABI().getMangleContext().mangleBlock(BD, Out); +    getCXXABI().getMangleContext().mangleBlock(BD, Out, +      dyn_cast_or_null<VarDecl>(initializedGlobalDecl.getDecl()));    else      getCXXABI().getMangleContext().mangleName(ND, Out); @@ -368,7 +369,8 @@ void CodeGenModule::getBlockMangledName(GlobalDecl GD, MangleBuffer &Buffer,    const Decl *D = GD.getDecl();    llvm::raw_svector_ostream Out(Buffer.getBuffer());    if (D == 0) -    MangleCtx.mangleGlobalBlock(BD, Out); +    MangleCtx.mangleGlobalBlock(BD,  +      dyn_cast_or_null<VarDecl>(initializedGlobalDecl.getDecl()), Out);    else if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D))      MangleCtx.mangleCtorBlock(CD, GD.getCtorType(), BD, Out);    else if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(D)) @@ -1551,8 +1553,10 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {      // FIXME: It does so in a global constructor, which is *not* what we      // want. -    if (!Init) +    if (!Init) { +      initializedGlobalDecl = GlobalDecl(D);        Init = EmitConstantInit(*InitDecl); +    }      if (!Init) {        QualType T = InitExpr->getType();        if (D->getType()->isReferenceType()) diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index d1ecfec78a7..a742d846c19 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -351,6 +351,8 @@ class CodeGenModule : public CodeGenTypeCache {    struct {      int GlobalUniqueCount;    } Block; +   +  GlobalDecl initializedGlobalDecl;    /// @}  public: @@ -596,7 +598,7 @@ public:    /// getUniqueBlockCount - Fetches the global unique block count.    int getUniqueBlockCount() { return ++Block.GlobalUniqueCount; } - +      /// getBlockDescriptorType - Fetches the type of a generic block    /// descriptor.    llvm::Type *getBlockDescriptorType();  | 

