]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Updated code for unlinking regions and update stmt_eh_regions as well
authorPranil Dey <mkdeyp@gmail.com>
Sat, 5 Oct 2024 04:56:15 +0000 (10:26 +0530)
committerPranil Dey <mkdeyp@gmail.com>
Sat, 5 Oct 2024 04:56:15 +0000 (10:26 +0530)
gcc/tree-eh.cc

index ef7d773d83728b2ccda46a17a56d5a49e20d0daa..89daf32046e3d8d768082f1dbf9008381929cbb9 100644 (file)
@@ -2327,7 +2327,6 @@ bool match_lp (eh_landing_pad lp, vec<tree> *exception_types) {
 }
 
 void unlink_eh_region(eh_region region) {
-    gcc_assert(!region->inner);
     eh_region *link;
 
     // Check if region is root
@@ -2389,14 +2388,22 @@ void update_stmt_eh_region (gimple *stmt) {
     eh_region region = lp->region;
     eh_region prev_region = NULL;
 
+    bool update = false;
+    if (gimple_code (stmt) == GIMPLE_RESX)
+    region = region->outer;
+
     // Walk up the region tree
     while (region) {
         switch (region->type) {
             case ERT_CLEANUP:
+                if (!update)
+                     return;
+
                 if (gimple_code (stmt) == GIMPLE_RESX){
                   gresx *resx_stmt = as_a <gresx *> (stmt);
                   gimple_resx_set_region (resx_stmt, region->index);
                 }
+
                 else *cfun->eh->throw_stmt_table->get (const_cast<gimple *> (stmt)) = lp->index;
 
                 unlink_eh_region (region);
@@ -2404,11 +2411,15 @@ void update_stmt_eh_region (gimple *stmt) {
                 return;
 
             case ERT_TRY:
+                if (update)
+                return;
+
                 if (match_lp (lp, &exception_types)) {
                   if (gimple_code (stmt) == GIMPLE_RESX){
                     gresx *resx_stmt = as_a <gresx *> (stmt);
                     gimple_resx_set_region (resx_stmt, region->index);
                   }
+
                   else *cfun->eh->throw_stmt_table->get (const_cast<gimple *> (stmt)) = lp->index;
 
                   unlink_eh_region (region);
@@ -2432,8 +2443,12 @@ void update_stmt_eh_region (gimple *stmt) {
         }
         prev_region = region;
         region = region->outer;
+        update = true;
     }
 
+    if (!update)
+    return;
+
     if (gimple_code (stmt) == GIMPLE_RESX){
       gresx *resx_stmt = as_a <gresx *> (stmt);
       gimple_resx_set_region (resx_stmt, 0);
@@ -3115,9 +3130,9 @@ bool stmt_throw_types (function *fun, gimple *stmt, vec<tree> *ret_vector) {
     bool type_exists = true;
 
     switch (gimple_code (stmt)) {
-        // case GIMPLE_RESX:
-        //     extract_fun_resx_types (fun, ret_vector);
-        //     return !ret_vector->is_empty ();
+        case GIMPLE_RESX:
+            extract_fun_resx_types (fun, ret_vector);
+            return !ret_vector->is_empty ();
 
         case GIMPLE_CALL:
             type_exists =  extract_types_for_call (as_a<gcall*> (stmt), ret_vector);