]> granicus.if.org Git - clang/commitdiff
Implement a FIXME. This improves codegen just a tad.
authorMike Stump <mrs@apple.com>
Thu, 1 Oct 2009 22:29:41 +0000 (22:29 +0000)
committerMike Stump <mrs@apple.com>
Thu, 1 Oct 2009 22:29:41 +0000 (22:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83221 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGBlocks.cpp
lib/CodeGen/CGDebugInfo.cpp

index ba14fea36e055c2685585a736e9a0cf59e721bc0..79950e8c6beb44cc6b76f9b426a234b5565f0eb2 100644 (file)
@@ -663,20 +663,23 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr,
   StartFunction(BD, ResultType, Fn, Args,
                 BExpr->getBody()->getLocEnd());
 
+  CurFuncDecl = OuterFuncDecl;
+  CurCodeDecl = BD;
+
   // Save a spot to insert the debug information for all the BlockDeclRefDecls.
   llvm::BasicBlock *entry = Builder.GetInsertBlock();
+  llvm::BasicBlock::iterator entry_ptr = Builder.GetInsertPoint();
+  --entry_ptr;
 
-  CurFuncDecl = OuterFuncDecl;
-  CurCodeDecl = BD;
-  // FIXME: Can we straighten this out not using multiple basic blocks?
-  // Set body aside for now.
-  llvm::BasicBlock *body = createBasicBlock("body");
-  Builder.SetInsertPoint(body);
   EmitStmt(BExpr->getBody());
+
   // Remember where we were...
   llvm::BasicBlock *resume = Builder.GetInsertBlock();
+
   // Go back to the entry.
-  Builder.SetInsertPoint(entry);
+  ++entry_ptr;
+  Builder.SetInsertPoint(entry, entry_ptr);
+
   if (CGDebugInfo *DI = getDebugInfo()) {
     // Emit debug information for all the BlockDeclRefDecls.
     for (unsigned i=0; i < BlockDeclRefDecls.size(); ++i) {
@@ -691,8 +694,6 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr,
       }
     }
   }
-  // And now go back to the body
-  EmitBlock(body);
   // And resume where we left off.
   if (resume == 0)
     Builder.ClearInsertionPoint();
index 645125667c9a5f46f5935b5193d16e3f34ca8fce..0b386841f19dca5369a04bf209710b6829174b2c 100644 (file)
@@ -1088,7 +1088,7 @@ void CGDebugInfo::EmitDeclare(const BlockDeclRefExpr *BDRE, unsigned Tag,
   // The llvm optimizer and code generator are not yet ready to support
   // optimized code debugging.
   const CompileOptions &CO = M->getCompileOpts();
-  if (CO.OptimizationLevel)
+  if (CO.OptimizationLevel || Builder.GetInsertBlock() == 0)
     return;
 
   uint64_t XOffset = 0;
@@ -1269,7 +1269,7 @@ void CGDebugInfo::EmitDeclare(const BlockDeclRefExpr *BDRE, unsigned Tag,
                                        Decl->getNameAsString(), Unit, Line, Ty,
                                        addr);
   // Insert an llvm.dbg.declare into the current block.
-  DebugFactory.InsertDeclare(Storage, D, Builder.GetInsertBlock());
+  DebugFactory.InsertDeclare(Storage, D, Builder.GetInsertPoint());
 }
 
 void CGDebugInfo::EmitDeclareOfAutoVariable(const VarDecl *Decl,