[cfe-commits] r83221 - in /cfe/trunk/lib/CodeGen: CGBlocks.cpp CGDebugInfo.cpp

Mike Stump mrs at apple.com
Thu Oct 1 15:29:41 PDT 2009


Author: mrs
Date: Thu Oct  1 17:29:41 2009
New Revision: 83221

URL: http://llvm.org/viewvc/llvm-project?rev=83221&view=rev
Log:
Implement a FIXME.  This improves codegen just a tad.

Modified:
    cfe/trunk/lib/CodeGen/CGBlocks.cpp
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=83221&r1=83220&r2=83221&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Oct  1 17:29:41 2009
@@ -663,20 +663,23 @@
   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 @@
       }
     }
   }
-  // And now go back to the body
-  EmitBlock(body);
   // And resume where we left off.
   if (resume == 0)
     Builder.ClearInsertionPoint();

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=83221&r1=83220&r2=83221&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Oct  1 17:29:41 2009
@@ -1088,7 +1088,7 @@
   // 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 @@
                                        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,





More information about the cfe-commits mailing list