[llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c llvm-representation.h

Chris Lattner lattner at cs.uiuc.edu
Mon Mar 15 23:24:01 PST 2004


Changes in directory llvm-gcc/gcc:

llvm-expand.c updated: 1.24 -> 1.25
llvm-representation.h updated: 1.2 -> 1.3

---
Log message:

Fix PR291: http://llvm.cs.uiuc.edu/PR291 : [llvm-g++] Cleanups and exception handlers don't mix properly


---
Diffs of the changes:  (+30 -4)

Index: llvm-gcc/gcc/llvm-expand.c
diff -u llvm-gcc/gcc/llvm-expand.c:1.24 llvm-gcc/gcc/llvm-expand.c:1.25
--- llvm-gcc/gcc/llvm-expand.c:1.24	Tue Mar  9 21:05:22 2004
+++ llvm-gcc/gcc/llvm-expand.c	Mon Mar 15 23:23:37 2004
@@ -951,6 +951,9 @@
     case COND_NESTING: break;
     }
 
+    if (f->target_bb->EnclosingScope == thisblock)
+      DeleteThisFixup = 1;
+
   ReallyDeleteThisFixup:
     if (DeleteThisFixup) {
       /* Unlink this node in the fixup chain */
@@ -1010,9 +1013,10 @@
   
   /* add the new basic block to the function */
   llvm_ilist_push_back(llvm_basicblock, Fn->BasicBlocks, BB);
+  BB->EnclosingScope = Fn->ExpandInfo->InnermostBlockScope;
 
   /* If there were any pending fixups that branch to this block, they can be
-   * deleted now, because they do not exit the current scope.
+   * deleted now, because they do not exist the current scope.
    */
   if (BB->FixupExistsForThisBlock) {
     llvm_goto_fixup **fl = &Fn->ExpandInfo->GotoFixupList;
@@ -1563,8 +1567,23 @@
   /* Does any containing block have a stack level or cleanups?  If not, no fixup
      is needed, and that is the normal case (the only case, for standard C).  */
   block = Fn->ExpandInfo->InnermostBlockScope;
-  while (block && !block->x.block.cleanups)
-    block = block->next;
+  if (!BB->EnclosingScope) {
+    /* This is a forward reference to a block.  Since we know that we can't jump
+     * INTO a region that has cleanups, we can only be branching out.
+     */
+    while (block && !block->x.block.cleanups)
+      block = block->next;
+  } else {
+    /* This is not a forward reference.  Check to see if there are any blocks
+     * with cleanups before we get to the enclosing block.
+     */
+    llvm_nesting *EnclosingScope = (llvm_nesting *)BB->EnclosingScope;
+    
+    while (block && block != EnclosingScope && !block->x.block.cleanups)
+      block = block->next;
+    if (block == EnclosingScope)
+      return;
+  }
 
   /* If there are no cleanups that need to be fun for this branch, don't create
    * a fixup.
@@ -6619,7 +6638,7 @@
 
   assert(!Fn->ExpandInfo->CleanupBlock && "Cleanupblock not handled yet!");
 
-  /* C++ uses this.  */
+  /* C++ uses this?  */
   if (end_bindings) {
     LLVM_TODO();
     expand_end_bindings (0, 0, 0);


Index: llvm-gcc/gcc/llvm-representation.h
diff -u llvm-gcc/gcc/llvm-representation.h:1.2 llvm-gcc/gcc/llvm-representation.h:1.3
--- llvm-gcc/gcc/llvm-representation.h:1.2	Tue Mar  9 20:50:57 2004
+++ llvm-gcc/gcc/llvm-representation.h	Mon Mar 15 23:23:37 2004
@@ -217,6 +217,13 @@
    * which will branch to this block.
    */
   int FixupExistsForThisBlock;
+
+  /* EnclosingScope - This member contains the innermost scope that contains the
+   * basic block.  This is only valid when a basic block is added to the
+   * program, it is not valid if a label or block is, for example, forward
+   * referenced.  This member is used when expanding cleanups.
+   */
+  void *EnclosingScope;
 } llvm_basicblock;
 
 llvm_basicblock *llvm_basicblock_new(const char *);





More information about the llvm-commits mailing list