[llvm-commits] [llvm-gcc-4.2] r67095 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Devang Patel dpatel at apple.com
Tue Mar 17 12:46:45 PDT 2009


Author: dpatel
Date: Tue Mar 17 14:46:45 2009
New Revision: 67095

URL: http://llvm.org/viewvc/llvm-project?rev=67095&view=rev
Log:
Keep track of nested regions properly. Pop out of all remaining regions at the end.


Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=67095&r1=67094&r2=67095&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Mar 17 14:46:45 2009
@@ -725,6 +725,7 @@
   edge e;
   edge_iterator ei;
   tree stmt_block = NULL_TREE;
+  unsigned RegionCount = 0;
   FOR_EACH_BB (bb) {
     for (block_stmt_iterator bsi = bsi_start (bb); !bsi_end_p (bsi);
          bsi_next (&bsi)) {
@@ -734,15 +735,24 @@
       // while dealing with variable's debug info locations.
       tree new_stmt_block = TREE_BLOCK (stmt);
       if (TheDebugInfo && new_stmt_block && !optimize) {
-        if (stmt_block == NULL_TREE) 
+        if (stmt_block == NULL_TREE) {
           // This is beginning of function. llvm.dbg.func.start is emitted so
           // no need to emit llvm.dbg.region.start here.
+          tree t = new_stmt_block;
+          while (TREE_CODE (BLOCK_SUPERCONTEXT (t)) != FUNCTION_DECL) {
+            TheDebugInfo->EmitRegionStart(Builder.GetInsertBlock());
+            t = BLOCK_SUPERCONTEXT (t);
+            RegionCount++;
+          } 
           stmt_block = new_stmt_block;
+        }
         else {
           if (stmt_block != new_stmt_block) {
-            if (BLOCK_SUPERCONTEXT (new_stmt_block) == stmt_block) 
+            if (BLOCK_SUPERCONTEXT (new_stmt_block) == stmt_block) {
               // Entering new scope. Emit llvm.dbg.func.start.
               TheDebugInfo->EmitRegionStart(Builder.GetInsertBlock());
+              RegionCount++;
+            }
             else if (BLOCK_SUPERCONTEXT (new_stmt_block) == 
                      BLOCK_SUPERCONTEXT (stmt_block)) {
               // Entering new scope at the same level. End previous current 
@@ -750,10 +760,11 @@
               // llvm.dbg.region.start to start new region.
               TheDebugInfo->EmitRegionEnd(Builder.GetInsertBlock());
               TheDebugInfo->EmitRegionStart(Builder.GetInsertBlock());
-            } else
-              // Leaving current scop.e Emit llvm.dbg.region.end.
+            } else {
+              // Leaving current scope. Emit llvm.dbg.region.end.
               TheDebugInfo->EmitRegionEnd(Builder.GetInsertBlock());
-            
+              RegionCount--;
+            }
             stmt_block = new_stmt_block;
           }
         }
@@ -777,7 +788,13 @@
       EmitBlock(BasicBlock::Create(""));
     }
   }
- 
+
+  // Pop out of dbg info regions.
+  while(RegionCount) {
+    TheDebugInfo->EmitRegionEnd(Builder.GetInsertBlock());
+    RegionCount--;
+  }
+
   // Wrap things up.
   return FinishFunctionBody();
 }





More information about the llvm-commits mailing list